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 2020/02/15 15:47:48 UTC
[groovy] 01/01: GROOVY-9399: Annotations on annotation methods are
missing in the AST
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY-9399
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 3d8515cd77e307aef7863cef7d5ac92edf1fc4e0
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Feb 15 23:47:20 2020 +0800
GROOVY-9399: Annotations on annotation methods are missing in the AST
---
src/antlr/GroovyParser.g4 | 14 +++++++-----
.../groovy/parser/antlr4/GroovyParserTest.groovy | 1 +
.../src/test/resources/bugs/BUG-GROOVY-9399.groovy | 26 ++++++++++++++++++++++
3 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index d77c581..65655ff 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -291,12 +291,14 @@ memberDeclaration[int t]
* ct 9: script, other see the comment of classDeclaration
*/
methodDeclaration[int t, int ct]
- : { 3 == $ct }?
- returnType[$ct] methodName LPAREN rparen (DEFAULT nls elementValue)?
- |
- modifiersOpt typeParameters? returnType[$ct]?
- methodName formalParameters (nls THROWS nls qualifiedClassNameList)?
- (nls methodBody)?
+ : modifiersOpt
+ ( { 3 == $ct }?
+ returnType[$ct] methodName LPAREN rparen (DEFAULT nls elementValue)?
+ |
+ typeParameters? returnType[$ct]?
+ methodName formalParameters (nls THROWS nls qualifiedClassNameList)?
+ (nls methodBody)?
+ )
;
methodName
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 132b02a..2c7d435 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
@@ -436,5 +436,6 @@ final class GroovyParserTest extends GroovyTestCase {
doTest('bugs/BUG-GROOVY-8641.groovy')
doTest('bugs/BUG-GROOVY-8913.groovy')
doRunAndTestAntlr4('bugs/BUG-GROOVY-8991.groovy')
+ doTest('bugs/BUG-GROOVY-9399.groovy')
}
}
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-9399.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-9399.groovy
new file mode 100644
index 0000000..c3aadec
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-9399.groovy
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+@interface Bar {
+ @Foo
+ String value()
+
+ @Foo
+ String foo() default 'abc'
+}