Skip to content

Commit 827395e

Browse files
gselzerctrueden
authored andcommitted
TypeVariables can be satisfied using typeVarAssigns
This change broke a test in MatchingUtils because it was calling Types.isAssignable without passing in a HashMap. This solution might not be the best one but the fix does ensure that we get the expected behavior from the test
1 parent 718bacb commit 827395e

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,6 +2237,11 @@ private static boolean isAssignable(final Type type,
22372237
if (toTypeVariable.equals(type)) {
22382238
return true;
22392239
}
2240+
2241+
// if toTypeVariable is assigned to type in typeVarAssigns, then it is assignable
2242+
if (typeVarAssigns.get(toTypeVariable) == type) {
2243+
return true;
2244+
}
22402245

22412246
if (type instanceof TypeVariable) {
22422247
// a type variable is assignable to another type variable, if

src/test/java/org/scijava/ops/util/MatchingUtilsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import java.lang.reflect.ParameterizedType;
3535
import java.lang.reflect.Type;
36+
import java.lang.reflect.TypeVariable;
3637
import java.util.HashMap;
3738
import java.util.List;
3839
import java.util.function.BiFunction;
@@ -57,7 +58,7 @@ private void assertAll(Class<?> from, boolean condition, Type... tos) {
5758
if (to instanceof ParameterizedType) {
5859
assertTrue(MatchingUtils.checkGenericAssignability(from, (ParameterizedType) to, false) == condition);
5960
} else {
60-
assertTrue(Types.isAssignable(from, to) == condition);
61+
assertTrue(Types.isAssignable(from, to, new HashMap<TypeVariable<?>, Type>()) == condition);
6162
}
6263
}
6364
}

0 commit comments

Comments
 (0)