groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Refine STC of `call` method
Date Wed, 31 Jan 2018 09:47:08 GMT
Repository: groovy
Updated Branches:
  refs/heads/native-lambda 37dc84543 -> 9f51d3b3e


Refine STC of `call` method


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

Branch: refs/heads/native-lambda
Commit: 9f51d3b3efa0c891b3bfba6ac23e684597caf6d3
Parents: 37dc845
Author: sunlan <sunlan@apache.org>
Authored: Wed Jan 31 17:47:02 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Wed Jan 31 17:47:02 2018 +0800

----------------------------------------------------------------------
 .../transform/stc/StaticTypeCheckingVisitor.java    | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/9f51d3b3/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
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 dcb3ab6..e9ccffd 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -281,13 +281,15 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
     public static final MethodNode CLOSURE_CALL_ONE_ARG;
     public static final MethodNode CLOSURE_CALL_VARGS;
 
+    public static final String CALL = "call";
+
     static {
         // Cache closure call methods
-        CLOSURE_CALL_NO_ARG = CLOSURE_TYPE.getDeclaredMethod("call", Parameter.EMPTY_ARRAY);
-        CLOSURE_CALL_ONE_ARG = CLOSURE_TYPE.getDeclaredMethod("call", new Parameter[]{
+        CLOSURE_CALL_NO_ARG = CLOSURE_TYPE.getDeclaredMethod(CALL, Parameter.EMPTY_ARRAY);
+        CLOSURE_CALL_ONE_ARG = CLOSURE_TYPE.getDeclaredMethod(CALL, new Parameter[]{
                 new Parameter(OBJECT_TYPE, "arg")
         });
-        CLOSURE_CALL_VARGS = CLOSURE_TYPE.getDeclaredMethod("call", new Parameter[]{
+        CLOSURE_CALL_VARGS = CLOSURE_TYPE.getDeclaredMethod(CALL, new Parameter[]{
                 new Parameter(OBJECT_TYPE.makeArray(), "args")
         });
     }
@@ -3404,7 +3406,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
     }
 
     protected boolean isClosureCall(final String name, final Expression objectExpression,
final Expression arguments) {
-        if (objectExpression instanceof ClosureExpression && ("call".equals(name)||"doCall".equals(name)))
return true;
+        if (objectExpression instanceof ClosureExpression && (CALL.equals(name)||"doCall".equals(name)))
return true;
         if (objectExpression == VariableExpression.THIS_EXPRESSION) {
             FieldNode fieldNode = typeCheckingContext.getEnclosingClassNode().getDeclaredField(name);
             if (fieldNode != null) {
@@ -3414,7 +3416,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
                 }
             }
         } else {
-            if (!"call".equals(name) && !"doCall".equals(name)) return false;
+            if (!CALL.equals(name) && !"doCall".equals(name)) return false;
         }
         return (getType(objectExpression).equals(CLOSURE_TYPE));
     }
@@ -4119,9 +4121,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
                 collectAllInterfaceMethodsByName(receiver, name, methods);
                 methods.addAll(OBJECT_TYPE.getMethods(name));
 
-                if (ClassHelper.isSAMType(receiver)) {
+                if (CALL.equals(name) && ClassHelper.isSAMType(receiver)) {
                     MethodNode sam = ClassHelper.findSAM(receiver);
-                    MethodNode callMethodNode = new MethodNode("call", sam.getModifiers(),
sam.getReturnType(), sam.getParameters(), sam.getExceptions(), sam.getCode());
+                    MethodNode callMethodNode = new MethodNode(CALL, sam.getModifiers(),
sam.getReturnType(), sam.getParameters(), sam.getExceptions(), sam.getCode());
                     callMethodNode.setDeclaringClass(sam.getDeclaringClass());
                     callMethodNode.setSourcePosition(sam);
 


Mime
View raw message