You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2022/02/24 20:17:58 UTC

[groovy] branch GROOVY_2_5_X updated (3a459ed -> 5411b2e)

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a change to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 3a459ed  GROOVY-6851, GROOVY-10104: SC: skip Verifier-generated methods
     new ce33de2  GROOVY-9955: SC: fix for static property access
     new 5411b2e  fix for JDK7

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../classgen/asm/sc/StaticTypesCallSiteWriter.java      |  4 ++--
 .../groovy/transform/stc/StaticTypeCheckingVisitor.java | 17 ++++++++---------
 .../asm/sc/FieldsAndPropertiesStaticCompileTest.groovy  | 14 --------------
 3 files changed, 10 insertions(+), 25 deletions(-)

[groovy] 02/02: fix for JDK7

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 5411b2e312dc46c6cf571534531799ae8a96bd1d
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Feb 24 14:05:38 2022 -0600

    fix for JDK7
---
 .../groovy/transform/stc/StaticTypeCheckingVisitor.java | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 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 18efda4..6d69498 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -125,7 +125,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
@@ -2032,18 +2031,18 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         visitPrefixOrPostifExpression(expression, inner, type);
     }
 
-    private static Optional<Token> asAssignment(final int op) {
+    private static Token asAssignment(final int op) {
         switch (op) {
             case Types.PLUS_PLUS:
             case Types.PREFIX_PLUS_PLUS:
             case Types.POSTFIX_PLUS_PLUS:
-                return Optional.of(Token.newSymbol(Types.PLUS_EQUAL, -1, -1));
+                return Token.newSymbol(Types.PLUS_EQUAL, -1, -1);
             case Types.MINUS_MINUS:
             case Types.PREFIX_MINUS_MINUS:
             case Types.POSTFIX_MINUS_MINUS:
-                return Optional.of(Token.newSymbol(Types.MINUS_EQUAL, -1, -1));
+                return Token.newSymbol(Types.MINUS_EQUAL, -1, -1);
         }
-        return Optional.empty();
+        return null;
     }
 
     private static ClassNode getMathWideningClassNode(final ClassNode type) {
@@ -2059,9 +2058,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
     }
 
     private void visitPrefixOrPostifExpression(final Expression origin, final Expression operand, final int operator) {
-        Optional<Token> token = asAssignment(operator);
-        if (token.isPresent()) { // push "operand += 1" or "operand -= 1" onto stack for LHS checks
-            typeCheckingContext.pushEnclosingBinaryExpression(binX(operand, token.get(), constX(1)));
+        Token token = asAssignment(operator);
+        if (token != null) { // push "operand += 1" or "operand -= 1" onto stack for LHS checks
+            typeCheckingContext.pushEnclosingBinaryExpression(binX(operand, token, constX(1)));
         }
         try {
             operand.visit(this);
@@ -2110,7 +2109,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                 storeType(origin, isPostfix ? operandType : inferReturnTypeGenerics(operandType, node, ArgumentListExpression.EMPTY_ARGUMENTS));
             }
         } finally {
-            if (token.isPresent()) typeCheckingContext.popEnclosingBinaryExpression();
+            if (token != null) typeCheckingContext.popEnclosingBinaryExpression();
         }
     }
 

[groovy] 01/02: GROOVY-9955: SC: fix for static property access

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit ce33de2817a57b8acd51d31eb3dd42037ff0a616
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Feb 24 13:55:39 2022 -0600

    GROOVY-9955: SC: fix for static property access
---
 .../groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java  |  4 ++--
 .../asm/sc/FieldsAndPropertiesStaticCompileTest.groovy     | 14 --------------
 2 files changed, 2 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 cec4416..082cb10 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
@@ -803,12 +803,12 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes
         OperandStack operandStack = controller.getOperandStack();
 
         if (name != null && compileStack.isLHS()) {
-            ClassNode classNode = controller.getClassNode();
-            ClassNode receiverType = controller.getTypeChooser().resolveType(objectExpression, classNode);
+            ClassNode receiverType = getPropertyOwnerType(objectExpression); // GROOVY-9955
             if (adapter == AsmClassGenerator.setField || adapter == AsmClassGenerator.setGroovyObjectField) {
                 if (setField(expression, objectExpression, receiverType, name)) return;
             }
             if (ExpressionUtils.isThisExpression(objectExpression)) {
+                ClassNode classNode = controller.getClassNode();
                 FieldNode fieldNode = receiverType.getField(name);
                 if (fieldNode != null && fieldNode.isPrivate() && !receiverType.equals(classNode)
                         && StaticInvocationWriter.isPrivateBridgeMethodsCallAllowed(receiverType, classNode)) {
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
index 5e562e7..4a2d48f 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
@@ -853,18 +853,4 @@ final class FieldsAndPropertiesStaticCompileTest extends FieldsAndPropertiesSTCT
             assert new A(['foo1', 'foo2']).fooNames.size() == 2
         '''
     }
-
-    @Override // GROOVY-9955
-    void testStaticPropertyWithInheritanceFromAnotherSourceUnit() {
-        assertScript '''
-            import groovy.transform.stc.FieldsAndPropertiesSTCTest.Public
-          //assert Public.answer == 42
-            assert Public.CONST == 'XX'
-            assert Public.VALUE == null
-            Public.VALUE = 'YY'
-            assert Public.VALUE == 'YY'
-            Public.@VALUE = 'ZZ'
-            assert Public.@VALUE == 'ZZ'
-        '''
-    }
 }