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-8263) Import alias introduces weird property
Date Tue, 18 Jul 2017 17:40:00 GMT

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

Daniil Ovchinnikov updated GROOVY-8263:
---------------------------------------
    Description: 
{code:title=com/foo/Bar.java}
package com.foo;
public class Bar {
    public static Object getSome() {return 42;}
}
{code}

{code:title=playground.groovy}
import static com.foo.Bar.some as getAbc
println abc // 42
println getAbc
println getGetAbc()
{code}

AFAIU an alias introduces property into a file which is being compiled (in this case {{getAbc}}
and {{getGetAbc()}}). This works as expected.
But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}.
This happens when alias is itself a valid getter name.

Is it a bug or a feature?

One more thing to consider.
Given {{abc}} is valid, {{getAbc()}} should be valid too. Instead it behaves like {{getAbc.call()}}.


  was:
{code:title=com/foo/Bar.java}
package com.foo;
public class Bar {
    public static Object getSome() {return 42;}
}
{code}

{code:title=playground.groovy}
import static com.foo.Bar.some as getAbc
println abc // 42
println getAbc
println getGetAbc()
{code}

AFAIU an alias introduces property into a file which is being compiled (in this case {{getAbc}}
and {{getGetAbc()}}). This works as expected.
But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}.

Is it a bug or a feature?


> Import alias introduces weird property
> --------------------------------------
>
>                 Key: GROOVY-8263
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8263
>             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() {return 42;}
> }
> {code}
> {code:title=playground.groovy}
> import static com.foo.Bar.some as getAbc
> println abc // 42
> println getAbc
> println getGetAbc()
> {code}
> AFAIU an alias introduces property into a file which is being compiled (in this case
{{getAbc}} and {{getGetAbc()}}). This works as expected.
> But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}.
> This happens when alias is itself a valid getter name.
> Is it a bug or a feature?
> One more thing to consider.
> Given {{abc}} is valid, {{getAbc()}} should be valid too. Instead it behaves like {{getAbc.call()}}.




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

Mime
View raw message