You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/12/23 00:34:23 UTC
[groovy] 02/05: remove repeat call to findSAM(ClassNode)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit d61ec94046261589e5dec4302958636ef03eeff0
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Dec 22 13:17:49 2019 -0600
remove repeat call to findSAM(ClassNode)
(cherry picked from commit 7f1ef57ff967441cc98c1c1ff925aaf4f7979626)
---
.../groovy/transform/stc/StaticTypeCheckingVisitor.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index fea37f6..4abb7f3 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -4166,17 +4166,19 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
Expression leftExpression = expr.getLeftExpression();
Expression rightExpression = expr.getRightExpression();
- if (op == ASSIGN || op == ASSIGNMENT_OPERATOR || op == ELVIS_EQUAL) {
- if (rightRedirect.isDerivedFrom(CLOSURE_TYPE) && isSAMType(leftRedirect)) {
+ if (op == EQUAL || op == ELVIS_EQUAL) {
+ if (rightRedirect.isDerivedFrom(CLOSURE_TYPE)) {
ClosureExpression closureExpression = null;
if (rightExpression instanceof ClosureExpression) {
closureExpression = (ClosureExpression) rightExpression;
} else if (rightExpression instanceof MethodReferenceExpression) {
closureExpression = rightExpression.getNodeMetaData(CONSTRUCTED_LAMBDA_EXPRESSION);
}
-
if (closureExpression != null) {
- return inferSAMTypeGenericsInAssignment(left, findSAM(left), right, closureExpression);
+ MethodNode abstractMethod = findSAM(left);
+ if (abstractMethod != null) {
+ return inferSAMTypeGenericsInAssignment(left, abstractMethod, right, closureExpression);
+ }
}
}