groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [3/4] groovy git commit: Minor refactoring: remove duplicated code of `StaticInvocationWriter`
Date Wed, 07 Feb 2018 15:15:02 GMT
Minor refactoring: remove duplicated code of `StaticInvocationWriter`

(cherry picked from commit 03c69ca)

(cherry picked from commit 98adb35)


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

Branch: refs/heads/GROOVY_2_5_X
Commit: 87c298aab461d33b6e14f12ce6bd9b342c1dbdb9
Parents: 63e7d90
Author: Daniel Sun <realbluesun@hotmail.com>
Authored: Wed Feb 7 22:43:31 2018 +0800
Committer: Daniel Sun <realbluesun@hotmail.com>
Committed: Wed Feb 7 23:03:45 2018 +0800

----------------------------------------------------------------------
 .../groovy/classgen/asm/sc/StaticInvocationWriter.java | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/87c298aa/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index a6329ce..88b6d99 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -390,16 +390,19 @@ public class StaticInvocationWriter extends InvocationWriter {
                 && !declaringClass.equals(classNode)) {
             if (tryBridgeMethod(target, receiver, implicitThis, args, classNode)) {
                 return true;
-            } else if (declaringClass != classNode) {
-                controller.getSourceUnit().addError(new SyntaxException("Cannot call private
method " + (target.isStatic() ? "static " : "") +
-                        declaringClass.toString(false) + "#" + target.getName() + " from
class " + classNode.toString(false), receiver.getLineNumber(), receiver.getColumnNumber(),
receiver.getLastLineNumber(), receiver.getLastColumnNumber()));
+            } else {
+                checkAndAddCannotCallPrivateMethodError(target, receiver, classNode, declaringClass);
             }
         }
+        checkAndAddCannotCallPrivateMethodError(target, receiver, classNode, declaringClass);
+        return false;
+    }
+
+    private void checkAndAddCannotCallPrivateMethodError(MethodNode target, Expression receiver,
ClassNode classNode, ClassNode declaringClass) {
         if (declaringClass != classNode) {
             controller.getSourceUnit().addError(new SyntaxException("Cannot call private
method " + (target.isStatic() ? "static " : "") +
-                                                declaringClass.toString(false) + "#" + target.getName()
+ " from class " + classNode.toString(false), receiver.getLineNumber(), receiver.getColumnNumber(),
receiver.getLastLineNumber(), receiver.getLastColumnNumber()));
+                    declaringClass.toString(false) + "#" + target.getName() + " from class
" + classNode.toString(false), receiver.getLineNumber(), receiver.getColumnNumber(), receiver.getLastLineNumber(),
receiver.getLastColumnNumber()));
         }
-        return false;
     }
 
     protected static boolean isPrivateBridgeMethodsCallAllowed(ClassNode receiver, ClassNode
caller) {


Mime
View raw message