Skip to content

Commit

Permalink
GROOVY-11369: STC: map entry comes before access method (pt.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed May 15, 2024
1 parent fda9b2b commit 653627c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re
foundGetterOrSetter = (foundGetterOrSetter || getter != null || !setters.isEmpty());
}

if (readMode && (isThisExpression(objectExpression) || isSuperExpression(objectExpression) || !isOrImplements(objectExpressionType, MAP_TYPE))) { // GROOVY-11370, GROOVY-11372
if (readMode && !isMapProperty(pexp)) { // GROOVY-11369, GROOVY-11370, GROOVY-11372
// GROOVY-5568, GROOVY-9115, GROOVY-9123: the property may be defined by an extension
for (ClassNode dgmReceiver : isPrimitiveType(receiverType) ? new ClassNode[]{receiverType, getWrapper(receiverType)} : new ClassNode[]{receiverType}) {
Set<MethodNode> methods = findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, getterName);
Expand Down
14 changes: 10 additions & 4 deletions src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -818,14 +818,20 @@ class FieldsAndPropertiesSTCTest extends StaticTypeCheckingTestCase {
assertScript types + '''
class D extends C {
void test() {
def x = this.a
assert x instanceof A
def a = this.a
assert a instanceof A
//typeof(this.b) is A for STC and B for SC
@ASTTest(phase=INSTRUCTION_SELECTION, value={
assert node.getNodeMetaData(INFERRED_TYPE).name == 'B'
})
def z = super.b
assert z instanceof B
def b = super.b
assert b instanceof B
//typeof(this.metaClass) is A for STC and MetaClass for SC
@ASTTest(phase=INSTRUCTION_SELECTION, value={
assert node.getNodeMetaData(INFERRED_TYPE) == METACLASS_TYPE
})
def c = super.metaClass
assert c instanceof MetaClass
}
}
def map = new D()
Expand Down

0 comments on commit 653627c

Please sign in to comment.