Resolve bounds for type variable before emptiness check

Closes gh-34328
This commit is contained in:
Juergen Hoeller
2025-01-30 15:35:14 +01:00
parent 4c3b435d23
commit ed994dcd97
3 changed files with 48 additions and 22 deletions

View File

@@ -180,7 +180,7 @@ public final class GenericTypeResolver {
generics[i] = resolvedTypeArgument;
}
else {
generics[i] = ResolvableType.forType(typeArgument).resolveType();
generics[i] = ResolvableType.forType(typeArgument);
}
}
else if (typeArgument instanceof ParameterizedType) {
@@ -226,7 +226,7 @@ public final class GenericTypeResolver {
return resolvedType;
}
}
return ResolvableType.NONE;
return ResolvableType.forVariableBounds(typeVariable);
}
/**

View File

@@ -953,14 +953,6 @@ public class ResolvableType implements Serializable {
return NONE;
}
@Nullable
private Type resolveBounds(Type[] bounds) {
if (bounds.length == 0 || bounds[0] == Object.class) {
return null;
}
return bounds[0];
}
@Nullable
private ResolvableType resolveVariable(TypeVariable<?> variable) {
if (this.type instanceof TypeVariable) {
@@ -1463,6 +1455,24 @@ public class ResolvableType implements Serializable {
return new ResolvableType(arrayType, componentType, null, null);
}
/**
* Return a {@code ResolvableType} for the bounds of the specified {@link TypeVariable}.
* @param typeVariable the type variable
* @return a {@code ResolvableType} for the specified bounds
* @since 6.2.3
*/
static ResolvableType forVariableBounds(TypeVariable<?> typeVariable) {
return forType(resolveBounds(typeVariable.getBounds()));
}
@Nullable
private static Type resolveBounds(Type[] bounds) {
if (bounds.length == 0 || bounds[0] == Object.class) {
return null;
}
return bounds[0];
}
/**
* Return a {@code ResolvableType} for the specified {@link Type}.
* <p>Note: The resulting {@code ResolvableType} instance may not be {@link Serializable}.
@@ -1491,7 +1501,6 @@ public class ResolvableType implements Serializable {
return forType(type, variableResolver);
}
/**
* Return a {@code ResolvableType} for the specified {@link ParameterizedTypeReference}.
* <p>Note: The resulting {@code ResolvableType} instance may not be {@link Serializable}.