[LANG-1702] test for LANG-1702 (#1151)

* test for LANG-1702

* remove trailing space

* Comments -> Javadoc

---------

Co-authored-by: Gary Gregory <garydgregory@users.noreply.github.com>
This commit is contained in:
Elliotte Rusty Harold 2024-01-03 07:14:16 -05:00 committed by GitHub
parent d788e7d389
commit 959178ee9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -315,6 +315,26 @@ public class TypeUtilsTest<B> extends AbstractLangTest {
assertArrayEquals(expectedArray, TypeUtils.normalizeUpperBounds(typeArray));
}
/** This non-static inner class is parameterized. */
private class MyInnerClass<T> {
}
/** The inner class is used as a return type from a method. */
private <U> MyInnerClass<U> aMethod() {
return null;
}
@Test
public void test_LANG_1702() throws NoSuchMethodException, SecurityException {
final Type type = TypeUtilsTest.class.getDeclaredMethod("aMethod").getGenericReturnType();
// any map will do
final Map<TypeVariable<?>, Type> typeArguments = Collections.emptyMap();
// this fails with a stack overflow
final Type unrolledType = TypeUtils.unrollVariables(typeArguments, type);
}
@Test
public void testContainsTypeVariables() throws Exception {
assertFalse(TypeUtils.containsTypeVariables(Test1.class.getMethod("m0").getGenericReturnType()));