From 043c3f31faf18a27e442d463d879b39db1eda0c7 Mon Sep 17 00:00:00 2001 From: pavanB247 <135733563+pavanB247@users.noreply.github.com> Date: Thu, 11 Jun 2026 12:34:06 +0530 Subject: [PATCH] Add regression test for type variable collision across interfaces Signed-off-by: pavanB247 <135733563+pavanB247@users.noreply.github.com> --- .../core/GenericTypeResolverTests.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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 { + } + }