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

Resolve method-only bounded generics correctly #34086

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rPraml
Copy link

@rPraml rPraml commented Dec 13, 2024

I tried to make a unit test and a possible fix for #33968

Someone who knows more about it than me should take another look at the fix ;)

@pivotal-cla
Copy link

@rPraml Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 13, 2024
@pivotal-cla
Copy link

@rPraml Thank you for signing the Contributor License Agreement!

@@ -180,7 +180,7 @@ else if (genericType instanceof ParameterizedType parameterizedType) {
generics[i] = resolvedTypeArgument;
}
else {
generics[i] = ResolvableType.forType(typeArgument);
generics[i] = ResolvableType.forType(typeArgument).resolveType();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I understand the code here, we want to resolve the T of a generic. If the T is not defined by the contextType, (because ist is no class Foo<T extends Bar>) we get to this line.

In my case, the T is bound by the function public <T extends BaseType> List<T> get() and means, that T is at least a BaseType

IMHO the type must be resolved here, so that the following code knows , that the elements in the list are BaseType or subtypes. This is later required for jackson, otherwise we have problems mentioned in this SO post.

@rPraml rPraml changed the title Possible fix for 33968 Resolve method-only bounded generics correctly Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants