Consider nested generics in TypeDiscoverer equality comparison.
We now compare nested generics wrapped into TypeInformation to consider type equality for deeply parametrized types. Previously, we resolved type parameters to Class so Foo<List<String>> was considered equal to Foo<List<Map>> as the type parameter of the first nesting level was erased. Closes #3051
This commit is contained in:
@@ -60,7 +60,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
private final Map<Constructor<?>, List<TypeInformation<?>>> constructorParameters = new ConcurrentHashMap<>();
|
||||
private final Lazy<List<TypeInformation<?>>> typeArguments;
|
||||
|
||||
private final Lazy<List<Class>> resolvedGenerics;
|
||||
private final Lazy<List<TypeInformation<?>>> resolvedGenerics;
|
||||
|
||||
protected TypeDiscoverer(ResolvableType type) {
|
||||
|
||||
@@ -71,7 +71,9 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
this.valueType = Lazy.of(this::doGetMapValueType);
|
||||
this.typeArguments = Lazy.of(this::doGetTypeArguments);
|
||||
this.resolvedGenerics = Lazy.of(() -> Arrays.stream(resolvableType.getGenerics()) //
|
||||
.map(ResolvableType::toClass).collect(Collectors.toList()));
|
||||
.map(TypeInformation::of) // use TypeInformation comparison to remove any attachments to variableResolver
|
||||
// holding the type source
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
static TypeDiscoverer<?> td(ResolvableType type) {
|
||||
|
||||
Reference in New Issue
Block a user