Shadow-Devil commented on code in PR #1824:
URL: https://github.com/apache/groovy/pull/1824#discussion_r1020417769


##########
src/main/java/org/codehaus/groovy/ast/tools/GenericsUtils.java:
##########
@@ -855,10 +855,16 @@ private static Map<GenericsType, GenericsType> 
doMakeDeclaringAndActualGenericsT
             GenericsType[] targetGenericsTypes = 
parameterizedType.redirect().getGenericsTypes();
             if (targetGenericsTypes != null) {
                 GenericsType[] sourceGenericsTypes = 
parameterizedType.getGenericsTypes();
-                if (sourceGenericsTypes == null) sourceGenericsTypes = 
EMPTY_GENERICS_ARRAY;
                 map = new LinkedHashMap<>();
-                for (int i = 0, m = sourceGenericsTypes.length, n = 
targetGenericsTypes.length; i < n; i += 1) {
-                    map.put(targetGenericsTypes[i], i < m ? 
sourceGenericsTypes[i] : targetGenericsTypes[i]);
+                if (sourceGenericsTypes == null) {
+                    //We have no sourceGenerics, so we need to return the 
erasures for the raw types (Groovy-10813)
+                    for (GenericsType targetGenericsType : 
targetGenericsTypes) {
+                        map.put(targetGenericsType, 
ClassHelper.OBJECT_TYPE.asGenericsType());

Review Comment:
   I've played around with generics in java, but couldn't find an example where 
the erasure isn't of type Object.
   I've also tried something like this:
   ```java
   import java.util.function.*
   interface T<E> extends Function<String, E>{}
   class TT implements T{
     @Override
     Object apply(Object o) {
       return null
     }
   }
   ```
   and it still loses all type information. Maybe I'm just not advanced enough 
into generics and how they work. Could you perhaps help me here or give me a 
resource where to learn more about this? I've found some information about the 
topic 
[here](https://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html) and 
[here](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html)



-- 
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: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to