-
Notifications
You must be signed in to change notification settings - Fork 357
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
False alarm when using "return null" and type is known to support nulls #3614
Comments
One more sample which does not have a nice workaround except public static @PolyNull Integer plus(@PolyNull Integer b0, @PolyNull Integer b1) {
return (b0 == null || b1 == null) ? null : (b0 + b1);
} |
The |
Followup: the fix for #3622 does not resolve this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample code:
Error:
Could checker be a bit smarter, so it could see that {{b == null}} implies {{@polynull}} is in {{@nullable}} mode, so it should be perfectly valid to return {{null}}.
I understand I can rewrite the method like {{return (b == null) ? b : !b;}}, however, it would be nice if checker could figure out that automatically.
Another example might involve regular generics without Poly annotations:
It would be nice if checker could figure out
return null
is reachable only in the caseT is nullable
.Another example:
The text was updated successfully, but these errors were encountered: