Skip to content

Commit b26ce65

Browse files
committed
Improve any checking in parameterizedTypes
Now, a Function<Function<I, O>, Function<Iterable<I>, Iterable<O>>> can be matched to a Function<Any, Function<Iterable<Double>, Iterable<Double>>>
1 parent 42c5a98 commit b26ce65

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,8 +2238,17 @@ private static boolean isAssignable(final Type type,
22382238
// parameters of the target type.
22392239
if (fromResolved != null && !fromResolved.equals(toResolved) && !(toResolved instanceof WildcardType
22402240
&& isAssignable(fromResolved, toResolved, typeVarAssigns))) {
2241+
// check for anys
22412242
if (fromResolved instanceof Any || toResolved instanceof Any)
22422243
continue;
2244+
if (fromResolved instanceof ParameterizedType && Types.raw(fromResolved) == Types.raw(toResolved)) {
2245+
Type[] fromTypes = ((ParameterizedType) fromResolved).getActualTypeArguments();
2246+
Type[] toTypes = ((ParameterizedType) toResolved).getActualTypeArguments();
2247+
for(int i = 0; i < fromTypes.length; i++) {
2248+
if(!(fromTypes[i] instanceof Any || toTypes[i] instanceof Any)) return false;
2249+
}
2250+
continue;
2251+
}
22432252
return false;
22442253
}
22452254
}

0 commit comments

Comments
 (0)