Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BFEAF200B65 for ; Tue, 2 Aug 2016 10:00:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BEA73160A8C; Tue, 2 Aug 2016 08:00:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 15CD1160A76 for ; Tue, 2 Aug 2016 10:00:35 +0200 (CEST) Received: (qmail 51745 invoked by uid 500); 2 Aug 2016 08:00:35 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 51713 invoked by uid 99); 2 Aug 2016 08:00:35 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Aug 2016 08:00:35 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 088792C0E38 for ; Tue, 2 Aug 2016 08:00:35 +0000 (UTC) Date: Tue, 2 Aug 2016 08:00:35 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-7774) Collection addAll fails CompileStatic type checking when adding a collection of subtypes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 02 Aug 2016 08:00:36 -0000 [ https://issues.apache.org/jira/browse/GROOVY-7774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15403569#comment-15403569 ] ASF GitHub Bot commented on GROOVY-7774: ---------------------------------------- Github user blackdrag commented on a diff in the pull request: https://github.com/apache/groovy/pull/376#discussion_r73109779 --- Diff: src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java --- @@ -5176,7 +5176,9 @@ public static Map groupBy(Object[] self, List closures) { G key = outer.getKey(); List> entries = outer.getValue(); Map target = createSimilarMap(self); - putAll(target, entries); --- End diff -- my suggestion would be to change putAll to `public static Map putAll(Map self, Collection> entries) ` which more or less adds `? extends` before the Map.Entry part and to change back to use the putAll instead of the loop > 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 > Assignee: Paul King > Fix For: 2.4.8 > > > 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 set = new HashSet() > Set toAdd = ...... > set.addAll(toAdd) > {code} > However, the following works, which to me is inconsistent: > {code} > Set set = new HashSet() > Set toAdd = ...... > for(Y y in toAdd) { > set.add(y) > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)