Skip to content

Commit cc44052

Browse files
Treiblesschorlectrueden
authored andcommitted
Add generic assignability test for types that contain type vars in the destination and source
1 parent 00687ad commit cc44052

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ private void assertAll(Class<?> from, boolean condition, Type... tos) {
6161
}
6262
}
6363
}
64+
65+
@Test
66+
public <E, N extends Number> void genericAssignabilityVarToVar() {
67+
abstract class Single<I> implements Supplier<I> {
68+
}
69+
abstract class SingleBounded<I extends Number> implements Supplier<I> {
70+
}
71+
Nil<Supplier<E>> y1 = new Nil<Supplier<E>>() {
72+
};
73+
Nil<Supplier<N>> y2 = new Nil<Supplier<N>>() {
74+
};
75+
Nil<Double> n1 = new Nil<Double>() {
76+
};
77+
78+
assertAll(Single.class, true, y1, y2);
79+
assertAll(Single.class, false, n1);
80+
81+
assertAll(SingleBounded.class, true, y2);
82+
assertAll(SingleBounded.class, false, y1, n1);
83+
}
6484

6585
@Test
6686
public void genericAssignabilitySingleVar() {

0 commit comments

Comments
 (0)