DATACMNS-1138 - TypeInformation.specialize(…) now only specializes unresolved parameterized types.
Type specialization - i.e. enrichment of a raw type with a current generic context - is now only done if the current type is not yet resolved completely. This allows wildcarded target references to just fall back to the type to specialize, which will then by definition carry more generics information than the one to be specialized.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.util.ClassTypeInformation.*;
|
||||
import static org.springframework.data.util.ClassTypeInformation.from;
|
||||
|
||||
import javaslang.collection.Traversable;
|
||||
|
||||
@@ -399,6 +399,17 @@ public class ClassTypeInformationUnitTests {
|
||||
assertThat(information.getMapValueType().getType()).isAssignableFrom(Integer.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1138
|
||||
public void usesTargetTypeForWildcardedBaseOnSpecialization() {
|
||||
|
||||
ClassTypeInformation<WildcardedWrapper> wrapper = ClassTypeInformation.from(WildcardedWrapper.class);
|
||||
ClassTypeInformation<SomeConcrete> concrete = ClassTypeInformation.from(SomeConcrete.class);
|
||||
|
||||
TypeInformation<?> property = wrapper.getRequiredProperty("wildcarded");
|
||||
|
||||
assertThat(property.specialize(concrete)).isEqualTo(concrete);
|
||||
}
|
||||
|
||||
static class StringMapContainer extends MapContainer<String> {
|
||||
|
||||
}
|
||||
@@ -601,4 +612,16 @@ public class ClassTypeInformationUnitTests {
|
||||
static interface SampleTraversable extends Traversable<Integer> {}
|
||||
|
||||
static interface SampleMap extends javaslang.collection.Map<String, Integer> {}
|
||||
|
||||
// DATACMNS-1138
|
||||
|
||||
static class SomeGeneric<T> {
|
||||
T value;
|
||||
}
|
||||
|
||||
static class SomeConcrete extends SomeGeneric<String> {}
|
||||
|
||||
static class WildcardedWrapper {
|
||||
SomeGeneric<?> wildcarded;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user