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 2022/04/19 17:27:00 UTC

[groovy] 01/01: GROOVY-10587: resolve annotations from module before nested

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

emilles pushed a commit to branch GROOVY-10587
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 0576fb007f0ac3ad9137738ac4db8b445f5cdb44
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Apr 19 12:17:07 2022 -0500

    GROOVY-10587: resolve annotations from module before nested
---
 .../codehaus/groovy/control/ResolveVisitor.java    |  2 +-
 src/test/groovy/bugs/Groovy10587.groovy            | 48 ++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
index d001b3f9dc..20a46b5a15 100644
--- a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
@@ -1227,7 +1227,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
 
     @Override
     protected void visitAnnotation(final AnnotationNode node) {
-        resolveOrFail(node.getClassNode(), " for annotation", node);
+        resolveOrFail(node.getClassNode(), " for annotation", node, true);
 
         for (Map.Entry<String, Expression> member : node.getMembers().entrySet()) {
             Expression value = transformInlineConstants(transform(member.getValue()));
diff --git a/src/test/groovy/bugs/Groovy10587.groovy b/src/test/groovy/bugs/Groovy10587.groovy
new file mode 100644
index 0000000000..6e7867b554
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy10587.groovy
@@ -0,0 +1,48 @@
+/*
+ *  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 groovy.bugs
+
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy10587 {
+
+    public @interface Client {
+    }
+
+    @Test
+    void testImportVsInnerClass() {
+        assertScript """
+            import ${this.class.name}.Client
+
+            class C {
+                interface I {
+                    interface Client extends I {
+                    }
+                }
+                @Client
+                interface J extends I.Client {
+                }
+            }
+
+            def tags = C.J.annotations
+        """
+    }
+}