diff --git a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java index e849a594ea9..aa72d9bc07f 100644 --- a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java +++ b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -177,7 +177,7 @@ public final class GenericTypeResolver { generics[i] = resolvedTypeArgument; } else { - generics[i] = ResolvableType.forType(typeArgument); + generics[i] = ResolvableType.forType(typeArgument).resolveType(); } } else if (typeArgument instanceof ParameterizedType) { 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 6338bedea81..1f80cc6c343 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -211,6 +211,14 @@ class GenericTypeResolverTests { assertThat(ResolvableType.forType(resolved).getGeneric(0).getGeneric(0).resolve()).isEqualTo(String.class); } + @Test + void resolvedTypeWithBase() { + Type type = method(WithBaseTypes.class, "get").getGenericReturnType(); + Type resolvedType = resolveType(type, WithBaseTypes.class); + ParameterizedTypeReference> reference = new ParameterizedTypeReference<>() {}; + assertThat(resolvedType).isEqualTo(reference.getType()); + } + private static Method method(Class target, String methodName, Class... parameterTypes) { Method method = findMethod(target, methodName, parameterTypes); assertThat(method).describedAs(target.getName() + "#" + methodName).isNotNull(); @@ -398,4 +406,12 @@ class GenericTypeResolverTests { public interface StringListOfListSupplier extends ListOfListSupplier { } + static class WithBaseTypes { + + List get() { + return List.of(); + } + + } + }