diff --git a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java index 705cb59d0014..baa53144176e 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -250,6 +250,16 @@ void resolveTypeFromGenericDefaultMethod() { assertThat(resolvedType).isEqualTo(InheritsDefaultMethod.ConcreteType.class); } + @Test + void resolveTypeVariableCollisionAcrossInterfaces() throws Exception { + Type createBody = Create.class.getMethod("create", Object.class) + .getGenericParameterTypes()[0]; + + Type resolved = resolveType(createBody, Controller.class); + + assertThat(resolved).isEqualTo(Long.class); + } + private static Method method(Class target, String methodName, Class... parameterTypes) { Method method = findMethod(target, methodName, parameterTypes); assertThat(method).describedAs(target.getName() + "#" + methodName).isNotNull(); @@ -477,4 +487,17 @@ static class ConcreteType implements InterfaceWithDefaultMethod.AbstractType { } } + interface Search { + } + + interface Create { + + default O create(I body) { + return null; + } + } + + static class Controller implements Search, Create { + } + }