-
Notifications
You must be signed in to change notification settings - Fork 781
Open
Description
When enabling NullAway's jspecify mode, the use of arrays needs to be annotated for stricter nullability. For example,
.../LocalAsyncCache.java:818: warning: [NullAway] Writing @Nullable expression into array with @NonNull contents.
oldValue[0] = Async.getIfReady(oldValueFuture);To satisfy this check without a suppression requires the change
-var oldValue = (V[]) new Object[1];
+@Nullable V[] oldValue = (V[]) new Object[1];ErrorProne then emits a warning,
.../LocalAsyncCache.java:800: warning: [Varifier] Consider using `var` here to avoid boilerplate.
@Nullable V[] oldValue = (V[]) new Object[1];
^
(see https://errorprone.info/bugpattern/Varifier)
Did you mean '@Nullable var oldValue = (V[]) new Object[1];'?However that suggestion is invalid by JLS and instead the warning must be suppressed.
.../LocalAsyncCache.java:800: error: annotation interface not applicable to this kind of declaration
@Nullable var oldValue = (V[]) new Object[1];
^
1 errorNote that the annotation is not carried forward in the inferred type for NullAway to use if instead trying to resolve both checks
var oldValue = (@Nullable V[]) new Object[1];Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels