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, perameterized method and @CompileStatic
Date Wed, 17 Aug 2016 02:11:20 GMT

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

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

GitHub user paulk-asert opened a pull request:

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

    GROOVY-7907: Cannot assign value of type java.lang.Object with vararg…

    …s, perameterized method and @CompileStatic

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/paulk-asert/groovy groovy7907

Alternatively you can review and apply these changes as the patch at:

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

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #385
    
----
commit 174e64ef7e8eb5d8726c1f55c00c50f8fee2527e
Author: paulk <paulk@asert.com.au>
Date:   2016-08-17T02:08:49Z

    GROOVY-7907: Cannot assign value of type java.lang.Object with varargs, perameterized
method and @CompileStatic

----


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

Mime
View raw message