Skip to content

Commit

Permalink
Polish "Resolve base type in parameterized type if necessary"
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Jan 15, 2025
1 parent 033d277 commit fe5f5d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
Expand Down Expand Up @@ -211,6 +211,14 @@ void resolveNestedTypeVariable() throws Exception {
assertThat(ResolvableType.forType(resolved).getGeneric(0).getGeneric(0).resolve()).isEqualTo(String.class);
}

@Test
void resolvedTypeWithBase() {
Type type = method(WithBaseTypes.class, "get").getGenericReturnType();
Type resolvedType = resolveType(type, WithBaseTypes.class);
ParameterizedTypeReference<List<A>> 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();
Expand Down Expand Up @@ -398,4 +406,12 @@ public interface ListOfListSupplier<T> {
public interface StringListOfListSupplier extends ListOfListSupplier<String> {
}

static class WithBaseTypes {

<T extends A> List<T> get() {
return List.of();
}

}

}

This file was deleted.

0 comments on commit fe5f5d5

Please sign in to comment.