[ https://issues.apache.org/jira/browse/GROOVY-9058?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16808788#comment-16808788 ]
Eric Milles commented on GROOVY-9058: ------------------------------------- This is what I am trying out: {code:java} ClassNode originType = getOriginalDeclarationType(leftExpression); typeCheckAssignment(expression, leftExpression, originType, rightExpression, resultType); // if assignment succeeds but result type is not a subtype of original type, then we are in a special cast handling and we must update the result type if (/*GRECLIPSE add*/(leftExpression instanceof VariableExpression && !((VariableExpression) leftExpression).isDynamicTyped()) ||/*GRECLIPSE end*/!implementsInterfaceOrIsSubclassOf(getWrapper(resultType), getWrapper(originType))) { resultType = originType; } else if (!lType.isEnum() && lType.isUsingGenerics() && hasRHSIncompleteGenericTypeInfo(resultType)) { // for example, LHS is List<ConcreteClass> and RHS is List<T> where T is a placeholder resultType = lType; } {code} It covers the reported case, but does not handle assignments to properties, like {{foo.bar = value}}. A check for {{leftExpression instanceof PropertyExpression}} could be added in front of the variable expression check. Not sure if either of these two changes has any impact on chained assignments like {{baz = foo.bar = value}}. > 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)