Skip to content

Commit

Permalink
GROOVY-11360: STC: fix for NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Apr 24, 2024
1 parent 6d33b44 commit b87d2dc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,9 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re
pexp.putNodeMetaData(DYNAMIC_RESOLUTION, Boolean.TRUE);
pexp.removeNodeMetaData(DECLARATION_INFERRED_TYPE);
pexp.removeNodeMetaData(INFERRED_TYPE);
visitor.visitMethod(mopMethod);
if (visitor != null) {
visitor.visitMethod(mopMethod);
}
return true;
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/test/groovy/transform/stc/ClosuresSTCTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,30 @@ class ClosuresSTCTest extends StaticTypeCheckingTestCase {
'''
}

// GROOVY-11360
void testLexicalScopeVersusGetDynamicProperty() {
assertScript '''
class C {
private static final value = "C"
def m(D d) {
d.with {
return value
}
}
}
class D {
def get(String name) {
if (name == "value") "D"
}
}
String result = new C().m(new D())
assert result == 'C'
'''
}

// GROOVY-9089
void testOwnerVersusDelegateFromNestedClosure() {
String declarations = '''
Expand Down

0 comments on commit b87d2dc

Please sign in to comment.