From df00aafdff80d1c8f30460d87437db7d520f4a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Wed, 29 Nov 2023 14:49:25 +0100 Subject: [PATCH] Add a nested generics test for GenericTypeResolver Closes gh-31690 --- .../core/GenericTypeResolverTests.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 2c049da8479a..403c11e7ffec 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-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -194,6 +194,15 @@ public void resolveTransitiveTypeVariableWithDifferentName() { assertThat(resolved).isEqualTo(E.class); } + @Test + public void resolveMethodParameterWithNestedGenerics() { + Method method = method(WithMethodParameter.class, "nestedGenerics", List.class); + MethodParameter methodParameter = new MethodParameter(method, 0); + Type resolvedType = resolveType(methodParameter.getGenericParameterType(), WithMethodParameter.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(); @@ -388,5 +397,10 @@ static class FirstSecondService implements First, Second { static class SecondFirstService implements Second, First { } + static class WithMethodParameter { + public void nestedGenerics(List> input) { + } + } + }