groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring: remove duplicated code of `StaticInvocationWriter`
Date Wed, 07 Feb 2018 14:43:34 GMT
Repository: groovy
Updated Branches:
  refs/heads/master ea816201e -> 03c69caaf


Minor refactoring: remove duplicated code of `StaticInvocationWriter`


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

Branch: refs/heads/master
Commit: 03c69caaf81cc43fad4abcbe1a2e28b0dac198db
Parents: ea81620
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 22:43:31 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/03c69caa/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 d2b5bc7..1ca5ed5 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