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/11/15 15:13:57 UTC

[groovy] branch GROOVY_3_0_X updated (4adbc65b6a -> b1ddd9c517)

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

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


    from 4adbc65b6a STC: fewer calls to `chooseBestMethod`
     new c59d28f9bd `CastExpression`: indicate coercion in `getText()` and `toString()`
     new b1ddd9c517 GROOVY-9739: prevent typecast expression with null type

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:
 src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)


[groovy] 02/02: GROOVY-9739: prevent typecast expression with null type

Posted by em...@apache.org.
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

commit b1ddd9c51725840cf67ee58827056f9ab4ce9a61
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Nov 15 09:09:53 2022 -0600

    GROOVY-9739: prevent typecast expression with null type
    
    3_0_X backport
---
 src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java
index 303514f02a..a640c0de3e 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java
@@ -110,6 +110,6 @@ public class CastExpression extends Expression {
 
     @Override
     public void setType(final ClassNode type) {
-        super.setType(type);
+        super.setType(java.util.Objects.requireNonNull(type)); // GROOVY-9739
     }
 }


[groovy] 01/02: `CastExpression`: indicate coercion in `getText()` and `toString()`

Posted by em...@apache.org.
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

commit c59d28f9bd18da13686019aec179e9a68f0ca009
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Nov 15 08:44:51 2022 -0600

    `CastExpression`: indicate coercion in `getText()` and `toString()`
---
 src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java
index 4932112b55..303514f02a 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/CastExpression.java
@@ -82,7 +82,7 @@ public class CastExpression extends Expression {
 
     @Override
     public String toString() {
-        return super.toString() +"[(" + getType().getName() + ") " + expression + "]";
+        return super.toString() + "[" + getText() + "]";
     }
 
     @Override
@@ -102,7 +102,10 @@ public class CastExpression extends Expression {
 
     @Override
     public String getText() {
-        return "(" + getType().toString(false) + ") " + expression.getText(); // TODO: add alternate for "as"?
+        if (isCoerce()) {
+            return expression.getText() + " as " + getType().toString(false);
+        }
+        return "(" + getType().toString(false) + ") " + expression.getText();
     }
 
     @Override