-
Notifications
You must be signed in to change notification settings - Fork 756
Should ASTHelpers.getSymbol(Tree)
be annotated with @Nullable
?
#3760
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
Comments
Yes, I think so. I wonder if I/we accidentally deleted that at some point. |
copybara-service bot
pushed a commit
that referenced
this issue
Feb 9, 2023
Fixes external #3760. PiperOrigin-RevId: 508166642
copybara-service bot
pushed a commit
that referenced
this issue
Feb 9, 2023
Fixes external #3760. PiperOrigin-RevId: 508315637
thanks for the quick feedback closing since fixed by e08edcd |
msridhar
pushed a commit
to uber/NullAway
that referenced
this issue
Mar 10, 2023
This method will return `@Nullable` in the next Error Prone release: google/error-prone#3760 This change prepares for that by adding appropriate null checks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
according to the method javadoc it can return
null
in multiple cases:error-prone/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
Lines 244 to 250 in 1c3c09f
one of them being that it calls
getDeclaredSymbol
which is marked@Nullable
already:error-prone/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
Lines 219 to 224 in 1c3c09f
this seems kind of inconsistent.
there are of course multiple current usage spots where from the context + outer checks it is clear that it will not return
null
for example aroundAssignmentTree.getVariable()
here:error-prone/core/src/main/java/com/google/errorprone/bugpatterns/FieldCanBeLocal.java
Lines 262 to 269 in 1c3c09f
but if the goal of the
@Nullable
annotation is to systematically force proper null handling maybe the annotation should be added.WDYT ?
if it is an intentional decision, maybe there should be a comment about it to make it look less inconsistent.
The text was updated successfully, but these errors were encountered: