diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index f4b9a0ce58fd..a1c515a77b3a 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -655,7 +655,7 @@ private boolean isUnresolvableTypeVariable() { return true; } ResolvableType resolved = this.variableResolver.resolveVariable(variable); - if (resolved == null || resolved.isUnresolvableTypeVariable()) { + if (resolved == null || resolved.isUnresolvableTypeVariable() || resolved.isWildcardWithoutBounds()) { return true; } } diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index d27f207011e6..966793c564b5 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -1370,13 +1370,19 @@ void spr16456() throws Exception { @Test void gh32327() throws Exception { ResolvableType repository1 = ResolvableType.forField(Fields.class.getField("repository")); - ResolvableType repository2 = ResolvableType.forMethodReturnType(Methods.class.getMethod("repository")); - assertThat(repository1.hasUnresolvableGenerics()); + ResolvableType repository2 = ResolvableType.forMethodReturnType(Methods.class.getMethod("someRepository")); + ResolvableType repository3 = ResolvableType.forMethodReturnType(Methods.class.getMethod("subRepository")); + assertThat(repository1.hasUnresolvableGenerics()).isFalse(); assertThat(repository1.isAssignableFrom(repository2)).isFalse(); assertThat(repository1.isAssignableFromResolvedPart(repository2)).isTrue(); - assertThat(repository2.hasUnresolvableGenerics()); + assertThat(repository1.isAssignableFrom(repository3)).isFalse(); + assertThat(repository1.isAssignableFromResolvedPart(repository3)).isTrue(); + assertThat(repository2.hasUnresolvableGenerics()).isTrue(); assertThat(repository2.isAssignableFrom(repository1)).isTrue(); assertThat(repository2.isAssignableFromResolvedPart(repository1)).isTrue(); + assertThat(repository3.hasUnresolvableGenerics()).isTrue(); + assertThat(repository3.isAssignableFrom(repository1)).isFalse(); + assertThat(repository3.isAssignableFromResolvedPart(repository1)).isFalse(); } @@ -1424,6 +1430,9 @@ interface SomeRepository { T someMethod(Class arg0, Class arg1, Class arg2); } + interface SubRepository extends SomeRepository { + } + static class Fields { @@ -1501,7 +1510,9 @@ interface Methods { List list2(); - SomeRepository repository(); + SomeRepository someRepository(); + + SubRepository subRepository(); }