groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 23/23: GROOVY-9237: restore constructors for EmptyExpression and EmptyStatement (provide empty immutable metadatamap)
Date Fri, 11 Oct 2019 13:54:36 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit b58fcabe1f98b7627c8b3f7148afeb4c3581d01c
Author: Paul King <paulk@asert.com.au>
AuthorDate: Fri Oct 11 20:03:24 2019 +1000

     GROOVY-9237: restore constructors for EmptyExpression and EmptyStatement (provide empty
immutable metadatamap)
    
    (cherry picked from commit fdfc38bb2827a488202847243a03501feb4ed5d0)
---
 src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java b/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java
index 5365b88..2353127 100644
--- a/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java
+++ b/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java
@@ -21,6 +21,7 @@ package org.codehaus.groovy.ast.stmt;
 import org.codehaus.groovy.ast.ASTNode;
 import org.codehaus.groovy.ast.GroovyCodeVisitor;
 
+import java.util.Collections;
 import java.util.Map;
 
 public class EmptyStatement extends Statement {
@@ -32,6 +33,11 @@ public class EmptyStatement extends Statement {
         super();
     }
 
+    protected EmptyStatement(Map<?, ?> metaDataMap) {
+        super();
+        super.setMetaDataMap(metaDataMap);
+    }
+
     @Override
     public boolean isEmpty() {
         return true;
@@ -48,7 +54,7 @@ public class EmptyStatement extends Statement {
      * Immutable singleton that is recommended for use when source range or any
      * other occurrence-specific metadata is not needed.
      */
-    public static final EmptyStatement INSTANCE = new EmptyStatement() {
+    public static final EmptyStatement INSTANCE = new EmptyStatement(Collections.EMPTY_MAP)
{
 
         private void throwUnsupportedOperationException() {
             throw new UnsupportedOperationException("EmptyStatement.INSTANCE is immutable");


Mime
View raw message