This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new f6b3f90  Trivial tweak: validate modifiers of compact constructor
f6b3f90 is described below

commit f6b3f90771370bed918794907b74486d1f14a283
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Oct 16 22:20:16 2021 +0800

    Trivial tweak: validate modifiers of compact constructor
---
 .../apache/groovy/parser/antlr4/AstBuilder.java    |  3 +++
 .../fail/RecordDeclaration_13x.groovy              | 24 ++++++++++++++++++++++
 .../groovy/parser/antlr4/SyntaxErrorTest.groovy    |  1 +
 3 files changed, 28 insertions(+)

diff --git a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java 
b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 326d3cf..6679cf5 100644
--- a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -2000,6 +2000,9 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> {
         MethodNode methodNode = 
classNode.addSyntheticMethod(RECORD_COMPACT_CONSTRUCTOR_NAME, 
Opcodes.ACC_PRIVATE,
                                                                 returnType, 
parameters, ClassNode.EMPTY_ARRAY, block);
 
+        ConstructorNode dummyConstructorNode = configureAST(new 
ConstructorNode(modifierManager.getClassMemberModifiersOpValue(), block), ctx);
+        modifierManager.validate(dummyConstructorNode);
+
         modifierManager.attachAnnotations(methodNode);
         attachMapConstructorAnnotationToRecord(classNode, parameters);
         attachTupleConstructorAnnotationToRecord(classNode, parameters);
diff --git a/src/test-resources/fail/RecordDeclaration_13x.groovy 
b/src/test-resources/fail/RecordDeclaration_13x.groovy
new file mode 100644
index 0000000..cbdb10d
--- /dev/null
+++ b/src/test-resources/fail/RecordDeclaration_13x.groovy
@@ -0,0 +1,24 @@
+/*
+ *  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.
+ */
+package core
+
+record Point(int x, int y, String color) {
+    final Point {
+    }
+}
diff --git a/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy 
b/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
index bfac665..cdeb278 100644
--- a/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
+++ b/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
@@ -445,6 +445,7 @@ final class SyntaxErrorTest extends GroovyTestCase {
         TestUtils.doRunAndShouldFail('fail/RecordDeclaration_10x.groovy')
         TestUtils.doRunAndShouldFail('fail/RecordDeclaration_11x.groovy')
         TestUtils.doRunAndShouldFail('fail/RecordDeclaration_12x.groovy')
+        TestUtils.doRunAndShouldFail('fail/RecordDeclaration_13x.groovy')
     }
 
     void 'test groovy core - Array'() {

Reply via email to