You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/07/30 05:33:20 UTC

[jira] [Commented] (GROOVY-7774) Collection addAll fails CompileStatic type checking when adding a collection of subtypes

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

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

GitHub user paulk-asert opened a pull request:

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

    GROOVY-7774: Collection addAll fails CompileStatic type checking when…

    … adding a collection of subtypes

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

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

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

    https://github.com/apache/groovy/pull/376.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 #376
    
----
commit 456fe6f089901668fd2e98f005da7240ca778827
Author: paulk <pa...@asert.com.au>
Date:   2016-07-30T05:31:50Z

    GROOVY-7774: Collection addAll fails CompileStatic type checking when adding a collection of subtypes

----


> Collection addAll fails CompileStatic type checking when adding a collection of subtypes
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7774
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7774
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.4.3
>         Environment: Windows, Java 8.
>            Reporter: Darren Hurt
>
> Suppose X is an interface and Y an interface such that Y extends X
> The following code throws a compilation error (the outer class is annotated as @CompileStatic).
> {code}
> Set<X> set = new HashSet<X>()
> Set<Y> toAdd = ......
> set.addAll(toAdd)
> {code}
> However, the following works, which to me is inconsistent:
> {code}
> Set<X> set = new HashSet<X>()
> Set<Y> toAdd = ......
> for(Y y in toAdd) {
>   set.add(y)
> }
> {code}



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