[ 
https://issues.apache.org/jira/browse/GROOVY-7907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15469970#comment-15469970
 ] 

Marcin Zajaczkowski commented on GROOVY-7907:
---------------------------------------------

Thanks for a quick fix.

> Cannot assign value of type java.lang.Object with varargs, parameterized 
> method and @CompileStatic
> --------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7907
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7907
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.7
>         Environment: Groovy 2.4.7 (tested also with 2.4.4)
>            Reporter: Marcin Zajaczkowski
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 2.4.8
>
>
> Static compilation fails when method is parameterized and there are varargs 
> arguments which are not used in the call.
> {code}
> Error:(9, 23) Groovyc: [Static type checking] - Cannot assign value of type 
> java.lang.Object to variable of type Ext.
> {code}
> Simple classes to reproduce the problem:
> {code}
> public class FooInJava { //needs to be in Java, a class in Groovy works fine
>     <T> T create(Class<T> type, Object... args) { return null; }
> }
> class Ext {}
> @CompileStatic
> class FooMain {
>     static void main(String[] args) {
>         Ext create = new FooInJava().create(Ext) //casting is required to 
> make compilation pass
>     }
> }
> {code}
> It only occurs if a class with unfortunate method signature is written in 
> Java and static compilation is enabled. Casting to the right type helps. 
> Originally spotted with Gradle - `ExtensionContainer.create(...)`.



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

Reply via email to