Repository: groovy Updated Branches: refs/heads/master 41bdb9416 -> 8a8f0b9da
Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8a8f0b9d Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8a8f0b9d Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8a8f0b9d Branch: refs/heads/master Commit: 8a8f0b9dadc92aa577370ee754f7e72dcc417570 Parents: 41bdb94 Author: sunlan <sun...@apache.org> Authored: Fri Sep 29 15:10:07 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 29 15:10:07 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/8a8f0b9d/src/antlr/GroovyParser.g4 ---------------------------------------------------------------------- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index d3990ac..f745130 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -1144,11 +1144,7 @@ typeArgumentsOrDiamond ; arguments - : LPAREN - ( enhancedArgumentList? - | enhancedArgumentList COMMA - ) - rparen + : LPAREN enhancedArgumentList? COMMA? rparen ; argumentList http://git-wip-us.apache.org/repos/asf/groovy/blob/8a8f0b9d/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 69e2fc9..931a8ae 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 @@ -2252,6 +2252,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/8a8f0b9d/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/8a8f0b9d/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