You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2019/11/30 21:02:59 UTC

[groovy] branch master updated: fix for "in closure" tracking

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f96c2b  fix for "in closure" tracking
6f96c2b is described below

commit 6f96c2b04eed0ae7051e7b8e18e22681d593d08a
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Nov 30 14:50:58 2019 -0600

    fix for "in closure" tracking
    
    - anon. inner class visited as closure expression
---
 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()) {