You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/06/26 16:22:42 UTC
[groovy] branch GROOVY_3_0_X updated: GROOVY-10150: Eliminate
ambiguities while parsing non-static class creator
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
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new f3e7b85 GROOVY-10150: Eliminate ambiguities while parsing non-static class creator
f3e7b85 is described below
commit f3e7b856aad08611cbbd2e477dd879d639d0c379
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jun 27 00:05:12 2021 +0800
GROOVY-10150: Eliminate ambiguities while parsing non-static class creator
(cherry picked from commit 8c794fd54ac02002a5ca53a3da1490746d9c3a08)
---
src/antlr/GroovyParser.g4 | 6 +++---
src/test/groovy/bugs/Groovy8947.groovy | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 418778c..0d62859 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -905,6 +905,9 @@ pathExpression returns [int t]
pathElement returns [int t]
: nls
(
+ DOT nls NEW creator[1]
+ { $t = 6; }
+ |
// AT: foo.@bar selects the field (or attribute), not property
(
( DOT // The all-powerful dot.
@@ -919,9 +922,6 @@ pathElement returns [int t]
)
namePart
{ $t = 1; }
- |
- DOT nls NEW creator[1]
- { $t = 6; }
// Can always append a block, as foo{bar}
| closureOrLambdaExpression
diff --git a/src/test/groovy/bugs/Groovy8947.groovy b/src/test/groovy/bugs/Groovy8947.groovy
index d7f8c6c..f11e565 100644
--- a/src/test/groovy/bugs/Groovy8947.groovy
+++ b/src/test/groovy/bugs/Groovy8947.groovy
@@ -45,6 +45,11 @@ final class Groovy8947 {
assert 4 == new Computer().new Cpu(4).coreNumber
assert 4 == Computer.newCpuInstance(4).coreNumber
assert 0 == new HashSet(new ArrayList()).size()
+
+ def coreNumber = new Computer().new Cpu(4).coreNumber
+ assert 4 == coreNumber
+ def cpu = new Computer().new Cpu(4)
+ assert 4 == cpu.coreNumber
'''
}