|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2020 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -1159,6 +1159,20 @@ void isAssignableFromForComplexWildcards() throws Exception {
|
1159 | 1159 | assertThatResolvableType(complex4).isNotAssignableFrom(complex3);
|
1160 | 1160 | }
|
1161 | 1161 |
|
| 1162 | + @Test |
| 1163 | + void identifyTypeVariable() throws Exception { |
| 1164 | + Method method = ClassArguments.class.getMethod("typedArgumentFirst", Class.class, Class.class, Class.class); |
| 1165 | + ResolvableType returnType = ResolvableType.forMethodReturnType(method, ClassArguments.class); |
| 1166 | + |
| 1167 | + ResolvableType arg0 = ResolvableType.forMethodParameter(method, 0, ClassArguments.class); |
| 1168 | + ResolvableType arg1 = ResolvableType.forMethodParameter(method, 1, ClassArguments.class); |
| 1169 | + ResolvableType arg2 = ResolvableType.forMethodParameter(method, 2, ClassArguments.class); |
| 1170 | + |
| 1171 | + assertThat(returnType.getType().equals(arg0.as(Class.class).getGeneric(0).getType())).isTrue(); |
| 1172 | + assertThat(returnType.getType().equals(arg1.as(Class.class).getGeneric(0).getType())).isFalse(); |
| 1173 | + assertThat(returnType.getType().equals(arg2.as(Class.class).getGeneric(0).getType())).isFalse(); |
| 1174 | + } |
| 1175 | + |
1162 | 1176 | @Test
|
1163 | 1177 | void hashCodeAndEquals() throws Exception {
|
1164 | 1178 | ResolvableType forClass = ResolvableType.forClass(List.class);
|
@@ -1427,6 +1441,10 @@ interface Methods<T> {
|
1427 | 1441 | }
|
1428 | 1442 |
|
1429 | 1443 |
|
| 1444 | + interface TypedMethods extends Methods<String> { |
| 1445 | + } |
| 1446 | + |
| 1447 | + |
1430 | 1448 | static class AssignmentBase<O, C, S> {
|
1431 | 1449 |
|
1432 | 1450 | public O o;
|
@@ -1479,7 +1497,9 @@ static class Assignment extends AssignmentBase<Object, CharSequence, String> {
|
1479 | 1497 | }
|
1480 | 1498 |
|
1481 | 1499 |
|
1482 |
| - interface TypedMethods extends Methods<String> { |
| 1500 | + interface ClassArguments { |
| 1501 | + |
| 1502 | + <T> T typedArgumentFirst(Class<T> arg0, Class<?> arg1, Class<Object> arg2); |
1483 | 1503 | }
|
1484 | 1504 |
|
1485 | 1505 |
|
|
0 commit comments