Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support variable resolution of wildcard types #24145

Merged
merged 1 commit into from Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -873,6 +873,12 @@ private ResolvableType resolveVariable(TypeVariable<?> variable) {
return forType(ownerType, this.variableResolver).resolveVariable(variable);
}
}
if (this.type instanceof WildcardType) {
ResolvableType resolved = resolveType().resolveVariable(variable);
if (resolved != null) {
return resolved;
}
}
if (this.variableResolver != null) {
return this.variableResolver.resolveVariable(variable);
}
Expand Down
Expand Up @@ -688,6 +688,13 @@ void resolveBoundedTypeVariableResult() throws Exception {
assertThat(type.resolve()).isEqualTo(CharSequence.class);
}


@Test
void resolveBoundedTypeVariableWildcardResult() throws Exception {
ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("boundedTypeVaraibleWildcardResult"));
assertThat(type.getGeneric(1).asCollection().resolveGeneric()).isEqualTo(CharSequence.class);
}

@Test
void resolveVariableNotFound() throws Exception {
ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("typedReturn"));
Expand Down Expand Up @@ -1417,6 +1424,8 @@ interface Methods<T> {

<R extends CharSequence & Serializable> R boundedTypeVaraibleResult();

Map<String, ? extends List<? extends CharSequence>> boundedTypeVaraibleWildcardResult();

void nested(Map<Map<String, Integer>, Map<Byte, Long>> p);

void typedParameter(T p);
Expand Down