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

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


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new 8fa2bd116d GROOVY-11522: fix for NPE
8fa2bd116d is described below

commit 8fa2bd116d1f5fa9393c45251c8bde4bd93c741b
Author: Eric Milles <eric.mil...@thomsonreuters.com>
AuthorDate: Tue Jul 15 12:38:43 2025 -0500

    GROOVY-11522: fix for NPE
---
 .../java/org/codehaus/groovy/classgen/VariableScopeVisitor.java    | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java 
b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
index 5e8af6384c..653a36259e 100644
--- a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
@@ -326,8 +326,7 @@ public class VariableScopeVisitor extends 
ClassCodeVisitorSupport {
         String name = expression.getPropertyAsString();
         if (name == null || name.equals("class")) return;
         Variable member = findClassMember(currentClass, name);
-        if (member == null) return;
-        checkVariableContextAccess(member, expression);
+        if (member != null) checkVariableContextAccess(member, expression);
     }
 
     private void checkVariableContextAccess(final Variable variable, final 
Expression expression) {
@@ -552,9 +551,9 @@ public class VariableScopeVisitor extends 
ClassCodeVisitorSupport {
     @Override
     public void visitFieldExpression(final FieldExpression expression) {
         String name = expression.getFieldName();
-        //TODO: change that to get the correct scope
+        // TODO: change that to get the correct scope
         Variable variable = findVariableDeclaration(name);
-        checkVariableContextAccess(variable, expression);
+        if (variable != null) checkVariableContextAccess(variable, expression);
     }
 
     @Override

Reply via email to