groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 20/20: fix for "in closure" tracking
Date Sun, 01 Dec 2019 10:41:58 GMT
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 <eric.milles@thomsonreuters.com>
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()) {


Mime
View raw message