From e945869708ecd32a2af13383ba3ad42eb89b9251 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Thu, 22 Dec 2022 11:35:51 -0800 Subject: [PATCH] More reliably use transitional `@CheckForNull` annotations. (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](https://github.com/google/guava/issues/2484#issuecomment-1203200500).) RELNOTES=n/a PiperOrigin-RevId: 497207876 --- .../src/com/google/common/collect/LinkedListMultimap.java | 2 +- guava/src/com/google/common/collect/LinkedListMultimap.java | 2 +- guava/src/com/google/common/collect/RegularImmutableMap.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/android/guava/src/com/google/common/collect/LinkedListMultimap.java b/android/guava/src/com/google/common/collect/LinkedListMultimap.java index be978fa9c60d..3644a90ac87f 100644 --- a/android/guava/src/com/google/common/collect/LinkedListMultimap.java +++ b/android/guava/src/com/google/common/collect/LinkedListMultimap.java @@ -676,7 +676,7 @@ private List getCopy(@ParametricNullness K key) { */ @CanIgnoreReturnValue @Override - public List removeAll(@Nullable Object key) { + public List 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. diff --git a/guava/src/com/google/common/collect/LinkedListMultimap.java b/guava/src/com/google/common/collect/LinkedListMultimap.java index dcbd32f29989..e026cdd1e2eb 100644 --- a/guava/src/com/google/common/collect/LinkedListMultimap.java +++ b/guava/src/com/google/common/collect/LinkedListMultimap.java @@ -678,7 +678,7 @@ private List getCopy(@ParametricNullness K key) { */ @CanIgnoreReturnValue @Override - public List removeAll(@Nullable Object key) { + public List 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. diff --git a/guava/src/com/google/common/collect/RegularImmutableMap.java b/guava/src/com/google/common/collect/RegularImmutableMap.java index f0f2031b9483..4155b169e792 100644 --- a/guava/src/com/google/common/collect/RegularImmutableMap.java +++ b/guava/src/com/google/common/collect/RegularImmutableMap.java @@ -228,7 +228,8 @@ private RegularImmutableMap( * flooding attack */ @CanIgnoreReturnValue - static @Nullable ImmutableMapEntry checkNoConflictInKeyBucket( + @CheckForNull + static ImmutableMapEntry checkNoConflictInKeyBucket( Object key, Object newValue, @CheckForNull ImmutableMapEntry keyBucketHead,