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 04:02:40 UTC

[groovy] branch master 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 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 631a182  GROOVY-10181: Groovy 3 AST for annotated fields reports wrong lastLineNumber if field not initialized
631a182 is described below

commit 631a1827b878257a7ae2f683577c96d2df21dffe
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 +-
 src/test-resources/bugs/BUG-GROOVY-10181.groovy    | 26 ++++++++++++++++++++++
 .../groovy/parser/antlr4/GroovyParserTest.groovy   |  4 ++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java b/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java
index 35e9967..ded5a59 100644
--- a/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java
+++ b/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java
@@ -100,7 +100,7 @@ public class PositionConfigureUtils {
             astNode.setLastLineNumber(initialStop.getLastLineNumber());
             astNode.setLastColumnNumber(initialStop.getLastColumnNumber());
         } else {
-            configureEndPosition(astNode, stop);
+            configureEndPosition(astNode, ctx.getStop());
         }
 
         return astNode;
diff --git a/src/test-resources/bugs/BUG-GROOVY-10181.groovy b/src/test-resources/bugs/BUG-GROOVY-10181.groovy
new file mode 100644
index 0000000..0d13501
--- /dev/null
+++ b/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
+}
diff --git a/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index 10c2af0..b6d87a7 100644
--- a/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -500,4 +500,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');
+    }
 }