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] [Commented] (GROOVY-8254) Alias is ignored in constructor call
Date Tue, 14 Nov 2017 17:09:00 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16251745#comment-16251745
] 

Daniil Ovchinnikov commented on GROOVY-8254:
--------------------------------------------

AFAIU there are no differences in how aliased/regular imports are treated by compiler.

I.e. in case of
{code}
import test.Bar
import foo.Foo as Bar
{code}
the second import will overwrite the first one and vice versa, because essentially these imports
are both _aliased_:
{code}
import test.Bar as Bar
import foo.Foo as Bar
{code}

I suppose anonymous class references should obey the same rules as reference in new expression,
i.e. prefer a class in the same file over any import.


> Alias is ignored in constructor call
> ------------------------------------
>
>                 Key: GROOVY-8254
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8254
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.12
>            Reporter: Daniil Ovchinnikov
>
> {code:title=foo/Foo.groovy}
> package foo
> class Foo {}
> {code}
> {code:title=test/test.groovy}
> package test
> import foo.Foo as Bar
> class Bar {}
> def regular = new Bar()
> def anonymous = new Bar() {}
> println regular.class // class test.Bar
> println anonymous.class.superclass // class foo.Foo
> {code}
> Either both of the invocations should use alias or both of them should use class defined
in the same file. 



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

Mime
View raw message