groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [2/2] groovy git commit: Revert "Disambiguate closures from code blocks when invoking methods"
Date Wed, 04 Jul 2018 00:26:51 GMT
Revert "Disambiguate closures from code blocks when invoking methods"

The Parrot parser can handle closures and code blocks properly. When calling methods, the
following `{ ... }` will be parsed as closure first, so no breaking changes.


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

Branch: refs/heads/master
Commit: 30b160d0a02bd52ddde855b3d918ae1c35133977
Parents: 8125e18
Author: sunlan <sunlan@apache.org>
Authored: Wed Jul 4 08:21:25 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Wed Jul 4 08:26:02 2018 +0800

----------------------------------------------------------------------
 src/antlr/GroovyParser.g4                       |  3 +-
 .../parser/antlr4/GroovyParserTest.groovy       |  4 ---
 .../test/resources/core/MethodCall_01x.groovy   | 29 --------------------
 3 files changed, 1 insertion(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/30b160d0/src/antlr/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 1a902e4..788626f 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -113,7 +113,6 @@ importDeclaration
     :   annotationsOpt IMPORT STATIC? qualifiedName (DOT MUL | AS alias=identifier)?
     ;
 
-
 typeDeclaration
     :   classOrInterfaceModifiersOpt classDeclaration
     ;
@@ -957,7 +956,7 @@ pathElement returns [int t]
         { $t = 2; }
 
     // Can always append a block, as foo{bar}
-    |   closure
+    |   nls closure
         { $t = 3; }
 
     // Element selection is always an option, too.

http://git-wip-us.apache.org/repos/asf/groovy/blob/30b160d0/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 2140dba..2384b85 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
@@ -415,10 +415,6 @@ class GroovyParserTest extends GroovyTestCase {
         doRunAndTestAntlr4('core/NonStaticClass_01x.groovy');
     }
 
-    void "test groovy core - MethodCall"() {
-        doRunAndTestAntlr4('core/MethodCall_01x.groovy');
-    }
-
     void "test groovy core - BUG"() {
         doRunAndTestAntlr4('bugs/BUG-GROOVY-4757.groovy')
         doRunAndTestAntlr4('bugs/BUG-GROOVY-5652.groovy')

http://git-wip-us.apache.org/repos/asf/groovy/blob/30b160d0/subprojects/parser-antlr4/src/test/resources/core/MethodCall_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodCall_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/MethodCall_01x.groovy
deleted file mode 100644
index aa66cd9..0000000
--- a/subprojects/parser-antlr4/src/test/resources/core/MethodCall_01x.groovy
+++ /dev/null
@@ -1,29 +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.
- */
-
-class MethodCall {
-    def p = 1
-}
-
-def mc = new MethodCall()
-def x = mc.p
-{ // this is a code block(not a closure)
-    mc.p = 2
-}
-assert 2 == mc.p


Mime
View raw message