groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7907) Cannot assign value of type java.lang.Object with varargs, parameterized method and @CompileStatic
Date Fri, 19 Aug 2016 04:20:22 GMT

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

ASF GitHub Bot commented on GROOVY-7907:
----------------------------------------

Github user asfgit closed the pull request at:

    https://github.com/apache/groovy/pull/385


> 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
>            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)

Mime
View raw message