Restrict lenient nested matching to immediate type variable
Includes fix for matching multiple wildcard bounds properly. Closes gh-34119 Closes gh-34234
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -410,8 +410,9 @@ public class ResolvableType implements Serializable {
|
||||
}
|
||||
matchedBefore.put(this.type, other.type);
|
||||
for (int i = 0; i < ourGenerics.length; i++) {
|
||||
if (!ourGenerics[i].isAssignableFrom(otherGenerics[i],
|
||||
!other.hasUnresolvableGenerics(), matchedBefore, upUntilUnresolvable)) {
|
||||
ResolvableType otherGeneric = otherGenerics[i];
|
||||
if (!ourGenerics[i].isAssignableFrom(otherGeneric,
|
||||
!otherGeneric.isUnresolvableTypeVariable(), matchedBefore, upUntilUnresolvable)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1729,8 +1730,16 @@ public class ResolvableType implements Serializable {
|
||||
* @return {@code true} if these bounds are assignable from all types
|
||||
*/
|
||||
public boolean isAssignableFrom(ResolvableType[] types, @Nullable Map<Type, Type> matchedBefore) {
|
||||
for (ResolvableType type : types) {
|
||||
if (!isAssignableFrom(type, matchedBefore)) {
|
||||
for (ResolvableType bound : this.bounds) {
|
||||
boolean matched = false;
|
||||
for (ResolvableType type : types) {
|
||||
if (this.kind == Kind.UPPER ? bound.isAssignableFrom(type, false, matchedBefore, false) :
|
||||
type.isAssignableFrom(bound, false, matchedBefore, false)) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user