From commits-return-10066-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Sun Dec 1 10:41:43 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 40B221806D5 for ; Sun, 1 Dec 2019 11:41:42 +0100 (CET) Received: (qmail 26007 invoked by uid 500); 1 Dec 2019 10:41:41 -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 25532 invoked by uid 99); 1 Dec 2019 10:41:40 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Dec 2019 10:41:40 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id A96A38B6A2; Sun, 1 Dec 2019 10:41:39 +0000 (UTC) Date: Sun, 01 Dec 2019 10:41:58 +0000 To: "commits@groovy.apache.org" Subject: [groovy] 20/20: fix for "in closure" tracking MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: sunlan@apache.org In-Reply-To: <157519689837.22317.13480026071125475937@gitbox.apache.org> References: <157519689837.22317.13480026071125475937@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: groovy X-Git-Refname: refs/heads/GROOVY_3_0_X X-Git-Reftype: branch X-Git-Rev: 4fb0893728a35ee7202960b52029e146234c76ab X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20191201104139.A96A38B6A2@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch GROOVY_3_0_X in repository https://gitbox.apache.org/repos/asf/groovy.git commit 4fb0893728a35ee7202960b52029e146234c76ab Author: Eric Milles AuthorDate: Sat Nov 30 14:50:58 2019 -0600 fix for "in closure" tracking - anon. inner class visited as closure expression (cherry picked from commit 6f96c2b04eed0ae7051e7b8e18e22681d593d08a) --- src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java index 3efd775..76664b3 100644 --- a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java +++ b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java @@ -259,7 +259,7 @@ public class VariableScopeVisitor extends ClassCodeVisitorSupport { } private static boolean isAnonymous(final ClassNode node) { - return (!node.isEnum() && node instanceof InnerClassNode && ((InnerClassNode) node).isAnonymous()); + return (node instanceof InnerClassNode && ((InnerClassNode) node).isAnonymous() && !node.isEnum()); } private void markClosureSharedVariables() { @@ -435,8 +435,8 @@ public class VariableScopeVisitor extends ClassCodeVisitorSupport { @Override public void visitClosureExpression(final ClosureExpression expression) { pushState(); - inClosure = true; expression.setVariableScope(currentScope); + inClosure = !isAnonymous(currentScope.getParent().getClassScope()); if (expression.isParameterSpecified()) { for (Parameter parameter : expression.getParameters()) {