Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.4.5
-
None
-
None
Description
Hi,
Please take a look at this code:
import groovy.transform.CompileStatic import static A1.a // as a1 import static A2.a // as a2 import static A3.a // as a3 @CompileStatic class A1 { static void a(String str) { println 'a1' } } @CompileStatic class A2 { static void a(int i) { println 'a2' } } @CompileStatic class A3 { static void a(boolean b) { println 'a3' } } a("string") a(1) a(true)
Running it, a compile exception is thrown:
Caught: groovy.lang.MissingMethodException: No signature of method: static A3.a() is applicable for argument types: (java.lang.String) values: [string]
Possible solutions: a(boolean), any(), any(groovy.lang.Closure), is(java.lang.Object), wait(), wait(long)
groovy.lang.MissingMethodException: No signature of method: static A3.a() is applicable for argument types: (java.lang.String) values: [string]
Possible solutions: a(boolean), any(), any(groovy.lang.Closure), is(java.lang.Object), wait(), wait(long)
It seems that the latest import overwrites the previous ones.
Is this the expected behavior in Groovy (Java allows this syntax)?
Best regards,
Mihai