groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniil Ovchinnikov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8264) Setter accessed via getter import alias with setter name
Date Wed, 19 Jul 2017 10:56:00 GMT

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

Daniil Ovchinnikov updated GROOVY-8264:
---------------------------------------
    Description: 
{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}

  was:
{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=playground.groovy}
import static com.foo.Bar.getSome as setAbc
setAbc() // prints 'getter'
setAbc(2) // MME: No signature of method: static com.foo.Bar.getSome() is applicable
abc = 1 // prints 'setter 1', should throw MME
{code}


> Setter accessed via getter import alias with setter name
> --------------------------------------------------------
>
>                 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)

Mime
View raw message