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

Annotations on generic or array incorrectly considered fix #2502

Merged
merged 7 commits into from
Aug 9, 2023

Conversation

gtoison
Copy link
Contributor

@gtoison gtoison commented Aug 5, 2023

The NonNull annotations might be on the return type or on the parameters but it might also be on generics of the corresponding types. When they are on the return/parameter we should consider them, when they are on the generics we (currently) should ignore them.

For instance List<@NonNull V> means that the list contains non null elements, but the list itself might be null

See #2500

The NonNull annotations might be on the return type or on the parameters
but they might also be on generics of the corresponding types.
When they are on the return/parameter we should consider them, when they
are on the generics we (currently) should ignore them.
The typePath seem to be set when the annotation is for a generic
@gtoison gtoison changed the title test: added tests showing the issue with annotations on generics Annotations on generic or array incorrectly considered fix Aug 5, 2023
@trancexpress
Copy link
Contributor

trancexpress commented Aug 7, 2023

Looks good, the bug is fixed with this PR. Thank you!

Copy link
Collaborator

@JuditKnoll JuditKnoll left a comment

Choose a reason for hiding this comment

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

LGTM! It seems like this issue solves several older issues as well.

@iloveeclipse iloveeclipse merged commit 2fdbb01 into spotbugs:master Aug 9, 2023
4 checks passed
@hazendaz hazendaz added this to the SpotBugs 4.8.0 milestone Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants