diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java index cdf68525904..4c77d35888f 100644 --- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java +++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java @@ -78,6 +78,7 @@ import static org.codehaus.groovy.transform.sc.StaticCompilationVisitor.ARRAYLIST_CONSTRUCTOR; import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isAssignment; import static org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferLoopElementType; +import static org.codehaus.groovy.transform.stc.StaticTypesMarker.DECLARATION_INFERRED_TYPE; import static org.codehaus.groovy.transform.stc.StaticTypesMarker.DIRECT_METHOD_CALL_TARGET; import static org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_FUNCTIONAL_INTERFACE_TYPE; import static org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_TYPE; @@ -171,8 +172,10 @@ protected void evaluateBinaryExpressionWithAssignment(final String method, final public void evaluateEqual(final BinaryExpression expression, final boolean defineVariable) { Expression leftExpression = expression.getLeftExpression(); Expression rightExpression = expression.getRightExpression(); - if (defineVariable && (rightExpression instanceof LambdaExpression || rightExpression instanceof MethodReferenceExpression)) { - rightExpression.putNodeMetaData(INFERRED_FUNCTIONAL_INTERFACE_TYPE, leftExpression.getNodeMetaData(INFERRED_TYPE)); + if (rightExpression instanceof LambdaExpression || rightExpression instanceof MethodReferenceExpression) { + ClassNode leftType = leftExpression.getNodeMetaData(DECLARATION_INFERRED_TYPE); // GROOVY-11353 + if (leftType == null) leftType = leftExpression.getNodeMetaData(INFERRED_TYPE); + rightExpression.putNodeMetaData(INFERRED_FUNCTIONAL_INTERFACE_TYPE, leftType); } if (leftExpression instanceof PropertyExpression) { PropertyExpression pexp = (PropertyExpression) leftExpression;