groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcin Zajaczkowski (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-7907) Cannot assign value of type java.lang.Object with varargs, perameterized method and @CompileStatic
Date Mon, 15 Aug 2016 11:15:22 GMT
Marcin Zajaczkowski created GROOVY-7907:
-------------------------------------------

             Summary: 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 {
    <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)

Mime
View raw message