You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2026/09/12 14:37:09 UTC

(groovy) branch master updated: propagate annotation source range

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

asf-gitbox-commits 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 b1ba4687d8 propagate annotation source range
b1ba4687d8 is described below

commit b1ba4687d8a25e98b6d72ce6632e9155e40450fb
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Sep 12 09:36:59 2026 -0500

    propagate annotation source range
---
 src/main/java/org/codehaus/groovy/ast/tools/GeneralUtils.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/tools/GeneralUtils.java b/src/main/java/org/codehaus/groovy/ast/tools/GeneralUtils.java
index 660154f450..e4fa743fb4 100644
--- a/src/main/java/org/codehaus/groovy/ast/tools/GeneralUtils.java
+++ b/src/main/java/org/codehaus/groovy/ast/tools/GeneralUtils.java
@@ -1876,15 +1876,14 @@ public class GeneralUtils {
             Expression valueExpression = retentionPolicyAnnotation.getMember("value");
             if (!(valueExpression instanceof PropertyExpression propertyExpression)) continue;
 
-            boolean processAnnotation = propertyExpression.getProperty() instanceof ConstantExpression
-                    && ("RUNTIME".equals(((ConstantExpression) (propertyExpression.getProperty())).getValue())
-                        || "CLASS".equals(((ConstantExpression) (propertyExpression.getProperty())).getValue()));
+            boolean processAnnotation = propertyExpression.getProperty() instanceof ConstantExpression property
+                    && ("RUNTIME".equals(property.getValue()) || "CLASS".equals(property.getValue()));
             if (processAnnotation)  {
                 AnnotationNode newAnnotation = new AnnotationNode(annotation.getClassNode());
                 for (Map.Entry<String, Expression> member : annotation.getMembers().entrySet())  {
                     newAnnotation.addMember(member.getKey(), member.getValue());
                 }
-                newAnnotation.setSourcePosition(annotatedNode);
+                newAnnotation.setSourcePosition(annotation);
 
                 copied.add(newAnnotation);
             }