You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Adam Augusta (JIRA)" <ji...@apache.org> on 2015/10/27 16:26:27 UTC

[jira] [Created] (GROOVY-7648) Problem with @CompileStatic, generic types, and varags

Adam Augusta created GROOVY-7648:
------------------------------------

             Summary: Problem with @CompileStatic, generic types, and varags
                 Key: GROOVY-7648
                 URL: https://issues.apache.org/jira/browse/GROOVY-7648
             Project: Groovy
          Issue Type: Bug
          Components: groovy-jdk
    Affects Versions: 2.4.4
            Reporter: Adam Augusta


Similar to GROOVY-7182, groovyc fails to handle generic types if a class uses @CompileStatic and the generically typed method has a varargs parameter. Removal of @CompileStatic or the varargs parameter eliminates the compile error.

(Patterned after original use case involving Spring HATEOAS ControllerLinkBuilder#methodOn.)

{code:title=VarArgsGenericsCase.groovy|borderStyle=solid}
import groovy.transform.CompileStatic

@CompileStatic
class VarArgsGenericsCase {

    def markus(String name) {
        methodOn(VarArgsGenericsCase.class).markus(name)
    }

    static <T> T methodOn(Class<T> clazz, Object... parameters) {
        return clazz.newInstance()
    }
}
{code}

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
VarArgsGenericsCase.groovy: 7: [Static type checking] - Cannot find matching met
hod java.lang.Object#markus(java.lang.String). Please check if the declared type
 is right and if the method exists.
 @ line 7, column 9.
           methodOn(VarArgsGenericsCase.class).markus(name)
{code}



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