From notifications-return-16038-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Fri Apr 5 14:51:02 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 198F618067E for ; Fri, 5 Apr 2019 16:51:01 +0200 (CEST) Received: (qmail 60560 invoked by uid 500); 5 Apr 2019 14:51:01 -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 60551 invoked by uid 99); 5 Apr 2019 14:51:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Apr 2019 14:51:01 +0000 Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id BF063E083C for ; Fri, 5 Apr 2019 14:51:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 340202459D for ; Fri, 5 Apr 2019 14:51:00 +0000 (UTC) Date: Fri, 5 Apr 2019 14:51:00 +0000 (UTC) From: "Eric Milles (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-9058) each parameter type not correctly inferenced MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GROOVY-9058?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D168= 10904#comment-16810904 ]=20 Eric Milles commented on GROOVY-9058: ------------------------------------- I tried to make the minimal change since I do not have groovy core download= ed to run the tests. The {{if (lastArg && inferredType.isArray())}} seems = to have something to do with vargs handling. I'm not sure its exact purpos= e without some examples. In the case of this bug, {{originType}} is {{Object}} and {{inferredType}} = is {{Object[]}}. We want to keep it as {{Object[]}} since that is the elem= ent type of the collection being iterated over. All I can say with confide= nce is that this block is where the incorrect inference type is being set. > each parameter type not correctly inferenced > -------------------------------------------- > > Key: GROOVY-9058 > URL: https://issues.apache.org/jira/browse/GROOVY-9058 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.5.6 > Reporter: Mauro Molinari > Priority: Major > > Consider this Java class: > {code:java} > package test51; > import java.util.List; > public class Foo { > =C2=A0=C2=A0 =C2=A0public List bar() { return null; } > }{code} > =C2=A0and this Groovy class: > {code:java} > package test51 > import groovy.transform.CompileStatic > @CompileStatic > class Test51 { > =C2=A0=C2=A0 =C2=A0protected void foo() { > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0List foo =3D new Foo().ba= r() > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0foo.each { row -> > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0def o =3D row[0] > =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} > =C2=A0=C2=A0 =C2=A0} > =C2=A0=C2=A0 =C2=A0 > =C2=A0=C2=A0 =C2=A0List bar() { > =C2=A0=C2=A0 =C2=A0} > }{code} > This produces a compiler error because=C2=A0{{row}} is resolved as=C2=A0{= {Object}} rather than {{Object[]}}. > A workaround is to declare {{row}} as {{Object[] row}} in the closure par= ameter list. -- This message was sent by Atlassian JIRA (v7.6.3#76005)