Skip to content

Commit df00aaf

Browse files
committed
Add a nested generics test for GenericTypeResolver
Closes gh-31690
1 parent 7cf124b commit df00aaf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -194,6 +194,15 @@ public void resolveTransitiveTypeVariableWithDifferentName() {
194194
assertThat(resolved).isEqualTo(E.class);
195195
}
196196

197+
@Test
198+
public void resolveMethodParameterWithNestedGenerics() {
199+
Method method = method(WithMethodParameter.class, "nestedGenerics", List.class);
200+
MethodParameter methodParameter = new MethodParameter(method, 0);
201+
Type resolvedType = resolveType(methodParameter.getGenericParameterType(), WithMethodParameter.class);
202+
ParameterizedTypeReference<List<Map<String, Integer>>> reference = new ParameterizedTypeReference<>() {};
203+
assertThat(resolvedType).isEqualTo(reference.getType());
204+
}
205+
197206
private static Method method(Class<?> target, String methodName, Class<?>... parameterTypes) {
198207
Method method = findMethod(target, methodName, parameterTypes);
199208
assertThat(method).describedAs(target.getName() + "#" + methodName).isNotNull();
@@ -388,5 +397,10 @@ static class FirstSecondService implements First<Integer>, Second<String> {
388397
static class SecondFirstService implements Second<String>, First<Integer> {
389398
}
390399

400+
static class WithMethodParameter {
401+
public void nestedGenerics(List<Map<String, Integer>> input) {
402+
}
403+
}
404+
391405

392406
}

0 commit comments

Comments
 (0)