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/07/26 03:30:36 UTC
[groovy] branch GROOVY_3_0_X updated: GROOVY-10181: Groovy 3 AST
for annotated fields reports wrong lastLineNumber if field not initialized
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 5c0c19b GROOVY-10181: Groovy 3 AST for annotated fields reports wrong lastLineNumber if field not initialized
5c0c19b is described below
commit 5c0c19b3304a8fbc09d570caa59e07cc04779400
Author: Daniel Sun <su...@apache.org>
AuthorDate: Mon Jul 26 11:30:11 2021 +0800
GROOVY-10181: Groovy 3 AST for annotated fields reports wrong lastLineNumber if field not initialized
---
.../parser/antlr4/util/PositionConfigureUtils.java | 2 +-
.../groovy/parser/antlr4/GroovyParserTest.groovy | 4 ++++
.../test/resources/bugs/BUG-GROOVY-10181.groovy | 26 ++++++++++++++++++++++
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java
index a009468..9b6bb71 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java
@@ -99,7 +99,7 @@ public class PositionConfigureUtils {
astNode.setLastLineNumber(stop.getLastLineNumber());
astNode.setLastColumnNumber(stop.getLastColumnNumber());
} else {
- configureEndPosition(astNode, start);
+ configureEndPosition(astNode, ctx.getStop());
}
return astNode;
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 874eca1..5137964 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
@@ -473,4 +473,8 @@ final class GroovyParserTest extends GroovyTestCase {
void "test groovy core - GROOVY-9692"() {
doTest('bugs/BUG-GROOVY-9692.groovy');
}
+
+ void "test groovy core - GROOVY-10181"() {
+ doTest('bugs/BUG-GROOVY-10181.groovy');
+ }
}
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-10181.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-10181.groovy
new file mode 100644
index 0000000..0d13501
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-10181.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.
+ */
+
+class Test {
+ @Deprecated
+ private int count1
+
+ @Deprecated
+ private int count2 = 99
+}