You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniil Ovchinnikov (JIRA)" <ji...@apache.org> on 2017/07/19 10:58:00 UTC

[jira] [Updated] (GROOVY-8264) Wrong method accessed via aliased import

     [ https://issues.apache.org/jira/browse/GROOVY-8264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniil Ovchinnikov updated GROOVY-8264:
---------------------------------------
    Summary: Wrong method accessed via aliased import  (was: Wrong meth)

> Wrong method accessed via aliased import
> ----------------------------------------
>
>                 Key: GROOVY-8264
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8264
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.12
>            Reporter: Daniil Ovchinnikov
>
> {code:title=com/foo/Bar.java}package com.foo;
> public class Bar {
>     public static Object getSome() {
>         System.out.println("getter");
>         return 42;
>     }
>     public static void setSome(Object a) {
>         System.out.println("setter " + a);
>     }
> }
> {code}
> {code:title=getterAsSetter.groovy}
> import static com.foo.Bar.getSome as setAbc
> setAbc()  // prints 'getter' as expected
> setAbc(2) // throws MME as expected (No signature of method: static com.foo.Bar.getSome() is applicable)
> abc = 2   // prints 'setter 2'; should throw MME, because it's equivalent to setAbc(2)
> {code}
> {code:title=setterAsGetter.groovy}
> import static com.foo.Bar.setSome as getAbc
> getAbc(null)  // prints 'setter null' as expected
> getAbc()      // prints 'setter null' as expected, equivalent to getAbc(null)
> abc           // prints 'getter'; should print 'setter null', because it's equivalent to getAbc()
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)