You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Cazacu Mihai (JIRA)" <ji...@apache.org> on 2016/02/03 09:22:40 UTC

[jira] [Created] (GROOVY-7744) static import of multiple methods with same name

Cazacu Mihai created GROOVY-7744:
------------------------------------

             Summary: static import of multiple methods with same name
                 Key: GROOVY-7744
                 URL: https://issues.apache.org/jira/browse/GROOVY-7744
             Project: Groovy
          Issue Type: Improvement
          Components: groovy-jdk
    Affects Versions: 2.4.5
            Reporter: Cazacu Mihai


Hi,

Please take a look at this code:

{code:title=test.groovy|borderStyle=solid}
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)
{code}

Running it, a compile exception is thrown:

{quote}
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)
{quote}

It seems that the latest import overwrites the previous ones.
Is this the expected behavior in Groovy (Java allows this syntax)?

Best regards,
Mihai




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)