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/18 17:40:00 UTC
[jira] [Updated] (GROOVY-8263) Import alias introduces weird
property
[ 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)