Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Compiler
-
Labels:None
-
Number of attachments :
Description
Assume you have a class test.Foo:
package test class Foo { static foo() {'foo'} }
Let's consider some code snippets. IMHO Groovy incorrectly resolves reference 'foo' to statically imported method in all of these cases.
import static test.Foo.foo class Bar { def foo() {'bar'} class Inner { def abc() { assert foo() == 'bar' //statically imported method will be invoked here } } }
import static test.Foo.foo class Bar { def foo() {'bar'} } new Bar().with { assert foo() == 'bar' //statically imported method will be executed }
import static test.Foo.foo class Base { def foo(){'base'} } class Bar extends Base { def abc() { assert foo() == 'base' //statically imported method will be executed } }
I found another case. Assume you have default groovy method 'is' and statically imported 'org.hamcrest.CoreMatchers.is'. I don't know what is more relevant.