From commits-return-5422-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Wed Feb 7 16:15:02 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 088CC18067C for ; Wed, 7 Feb 2018 16:15:02 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id EBF04160C3C; Wed, 7 Feb 2018 15:15:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1F6D4160C5D for ; Wed, 7 Feb 2018 16:15:00 +0100 (CET) Received: (qmail 90318 invoked by uid 500); 7 Feb 2018 15:15:00 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 90302 invoked by uid 99); 7 Feb 2018 15:15:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2018 15:15:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 19A09E9654; Wed, 7 Feb 2018 15:15:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sunlan@apache.org To: commits@groovy.apache.org Date: Wed, 07 Feb 2018 15:15:02 -0000 Message-Id: <85f9bd7801614b89939c028ddf4a9bab@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/4] groovy git commit: Minor refactoring: remove duplicated code of `StaticInvocationWriter` 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 Authored: Wed Feb 7 22:43:31 2018 +0800 Committer: Daniel Sun 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) {