Skip to content

Commit 0b1df59

Browse files
Treiblesschorlectrueden
authored andcommitted
Use the bound of the TypeVariable as search class
Instead of using the TypeVariable itself, we need to use the resolved bound of it. The TypeVariable itself may not be unbounded, but we may already have found bounds for it. Moreover, if arg or its direct supertypes are not parameterized (Types.param() will return null) we can return false here.
1 parent 3095daf commit 0b1df59

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,12 @@ private static boolean satisfiesTypeVariable(final Type arg,
944944
final ParameterizedType paramBoundType = (ParameterizedType) paramBound;
945945
final Type[] paramBoundTypes = paramBoundType.getActualTypeArguments();
946946
for (int i = 0; i < paramBoundTypes.length; i++) {
947-
final Type argType = Types.param(arg, Types.raw(param), i);
947+
// Get the type parameter of arg from the bound type which we know
948+
// is parameterized.
949+
final Type argType = Types.param(arg, Types.raw(paramBoundType), i);
950+
if (argType == null) {
951+
return false;
952+
}
948953
if (paramBoundTypes[i] instanceof TypeVariable<?> &&
949954
!satisfiesTypeParameter(argType,
950955
(TypeVariable<?>) paramBoundTypes[i], typeBounds)) return false;

0 commit comments

Comments
 (0)