groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [7/7] groovy git commit: GROOVY-8377: Equals and hash code ast performance (tweak typing info for !== and === : closes #633)
Date Fri, 17 Nov 2017 11:56:06 GMT
GROOVY-8377: Equals and hash code ast performance (tweak typing info for !== and === : closes
#633)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e4e3bc60
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e4e3bc60
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e4e3bc60

Branch: refs/heads/GROOVY_2_6_X
Commit: e4e3bc60808d45cb2eb2e2d08bc6e654f2060a4a
Parents: 0cd1bcc
Author: paulk <paulk@asert.com.au>
Authored: Fri Nov 17 20:48:58 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Fri Nov 17 21:55:38 2017 +1000

----------------------------------------------------------------------
 .../groovy/transform/stc/StaticTypeCheckingVisitor.java      | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e4e3bc60/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 8789a4f..10021c1 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -110,7 +110,9 @@ import static org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound;
 import static org.codehaus.groovy.syntax.Types.ASSIGN;
 import static org.codehaus.groovy.syntax.Types.ASSIGNMENT_OPERATOR;
 import static org.codehaus.groovy.syntax.Types.COMPARE_EQUAL;
+import static org.codehaus.groovy.syntax.Types.COMPARE_IDENTICAL;
 import static org.codehaus.groovy.syntax.Types.COMPARE_NOT_EQUAL;
+import static org.codehaus.groovy.syntax.Types.COMPARE_NOT_IDENTICAL;
 import static org.codehaus.groovy.syntax.Types.COMPARE_NOT_IN;
 //import static org.codehaus.groovy.syntax.Types.COMPARE_NOT_INSTANCEOF;
 import static org.codehaus.groovy.syntax.Types.COMPARE_TO;
@@ -3591,12 +3593,16 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
         ClassNode leftRedirect = left.redirect();
         ClassNode rightRedirect = right.redirect();
 
+        if (op == COMPARE_NOT_IDENTICAL || op == COMPARE_IDENTICAL) {
+            return boolean_TYPE;
+        }
+
         Expression leftExpression = expr.getLeftExpression();
         Expression rightExpression = expr.getRightExpression();
         if (op == ASSIGN || op == ASSIGNMENT_OPERATOR || op == ELVIS_EQUAL) {
             if (leftRedirect.isArray() && implementsInterfaceOrIsSubclassOf(rightRedirect,
Collection_TYPE)) return leftRedirect;
             if (leftRedirect.implementsInterface(Collection_TYPE) && rightRedirect.implementsInterface(Collection_TYPE))
{
-                // because of type inferrence, we must perform an additional check if the
right expression
+                // because of type inference, we must perform an additional check if the
right expression
                 // is an empty list expression ([]). In that case and only in that case,
the inferred type
                 // will be wrong, so we will prefer the left type
                 if (rightExpression instanceof ListExpression) {


Mime
View raw message