Skip to content

Commit

Permalink
Detect wildcard without bounds returned from VariableResolver as well
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Feb 25, 2024
1 parent 4308240 commit 9198774
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down Expand Up @@ -1424,6 +1430,9 @@ interface SomeRepository<S extends Serializable> {
<T> T someMethod(Class<T> arg0, Class<?> arg1, Class<Object> arg2);
}

interface SubRepository<S extends Serializable> extends SomeRepository {
}


static class Fields<T> {

Expand Down Expand Up @@ -1501,7 +1510,9 @@ interface Methods<T> {

List<String> list2();

SomeRepository<?> repository();
SomeRepository<?> someRepository();

SubRepository<?> subRepository();
}


Expand Down

0 comments on commit 9198774

Please sign in to comment.