|
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.*;
|
19 | 19 |
|
| 20 | +import java.lang.reflect.Method; |
20 | 21 | import java.util.Collection;
|
21 | 22 | import java.util.Collections;
|
22 | 23 | import java.util.EnumMap;
|
|
33 | 34 | import org.springframework.beans.factory.annotation.Autowire;
|
34 | 35 | import org.springframework.core.ResolvableType;
|
35 | 36 | import org.springframework.data.geo.GeoResults;
|
| 37 | +import org.springframework.data.repository.Repository; |
36 | 38 | import org.springframework.util.ReflectionUtils;
|
37 | 39 |
|
38 | 40 | /**
|
@@ -358,6 +360,24 @@ void considersNestedGenericsInEquality() throws ReflectiveOperationException {
|
358 | 360 | assertThat(TypeInformation.of(containerList)).isNotEqualTo(TypeInformation.of(containerMap));
|
359 | 361 | }
|
360 | 362 |
|
| 363 | + @Test // GH-3084 |
| 364 | + void considersNestedGenericsInEqualityForRecursiveUnresolvableTypes() throws Exception { |
| 365 | + |
| 366 | + TypeInformation<RepoWithRawGenerics> repro = TypeInformation.of(RepoWithRawGenerics.class); |
| 367 | + |
| 368 | + Method findAllExternalIdsFor = RepoWithRawGenerics.class.getDeclaredMethod("findAllExternalIdsFor"); |
| 369 | + TypeInformation<?> returnType = repro.getReturnType(findAllExternalIdsFor); |
| 370 | + |
| 371 | + List<TypeInformation<?>> arguments = TypeInformation.of(RepoWithRawGenerics.class)// |
| 372 | + .getRequiredSuperTypeInformation(Repository.class)// |
| 373 | + .getTypeArguments(); |
| 374 | + |
| 375 | + TypeInformation<?> domainType = arguments.get(1); |
| 376 | + TypeInformation<?> actualType = returnType.getRequiredComponentType(); |
| 377 | + |
| 378 | + assertThat(domainType.isAssignableFrom(actualType)).isTrue(); |
| 379 | + } |
| 380 | + |
361 | 381 | class Person {
|
362 | 382 |
|
363 | 383 | Addresses addresses;
|
@@ -462,4 +482,14 @@ static class MyContainer<T> {
|
462 | 482 | T data;
|
463 | 483 | }
|
464 | 484 |
|
| 485 | + static abstract class SomeType<Self extends SomeType<Self>> { |
| 486 | + |
| 487 | + } |
| 488 | + |
| 489 | + @SuppressWarnings("rawtypes") |
| 490 | + interface RepoWithRawGenerics extends Repository<SomeType, SomeType> { |
| 491 | + |
| 492 | + <T extends SomeType<T>> List<SomeType<T>> findAllExternalIdsFor(); |
| 493 | + } |
| 494 | + |
465 | 495 | }
|
0 commit comments