Repository: groovy
Updated Branches:
  refs/heads/master 18de060f6 -> 6db885207


Revert "Treat conditional statement as expression" related commits


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6db88520
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6db88520
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6db88520

Branch: refs/heads/master
Commit: 6db8852079a600c2af28f5a1efb15e46316023a7
Parents: 18de060
Author: sunlan <sun...@apache.org>
Authored: Thu Oct 5 14:33:40 2017 +0800
Committer: sunlan <sun...@apache.org>
Committed: Thu Oct 5 14:33:40 2017 +0800

----------------------------------------------------------------------
 src/antlr/GroovyParser.g4                       |  1 -
 src/test/gls/generics/GenericsTest.groovy       |  6 +-
 src/test/groovy/bugs/Groovy5318Bug.groovy       |  2 +-
 .../apache/groovy/parser/antlr4/AstBuilder.java | 18 ----
 .../parser/antlr4/GroovyParserTest.groovy       |  4 -
 .../ConditionalStatementAsExpression_01x.groovy | 91 --------------------
 6 files changed, 4 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/src/antlr/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index dd0bcfb..23e7e7a 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -784,7 +784,6 @@ expressionListElement[boolean canSpread]
 enhancedStatementExpression
     :   statementExpression
     |   standardLambdaExpression
-    |   conditionalStatement        // treat conditional statement as 
expression
     ;
 
 /**

http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/src/test/gls/generics/GenericsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/gls/generics/GenericsTest.groovy 
b/src/test/gls/generics/GenericsTest.groovy
index 0f8df3b..3fe0e69 100644
--- a/src/test/gls/generics/GenericsTest.groovy
+++ b/src/test/gls/generics/GenericsTest.groovy
@@ -398,7 +398,7 @@ import java.util.concurrent.atomic.AtomicInteger
         } else {
             shouldFailCompilationWithMessage """
                 def list1 = new ArrayList<Integer()
-            """, "Unexpected input:"
+            """, "Unexpected input: 'new ArrayList<Integer('"
 
             shouldFailCompilationWithMessage """
                 List<Integer list2 = new ArrayList<Integer>()
@@ -427,11 +427,11 @@ import java.util.concurrent.atomic.AtomicInteger
 
             shouldFailCompilationWithMessage """
                 def List<List<Integer> history = new ArrayList<List<Integer>>()
-            """, "Unexpected input: '<'"
+            """, "Unexpected input: 'def List<List<Integer> history'"
 
             shouldFailCompilationWithMessage """
                 def List<List<Integer>> history = new ArrayList<List<Integer>()
-            """, "Unexpected input:"
+            """, "Unexpected input: 'new ArrayList<List<Integer>('"
         }
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/src/test/groovy/bugs/Groovy5318Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy5318Bug.groovy 
b/src/test/groovy/bugs/Groovy5318Bug.groovy
index 8feaf6d..bf2610a 100644
--- a/src/test/groovy/bugs/Groovy5318Bug.groovy
+++ b/src/test/groovy/bugs/Groovy5318Bug.groovy
@@ -31,7 +31,7 @@ class Groovy5318Bug extends CompilableTestSupport {
         if (ParserVersion.V_2 == CompilerConfiguration.DEFAULT.parserVersion) {
             assert message.contains('Unexpected type arguments found prior to: 
ArrayList')
         } else {
-            assert message.contains('Unexpected input:')
+            assert message.contains('Unexpected input: \'new 
java.util<Integer>.\'')
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git 
a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
 
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index c69cf3c..157a5be 100644
--- 
a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ 
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -1979,24 +1979,6 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
             expression = ((ExpressionStatement) 
this.visit(ctx.statementExpression())).getExpression();
         } else if (asBoolean(ctx.standardLambdaExpression())) {
             expression = 
this.visitStandardLambdaExpression(ctx.standardLambdaExpression());
-        } else if (asBoolean(ctx.conditionalStatement())) {
-            expression =
-                    configureAST(
-                        createCallMethodCallExpression(
-                            configureAST(
-                                    new ClosureExpression(
-                                        Parameter.EMPTY_ARRAY,
-                                        configureAST(
-                                            
this.createBlockStatement(this.visitConditionalStatement(ctx.conditionalStatement())),
-                                            ctx
-                                        )
-                                    ),
-                                    ctx
-                            ),
-                            new ArgumentListExpression()
-                        ),
-                        ctx
-                    );
         } else {
             throw createParsingFailedException("Unsupported enhanced statement 
expression: " + ctx.getText(), ctx);
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
----------------------------------------------------------------------
diff --git 
a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
 
b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index abadf5f..fd65344 100644
--- 
a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ 
b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -373,10 +373,6 @@ class GroovyParserTest extends GroovyTestCase {
         doRunAndTest('core/SafeChainOperator.groovy');
     }
 
-    void "test groovy core - ConditionalStatementAsExpression"() {
-        doRunAndTest('core/ConditionalStatementAsExpression_01x.groovy');
-    }
-
     void "test groovy core - BUG"() {
         doRunAndTest('bugs/BUG-GROOVY-4757.groovy');
         doRunAndTest('bugs/BUG-GROOVY-5652.groovy');

http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/subprojects/parser-antlr4/src/test/resources/core/ConditionalStatementAsExpression_01x.groovy
----------------------------------------------------------------------
diff --git 
a/subprojects/parser-antlr4/src/test/resources/core/ConditionalStatementAsExpression_01x.groovy
 
b/subprojects/parser-antlr4/src/test/resources/core/ConditionalStatementAsExpression_01x.groovy
deleted file mode 100644
index 3bc5d0f..0000000
--- 
a/subprojects/parser-antlr4/src/test/resources/core/ConditionalStatementAsExpression_01x.groovy
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *  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.
- */
-
-import groovy.transform.CompileStatic
-
-def testConditionalStatementAsExpression() {
-    def a = 1
-    def b = 2
-    def max = if (a > b) a else b
-    assert 2 == max
-
-    def c = 1
-    def result = switch (c) {
-        case 1:
-            2; break
-        default:
-            0
-    }
-    assert 2 == result
-
-    def d = 6
-    d = if (d > 0) 1 else if (d == 0) 0 else -1
-    assert 1 == d
-
-    def e = 7
-    e = switch (e) {
-        case 5:
-            6; break
-        case 6:
-            7; break
-        case 7:
-            8; break
-        default:
-            0
-    }
-    assert 8 == e
-}
-
-testConditionalStatementAsExpression()
-
-@CompileStatic
-def testCsConditionalStatementAsExpression() {
-    def a = 1
-    def b = 2
-    def max = if (a > b) a else b
-    assert 2 == max
-
-    def c = 1
-    def result = switch (c) {
-        case 1:
-            2; break
-        default:
-            0
-    }
-    assert 2 == result
-
-    def d = 6
-    d = if (d > 0) 1 else if (d == 0) 0 else -1
-    assert 1 == d
-
-    def e = 7
-    e = switch (e) {
-        case 5:
-            6; break
-        case 6:
-            7; break
-        case 7:
-            8; break
-        default:
-            0
-    }
-    assert 8 == e
-}
-
-testCsConditionalStatementAsExpression()

Reply via email to