[ https://issues.apache.org/jira/browse/GROOVY-9058?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16810904#comment-16810904 ]
Eric Milles commented on GROOVY-9058: ------------------------------------- I tried to make the minimal change since I do not have groovy core downloaded to run the tests. The {{if (lastArg && inferredType.isArray())}} seems to have something to do with vargs handling. I'm not sure its exact purpose 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 element type of the collection being iterated over. All I can say with confidence 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 { > public List<Object[]> bar() { return null; } > }{code} > and this Groovy class: > {code:java} > package test51 > import groovy.transform.CompileStatic > @CompileStatic > class Test51 { > protected void foo() { > List<Object[]> foo = new Foo().bar() > foo.each { row -> > def o = row[0] > } > } > > List bar() { > } > }{code} > This produces a compiler error because {{row}} is resolved as {{Object}} > rather than {{Object[]}}. > A workaround is to declare {{row}} as {{Object[] row}} in the closure > parameter list. -- This message was sent by Atlassian JIRA (v7.6.3#76005)