Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F0D70200B70 for ; Sat, 27 Aug 2016 13:22:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EF41C160AB2; Sat, 27 Aug 2016 11:22:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 431BD160AA6 for ; Sat, 27 Aug 2016 13:22:45 +0200 (CEST) Received: (qmail 70000 invoked by uid 500); 27 Aug 2016 11:22:44 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 69989 invoked by uid 99); 27 Aug 2016 11:22:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Aug 2016 11:22:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id A1725C031E for ; Sat, 27 Aug 2016 11:22:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.702 X-Spam-Level: X-Spam-Status: No, score=-0.702 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id rCSR-OQMIaAk for ; Sat, 27 Aug 2016 11:22:42 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 214CD5F30A for ; Sat, 27 Aug 2016 11:22:42 +0000 (UTC) Received: from [192.168.1.6] ([89.12.175.172]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LwaQZ-1b3bM413zr-018JHZ for ; Sat, 27 Aug 2016 13:22:35 +0200 Subject: Re: Method resolution pondering To: dev@groovy.apache.org References: From: Jochen Theodorou Message-ID: <57C177F8.7090003@gmx.org> Date: Sat, 27 Aug 2016 13:22:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:xB9d0ieC0kojBq39+c2zM3c0c1zFBUNgLQzLJYBIO3u9hclzRTY hfy4vKWTe45jYJfof1UnyeI9CVCscFSF7dr3Ln/G6Y5GLGoWlhhF3wmL42/RqttAfvXG/pi vhZCnfyr5fmCiAYfl+/9JNKNQ/ZzGgI6opOHza8flka8kWob6lWSsq+j/fhDZAPkrKupVkG 1STCIdVn5jVeEOyxlsPeg== X-UI-Out-Filterresults: notjunk:1;V01:K0:WXqH0GVl+KA=:V+gUk3kiue0/NNyv3Fk+KV PNJml4XGetvkgDDdqZesK1Auc6+ESGwUxCU+cjMHH0mgEEkB1owhmteDgLULa6l+bh154v7XW 2IWAQO2cQFTbjlyOCgwLGBU0hLH1uFFrGCOyaLpOEQ9H7eJBHXhb0u2WVv+nIAA3ooQIvCUoC mZ9pJQ8a/IHoS3+aPiOT7Ns0AN0ieIyjy9v2cStziu9tXrG9rDitUUsBccP0/G0y45O/MNLtP gI5M/WIXBNGWrDaHj9DGTdX6yAF4ojCiIYDWVzVhTEoG1yjImdGEf+AJcXYI27tZhUmDrC7kx GoSD1Q9uktVAjeJQKaXx4oe60F2ArYGWvI5iK2NOV+Dh8G0/rtnQN3bVmLt8vyah51sJEpLwC 0birQpEYIHRdXSvw0lxgdXE1fzdzqu76cmAzTmnb/QfFi1COjw3QjsBxt7ZWRyiRgMeAe+xyM McdRBFkI+MSB05xq8KWerA2VnuF1+S8tkKHxQZBmZY4YMWn4HhJop4AyrWhBPF4NiupuVZGvC 39b6Fb1kMVq1FdCxLpVb0dzt8RnlFuTG1+e0rWizEqsyfbaaVS+gd/Blm7eJZONjJesSKW5nr LpYuJzpmklLC2OHaVnpKkzVUkQPv8aHA9mFFZMK6iHLeJ+uxANFXtKtBJY/kRDoIfsGM4z8hp +zCqHRFETeCfzg0YcCfmTYC79BHfMVcAnb4ZkK2IA4epQ3w8sBebTv5QeKOewCvDv2BmgyKpw kxItFqQ+VUv1DSJAVUQ2CErfUEoSATGp+gIhTolEemFf9s8g+rK8wtxfOneWqzVCcuXMKLloi dsuSrAB archived-at: Sat, 27 Aug 2016 11:22:46 -0000 On 27.08.2016 12:22, Paul King wrote: > I am just wondering what people's thoughts are on the different > approaches different parts of Groovy take for method resolution when > multiple methods are matched. > > Given this code: > > import groovy.transform.CompileStatic > > interface FooA {} > interface FooB {} > class FooAB implements FooA, FooB {} > @CompileStatic > class TestGroovy { > static void test() { println new TestGroovy().foo(new FooAB()) } > def foo(FooB x) { 43 } > def foo(FooA x) { 42 } > } > > TestGroovy.test() > > The output will be 42 because FooA comes before FooB in the implements > clause for FooAB. I think we should orientate us at Java for this... and in Java I would expect this to fail compilation > If we leave off the @CompileStatic, their will be a runtime exception: > > groovy.lang.GroovyRuntimeException: Ambiguous method overloading for > method TestGroovy#foo that I expect > Given this trait example: > > trait BarA { def bar() { println 42 } } > trait BarB { def bar() { println 43 } } > class BarAB implements BarA, BarB {} > new BarAB().bar() > > the output will be 43 because BarB comes last in the implements clause. that is not because of method resolution, that is because of how the traits are mapped to BarAB. BarAB has in fact only one bar() method. So I do not really see a problem with this one bye Jochen