Closed
Description
When resolving the TypeInformation
for properties via TypeInformation.getProperty
the actual type parameter might be lost and be replaced by java.lang.Object
if the property is declared in a super type.
Related issue: spring-projects/spring-data-mongodb#3567
class SomeGeneric<T> {
T value;
}
class GenericExtendingSomeGeneric<T> extends SomeGeneric<T> { }
class Wrapper {
GenericExtendingSomeGeneric<Leaf> field;
}
@Test
void typeInfoShouldPreserveGenericParameter() {
TypeInformation<Wrapper> wrapperTypeInfo = from(Wrapper.class);
TypeInformation<?> fieldTypeInfo = wrapperTypeInfo.getProperty("field");
TypeInformation<?> valueTypeInfo = fieldTypeInfo.getProperty("value");
assertThat(valueTypeInfo.getType()).isEqualTo(Leaf.class);
}