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 e7b7fc70b0 GROOVY-11522: fix for NPE
e7b7fc70b0 is described below
commit e7b7fc70b08147e5f4973b0be5d16024761774fa
Author: Eric Milles <[email protected]>
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 6e2753d8ea..e4001ee0c5 100644
--- a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
@@ -377,8 +377,7 @@ public class VariableScopeVisitor extends
ClassCodeVisitorSupport {
String name = expression.getPropertyAsString();
if (name == null || "class".equals(name)) 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) {
@@ -710,9 +709,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