blackdrag commented on code in PR #3259:
URL: https://github.com/apache/groovy/pull/3259#discussion_r4554525694


##########
src/main/java/org/codehaus/groovy/control/ResolveVisitor.java:
##########
@@ -582,9 +590,41 @@ protected boolean resolve(final ClassNode type, final 
boolean testModuleImports,
         if (resolved && genericsTypes != null) {
             resolveWildcardBounding(genericsTypes, type);
         }
+        if (resolved) {
+            normalizeUseSite(type);
+        }
         return resolved;
     }
 
+    /**
+     * Drops type arguments a class does not declare and boxes a primitive
+     * argument or wildcard bound. A use site is a redirect; the declaration
+     * itself is left alone. An unresolved name is not a redirect yet, so this
+     * runs again once {@link #resolve} has found the class.
+     */
+    private static void normalizeUseSite(final ClassNode type) {
+        if (type == null || type.isGenericsPlaceHolder() || 
!type.isRedirectNode()) {
+            return;
+        }
+        GenericsType[] arguments = type.getGenericsTypes();
+        if (arguments == null || arguments.length == 0) {
+            return;
+        }
+        GenericsType[] legal = GenericsUtils.legalTypeArguments(type, 
arguments);
+        if (legal == arguments) {
+            return;
+        }
+        if (legal == null || legal.length == 0) {
+            type.setGenericsTypes(null);
+            ClassNode outer = type.getOuterClassType();

Review Comment:
   what happens for `String<Integer>`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to