You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/10/25 16:33:00 UTC

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

     [ https://issues.apache.org/jira/browse/GROOVY-7648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles reassigned GROOVY-7648:
-----------------------------------

    Assignee: Eric Milles

> 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
>            Assignee: Eric Milles
>            Priority: Major
>
> 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.
> (Clarification: methodOn need not be defined in the @CompileStatic class. In the original case, the method was ControllerLinkBuilder#methodOn from Spring's HATEOAS library.)
> {code:title=VarArgsGenericsCase.groovy|borderStyle=solid}
> import groovy.transform.CompileStatic
> @CompileStatic
> class VarArgsGenericsCase {
>     def markus(String name) {
>         methodOn(VarArgsGenericsCase).markus(name)
>     }
>     static <T> T methodOn(Class<T> clazz, Object... parameters) {
>         return clazz.newInstance()
>     }
> }
> {code}
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> VarArgsGenericsCase.groovy: 7: [Static type checking] - Cannot find matching method java.lang.Object#markus(java.lang.String). Please check if the declared type is correct and if the method exists.
>  @ line 7, column 9.
>            methodOn(VarArgsGenericsCase).markus(name)
>            ^
> 1 error
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)