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 655353481f classgen: upper before outer 655353481f is described below commit 655353481ffc8721dcaa1110db1b10a71f7132f2 Author: Eric Milles <eric.mil...@thomsonreuters.com> AuthorDate: Wed May 22 14:08:52 2024 -0500 classgen: upper before outer --- .../classgen/asm/sc/StaticTypesCallSiteWriter.java | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java index 0201132ac2..3ffc0dfb68 100644 --- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java +++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java @@ -23,7 +23,6 @@ import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.FieldNode; -import org.codehaus.groovy.ast.InnerClassNode; import org.codehaus.groovy.ast.MethodNode; import org.codehaus.groovy.ast.Parameter; import org.codehaus.groovy.ast.PropertyNode; @@ -455,7 +454,7 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes getterName = "is" + capitalize(propertyName); getterNode = receiverType.getGetterMethod(getterName); } - if (getterNode != null && receiver instanceof ClassExpression && !CLASS_Type.equals(receiverType) && !getterNode.isStatic()) { + if (getterNode != null && !getterNode.isStatic() && receiver instanceof ClassExpression && !CLASS_Type.equals(receiverType)) { return false; } @@ -464,10 +463,7 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes // generated by the compiler yet (generated by the Verifier) PropertyNode propertyNode = receiverType.getProperty(propertyName); if (getterNode == null && propertyNode != null) { - String prefix = "get"; - if (boolean_TYPE.equals(propertyNode.getOriginType())) { - prefix = "is"; - } + String prefix = boolean_TYPE.equals(propertyNode.getOriginType()) ? "is" : "get"; getterName = prefix + capitalize(propertyName); getterNode = new MethodNode( getterName, @@ -488,22 +484,27 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes return true; } - if (receiverType instanceof InnerClassNode && !receiverType.isStaticClass()) { - if (makeGetPropertyWithGetter(receiver, receiverType.getOuterClass(), propertyName, safe, implicitThis)) { - return true; - } - } - // GROOVY-7149: check direct interfaces - for (ClassNode node : receiverType.getInterfaces()) { - if (makeGetPropertyWithGetter(receiver, node, propertyName, safe, implicitThis)) { + for (ClassNode traitClass : receiverType.getInterfaces()) { + if (makeGetPropertyWithGetter(receiver, traitClass, propertyName, safe, implicitThis)) { return true; } } - // go upper level + // check super class ClassNode superClass = receiverType.getSuperClass(); if (superClass != null) { - return makeGetPropertyWithGetter(receiver, superClass, propertyName, safe, implicitThis); + if (makeGetPropertyWithGetter(receiver, superClass, propertyName, safe, implicitThis)) { + return true; + } + } + // check outer class + ClassNode outerClass = receiverType.getOuterClass(); + if (implicitThis && outerClass != null + && !outerClass.implementsInterface(MAP_TYPE) + && (receiverType.getModifiers() & ACC_STATIC) == 0) { + if (makeGetPropertyWithGetter(receiver, outerClass, propertyName, safe, implicitThis)) { + return true; + } } return false;