Skip to content

Commit

Permalink
Roll back J2KT Map.merge nullness annotations to the more flexible …
Browse files Browse the repository at this point in the history
…(if possibly less convenient) original version, updating Guava.

This is another annotation from the [On Leveraging Tests to Infer Nullable Annotations](#6510) data.

RELNOTES=n/a
PiperOrigin-RevId: 546272042
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jul 7, 2023
1 parent fa695a1 commit 74859eb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion guava/src/com/google/common/cache/LocalCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -4277,7 +4277,9 @@ public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> f
}

@Override
public V merge(K key, V newValue, BiFunction<? super V, ? super V, ? extends V> function) {
@CheckForNull
public V merge(
K key, V newValue, BiFunction<? super V, ? super V, ? extends @Nullable V> function) {
checkNotNull(key);
checkNotNull(newValue);
checkNotNull(function);
Expand Down
3 changes: 2 additions & 1 deletion guava/src/com/google/common/collect/ImmutableMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,9 @@ public final V compute(
@Deprecated
@Override
@DoNotCall("Always throws UnsupportedOperationException")
@CheckForNull
public final V merge(
K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
K key, V value, BiFunction<? super V, ? super V, ? extends @Nullable V> function) {
throw new UnsupportedOperationException();
}

Expand Down
6 changes: 4 additions & 2 deletions guava/src/com/google/common/collect/Maps.java
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,9 @@ public V compute(
}

@Override
@CheckForNull
public V merge(
K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
K key, V value, BiFunction<? super V, ? super V, ? extends @Nullable V> function) {
throw new UnsupportedOperationException();
}

Expand Down Expand Up @@ -3656,8 +3657,9 @@ public V compute(
}

@Override
@CheckForNull
public V merge(
K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
K key, V value, BiFunction<? super V, ? super V, ? extends @Nullable V> function) {
throw new UnsupportedOperationException();
}

Expand Down
3 changes: 2 additions & 1 deletion guava/src/com/google/common/collect/Synchronized.java
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,9 @@ public V compute(
}

@Override
@CheckForNull
public V merge(
K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
K key, V value, BiFunction<? super V, ? super V, ? extends @Nullable V> remappingFunction) {
synchronized (mutex) {
return delegate().merge(key, value, remappingFunction);
}
Expand Down

0 comments on commit 74859eb

Please sign in to comment.