Skip to content

Commit 4765993

Browse files
Treiblesschorlegselzer
authored andcommitted
WIP: get correct type arguments if src is not parameterized itself
1 parent 7832d75 commit 4765993

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎src/main/java/org/scijava/util/Types.java‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,16 @@ private static boolean satisfiesParameterizedTypes(final Type arg,
856856
final Type[] destTypes = param.getActualTypeArguments();
857857

858858
// get an array of the source argument types
859-
final Type[] srcTypes = new Type[destTypes.length];
860-
for (int i = 0; i < srcTypes.length; i++) {
861-
srcTypes[i] = Types.param(arg, Types.raw(arg), i);
862-
}
859+
// TODO: Verify that this is correct. getExactSuperType should always return a ParameterizedType here because
860+
// param is parameterized and we know (check done earlier) that arg is assignable to param. Hence, arg must have
861+
// type parameters for param?
862+
ParameterizedType parameterizedSuperType = (ParameterizedType) GenericTypeReflector
863+
.getExactSuperType(arg, Types.raw(param));
864+
final Type[] srcTypes = parameterizedSuperType.getActualTypeArguments();
865+
// final Type[] srcTypes = new Type[destTypes.length];
866+
// for (int i = 0; i < srcTypes.length; i++) {
867+
// srcTypes[i] = Types.param(arg, Types.raw(arg), i);
868+
// }
863869

864870
// check to see if any of the Types of this ParameterizedType are
865871
// TypeVariables, if so restrict them to the type parameter of the argument.

0 commit comments

Comments
 (0)