Skip to content

Commit ad05c7a

Browse files
committed
Add regression test for type variable collision across interfaces
1 parent 0b5a9ea commit ad05c7a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ void resolveTypeFromGenericDefaultMethod() {
250250
assertThat(resolvedType).isEqualTo(InheritsDefaultMethod.ConcreteType.class);
251251
}
252252

253+
@Test
254+
void resolveTypeVariableCollisionAcrossInterfaces() throws Exception {
255+
Type createBody = Create.class.getMethod("create", Object.class)
256+
.getGenericParameterTypes()[0];
257+
258+
Type resolved = resolveType(createBody, Controller.class);
259+
260+
assertThat(resolved).isEqualTo(Long.class);
261+
}
262+
253263
private static Method method(Class<?> target, String methodName, Class<?>... parameterTypes) {
254264
Method method = findMethod(target, methodName, parameterTypes);
255265
assertThat(method).describedAs(target.getName() + "#" + methodName).isNotNull();
@@ -477,4 +487,17 @@ static class ConcreteType implements InterfaceWithDefaultMethod.AbstractType {
477487
}
478488
}
479489

490+
interface Search<I, O> {
491+
}
492+
493+
interface Create<I, O> {
494+
495+
default O create(I body) {
496+
return null;
497+
}
498+
}
499+
500+
static class Controller implements Search<String, Long>, Create<Long, Long> {
501+
}
502+
480503
}

0 commit comments

Comments
 (0)