Consider wildcard type without bounds as eligible for fallback match too

Issue: SPR-11250
This commit is contained in:
Juergen Hoeller
2014-01-21 01:26:30 +01:00
parent 96d6963d61
commit 709ac28f29
2 changed files with 123 additions and 4 deletions

View File

@@ -399,7 +399,7 @@ public final class ResolvableType implements Serializable {
}
ResolvableType[] generics = getGenerics();
for (ResolvableType generic : generics) {
if (generic.isUnresolvableTypeVariable()) {
if (generic.isUnresolvableTypeVariable() || generic.isWildcardWithoutBounds()) {
return true;
}
}
@@ -435,6 +435,23 @@ public final class ResolvableType implements Serializable {
return false;
}
/**
* Determine whether the underlying type represents a wildcard
* without specific bounds (i.e., equal to {@code ? extends Object}).
*/
private boolean isWildcardWithoutBounds() {
if (this.type instanceof WildcardType) {
WildcardType wt = (WildcardType) this.type;
if (wt.getLowerBounds().length == 0) {
Type[] upperBounds = wt.getUpperBounds();
if (upperBounds.length == 0 || (upperBounds.length == 1 && Object.class.equals(upperBounds[0]))) {
return true;
}
}
}
return false;
}
/**
* Return a {@link ResolvableType} for the specified nesting level. See
* {@link #getNested(int, Map)} for details.