Skip to content

Commit 9005a69

Browse files
gselzerctrueden
authored andcommitted
Allow lift transformations to lift subclasses
1 parent 7123ec2 commit 9005a69

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/main/java/org/scijava/ops/transform/TypeModUtils.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,20 @@ public static Type unliftType(Type type, Class<?> unliftRawType) {
172172
return Types.component(type);
173173
} else if (type instanceof ParameterizedType) {
174174
ParameterizedType casted = (ParameterizedType) type;
175-
176-
if (Types.raw(casted).equals(unliftRawType)) {
177-
Type[] typeArgs = casted.getActualTypeArguments();
175+
// determine the type parameter of type with respect to unliftRawType
176+
Type inheritedType = Types.getExactSuperType(casted, unliftRawType);
177+
if (!(inheritedType instanceof ParameterizedType))
178+
return null;
179+
ParameterizedType pInheritedType = (ParameterizedType) inheritedType;
180+
// TODO: this cast should now be unnecessary?
181+
// if (Types.raw(casted).equals(unliftRawType)) {
182+
Type[] typeArgs = pInheritedType.getActualTypeArguments();
178183
if (typeArgs.length == 1) {
179184
return typeArgs[0];
180185
}
181-
}
186+
// }
182187
}
188+
if (type instanceof Any) return type;
183189
return null;
184190
}
185191

0 commit comments

Comments
 (0)