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 653627c13b GROOVY-11369: STC: map entry comes before access method (pt.4) 653627c13b is described below commit 653627c13bc007ca38343ed9e9d0dcbc679e5c46 Author: Eric Milles <eric.mil...@thomsonreuters.com> AuthorDate: Wed May 15 16:21:59 2024 -0500 GROOVY-11369: STC: map entry comes before access method (pt.4) --- .../groovy/transform/stc/StaticTypeCheckingVisitor.java | 2 +- .../groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index d9c64f9625..dda0cc9998 100644 --- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -1633,7 +1633,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport { 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); diff --git a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy index 2ccad3f7dd..e548125340 100644 --- a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy +++ b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy @@ -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()