Merge branch '6.2.x'

This commit is contained in:
Juergen Hoeller 2025-03-06 15:45:18 +01:00
commit 2a98b3137d
2 changed files with 24 additions and 4 deletions

View File

@ -334,7 +334,7 @@ public class ResolvableType implements Serializable {
return otherBounds.isAssignableFrom(this, matchedBefore);
}
else if (!strict) {
return (matchedBefore != null ? otherBounds.equalsType(this) :
return (matchedBefore != null ? otherBounds.equalsType(this, matchedBefore) :
otherBounds.isAssignableTo(this, matchedBefore));
}
else {
@ -1775,11 +1775,13 @@ public class ResolvableType implements Serializable {
* Return {@code true} if these bounds are equal to the specified type.
* @param type the type to test against
* @return {@code true} if these bounds are equal to the type
* @since 6.2.3
* @since 6.2.4
*/
public boolean equalsType(ResolvableType type) {
public boolean equalsType(ResolvableType type, @Nullable Map<Type, Type> matchedBefore) {
for (ResolvableType bound : this.bounds) {
if (!type.equalsType(bound)) {
if (this.kind == Kind.UPPER && bound.hasUnresolvableGenerics() ?
!type.isAssignableFrom(bound, true, matchedBefore, false) :
!type.equalsType(bound)) {
return false;
}
}

View File

@ -1527,6 +1527,12 @@ class ResolvableTypeTests {
assertThat(repository3.isAssignableFromResolvedPart(repository2)).isTrue();
}
@Test
void gh34541() throws Exception {
ResolvableType typeWithGenerics = ResolvableType.forField(getClass().getDeclaredField("paymentCreator"));
assertThat(typeWithGenerics.isAssignableFrom(PaymentCreator.class)).isTrue();
}
private ResolvableType testSerialization(ResolvableType type) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@ -1928,6 +1934,18 @@ class ResolvableTypeTests {
}
PaymentCreator<? extends Payment, PaymentCreatorParameter<? extends Payment>> paymentCreator;
static class PaymentCreator<T extends Payment, P extends PaymentCreatorParameter<T>> {
}
static class PaymentCreatorParameter<T extends Payment> {
}
abstract static class Payment {
}
private static class ResolvableTypeAssert extends AbstractAssert<ResolvableTypeAssert, ResolvableType>{
public ResolvableTypeAssert(ResolvableType actual) {