[ https://issues.apache.org/jira/browse/GROOVY-7907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marcin Zajaczkowski updated GROOVY-7907: ---------------------------------------- Description: 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(...)`. was: 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 { <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(...)`. > Cannot assign value of type java.lang.Object with varargs, perameterized > 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 > Priority: Minor > > 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)