Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X edd97ea9c -> 6bd5ba14a
Minor refactoring (cherry picked from commit 8a8f0b9) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d498f4b3 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d498f4b3 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d498f4b3 Branch: refs/heads/GROOVY_2_6_X Commit: d498f4b31a94262b422b2912aa6242896ce4df33 Parents: edd97ea Author: sunlan <sun...@apache.org> Authored: Fri Sep 29 15:10:07 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 29 15:38:02 2017 +0800 ---------------------------------------------------------------------- src/antlr/GroovyParser.g4 | 6 +----- .../apache/groovy/parser/antlr4/AstBuilder.java | 4 ++++ .../groovy/parser/antlr4/SyntaxErrorTest.groovy | 4 ++++ .../test/resources/fail/MethodCall_01.groovy | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/d498f4b3/src/antlr/GroovyParser.g4 ---------------------------------------------------------------------- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 801e1e1..7dbef14 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -1177,11 +1177,7 @@ typeArgumentsOrDiamond ; arguments - : LPAREN - ( enhancedArgumentList? - | enhancedArgumentList COMMA - ) - rparen + : LPAREN enhancedArgumentList? COMMA? rparen ; argumentList http://git-wip-us.apache.org/repos/asf/groovy/blob/d498f4b3/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 c150dd1..4d7d968 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 @@ -2274,6 +2274,10 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov @Override public Expression visitArguments(ArgumentsContext ctx) { + if (asBoolean(ctx) && asBoolean(ctx.COMMA()) && !asBoolean(ctx.enhancedArgumentList())) { + throw createParsingFailedException("Expression expected", ctx); + } + if (!asBoolean(ctx) || !asBoolean(ctx.enhancedArgumentList())) { return new ArgumentListExpression(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/d498f4b3/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy ---------------------------------------------------------------------- diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy index f603e4b..66df9c9 100644 --- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy +++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy @@ -205,6 +205,10 @@ class SyntaxErrorTest extends GroovyTestCase { TestUtils.doRunAndShouldFail('fail/Number_05x.groovy'); } + void "test groovy core - MethodCall"() { + TestUtils.doRunAndShouldFail('fail/MethodCall_01.groovy'); + } + /**************************************/ static unzipScriptAndShouldFail(String entryName, List ignoreClazzList, Map<String, String> replacementsMap=[:], boolean toCheckNewParserOnly = false) { ignoreClazzList.addAll(TestUtils.COMMON_IGNORE_CLASS_LIST) http://git-wip-us.apache.org/repos/asf/groovy/blob/d498f4b3/subprojects/parser-antlr4/src/test/resources/fail/MethodCall_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/parser-antlr4/src/test/resources/fail/MethodCall_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/MethodCall_01.groovy new file mode 100644 index 0000000..cd73fd5 --- /dev/null +++ b/subprojects/parser-antlr4/src/test/resources/fail/MethodCall_01.groovy @@ -0,0 +1,20 @@ +/* + * 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. + */ + +m(,) \ No newline at end of file