Skip to content

Commit

Permalink
More reliably use transitional @CheckForNull annotations.
Browse files Browse the repository at this point in the history
(followup to cl/494880081)

We might _still_ not be 100% consistent in using them.

(Again, this helps slightly in my periodic attempts to [run NullAway](#2484 (comment)).)

RELNOTES=n/a
PiperOrigin-RevId: 497199314
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Dec 22, 2022
1 parent 59d174c commit a1d0f5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ private List<V> getCopy(@ParametricNullness K key) {
*/
@CanIgnoreReturnValue
@Override
public List<V> removeAll(@Nullable Object key) {
public List<V> removeAll(@CheckForNull Object key) {
/*
* Safe because all we do is remove values for the key, not add them. (If we wanted to make sure
* to call getCopy and removeAllNodes only with a true K, then we could check containsKey first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ private List<V> getCopy(@ParametricNullness K key) {
*/
@CanIgnoreReturnValue
@Override
public List<V> removeAll(@Nullable Object key) {
public List<V> removeAll(@CheckForNull Object key) {
/*
* Safe because all we do is remove values for the key, not add them. (If we wanted to make sure
* to call getCopy and removeAllNodes only with a true K, then we could check containsKey first.
Expand Down
3 changes: 2 additions & 1 deletion guava/src/com/google/common/collect/RegularImmutableMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ private RegularImmutableMap(
* flooding attack
*/
@CanIgnoreReturnValue
static <K, V> @Nullable ImmutableMapEntry<K, V> checkNoConflictInKeyBucket(
@CheckForNull
static <K, V> ImmutableMapEntry<K, V> checkNoConflictInKeyBucket(
Object key,
Object newValue,
@CheckForNull ImmutableMapEntry<K, V> keyBucketHead,
Expand Down

0 comments on commit a1d0f5b

Please sign in to comment.