groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch GROOVY_2_5_X updated: GROOVY-9153: create mutable constant expression
Date Tue, 04 Jun 2019 10:49:55 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
     new ba1f853  GROOVY-9153: create mutable constant expression
ba1f853 is described below

commit ba1f853175cc5676e46bb6da8f1cc757a22eff0a
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Mon Jun 3 13:16:06 2019 -0500

    GROOVY-9153: create mutable constant expression
---
 .../classgen/asm/sc/StaticInvocationWriter.java    |  2 +-
 src/test/groovy/bugs/Groovy9153.groovy             | 36 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index abab966..01e8b13 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -281,7 +281,7 @@ public class StaticInvocationWriter extends InvocationWriter {
 
             if (emn.isStaticExtension()) {
                 // it's a static extension method
-                argumentList.add(0, ConstantExpression.NULL);
+                argumentList.add(0, new ConstantExpression(null));
             } else {
                 ClassNode classNode = controller.getClassNode();
                 boolean isThisOrSuper = false;
diff --git a/src/test/groovy/bugs/Groovy9153.groovy b/src/test/groovy/bugs/Groovy9153.groovy
new file mode 100644
index 0000000..e28b629
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy9153.groovy
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * 	http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package groovy.bugs
+
+import groovy.transform.CompileStatic
+import org.codehaus.groovy.ast.expr.ConstantExpression
+
+@CompileStatic
+final class Groovy9153 extends GroovyTestCase {
+
+    void testConstantExpressionNULL() {
+        assertScript '''
+            @groovy.transform.CompileStatic
+            File tempDir() {
+                return File.createTempDir()
+            }
+        '''
+        assert ConstantExpression.NULL.getNodeMetaData().isEmpty()
+    }
+}


Mime
View raw message