You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2019/12/22 19:31:07 UTC
[groovy] 02/02: remove repeat call to findSAM(ClassNode)
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 7f1ef57ff967441cc98c1c1ff925aaf4f7979626
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Dec 22 13:17:49 2019 -0600
remove repeat call to findSAM(ClassNode)
---
.../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);
+ }
}
}