Skip to content

Commit

Permalink
Suppress or work around false-positive errors from the forthcoming ve…
Browse files Browse the repository at this point in the history
…rsion of our nullness checker.

RELNOTES=n/a
PiperOrigin-RevId: 627817079
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Apr 24, 2024
1 parent 730ca9f commit 21fb201
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ boolean removeEntriesIf(Predicate<? super Entry<K, Collection<V>>> predicate) {
Entry<K, Collection<V>> entry = entryIterator.next();
K key = entry.getKey();
Collection<V> collection = filterCollection(entry.getValue(), new ValuePredicate(key));
if (!collection.isEmpty() && predicate.apply(Maps.immutableEntry(key, collection))) {
if (!collection.isEmpty()
&& predicate.apply(Maps.<K, Collection<V>>immutableEntry(key, collection))) {
if (collection.size() == entry.getValue().size()) {
entryIterator.remove();
} else {
Expand Down Expand Up @@ -400,7 +401,7 @@ private boolean removeEntriesIf(Predicate<? super Multiset.Entry<K>> predicate)
return FilteredEntryMultimap.this.removeEntriesIf(
(Map.Entry<K, Collection<V>> entry) ->
predicate.apply(
Multisets.immutableEntry(entry.getKey(), entry.getValue().size())));
Multisets.<K>immutableEntry(entry.getKey(), entry.getValue().size())));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion android/guava/src/com/google/common/collect/Iterables.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T
Iterable<? extends T> iterable,
Predicate<? super T> predicate,
@CheckForNull T defaultValue) {
return Iterators.find(iterable.iterator(), predicate, defaultValue);
return Iterators.<T>find(iterable.iterator(), predicate, defaultValue);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion android/guava/src/com/google/common/collect/Maps.java
Original file line number Diff line number Diff line change
Expand Up @@ -3325,7 +3325,8 @@ Predicate<Entry<V, K>> inversePredicate(
return new Predicate<Entry<V, K>>() {
@Override
public boolean apply(Entry<V, K> input) {
return forwardPredicate.apply(Maps.immutableEntry(input.getValue(), input.getKey()));
return forwardPredicate.apply(
Maps.<K, V>immutableEntry(input.getValue(), input.getKey()));
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions android/guava/src/com/google/common/collect/Ordering.java
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public <E extends T> E min(Iterator<E> iterator) {
E minSoFar = iterator.next();

while (iterator.hasNext()) {
minSoFar = min(minSoFar, iterator.next());
minSoFar = this.<E>min(minSoFar, iterator.next());
}

return minSoFar;
Expand Down Expand Up @@ -660,7 +660,7 @@ public <E extends T> E max(Iterator<E> iterator) {
E maxSoFar = iterator.next();

while (iterator.hasNext()) {
maxSoFar = max(maxSoFar, iterator.next());
maxSoFar = this.<E>max(maxSoFar, iterator.next());
}

return maxSoFar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ boolean removeEntriesIf(Predicate<? super Entry<K, Collection<V>>> predicate) {
Entry<K, Collection<V>> entry = entryIterator.next();
K key = entry.getKey();
Collection<V> collection = filterCollection(entry.getValue(), new ValuePredicate(key));
if (!collection.isEmpty() && predicate.apply(Maps.immutableEntry(key, collection))) {
if (!collection.isEmpty()
&& predicate.apply(Maps.<K, Collection<V>>immutableEntry(key, collection))) {
if (collection.size() == entry.getValue().size()) {
entryIterator.remove();
} else {
Expand Down Expand Up @@ -400,7 +401,7 @@ private boolean removeEntriesIf(Predicate<? super Multiset.Entry<K>> predicate)
return FilteredEntryMultimap.this.removeEntriesIf(
(Map.Entry<K, Collection<V>> entry) ->
predicate.apply(
Multisets.immutableEntry(entry.getKey(), entry.getValue().size())));
Multisets.<K>immutableEntry(entry.getKey(), entry.getValue().size())));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/collect/Iterables.java
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T
Iterable<? extends T> iterable,
Predicate<? super T> predicate,
@CheckForNull T defaultValue) {
return Iterators.find(iterable.iterator(), predicate, defaultValue);
return Iterators.<T>find(iterable.iterator(), predicate, defaultValue);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions guava/src/com/google/common/collect/Maps.java
Original file line number Diff line number Diff line change
Expand Up @@ -3442,7 +3442,8 @@ Predicate<Entry<V, K>> inversePredicate(
return new Predicate<Entry<V, K>>() {
@Override
public boolean apply(Entry<V, K> input) {
return forwardPredicate.apply(Maps.immutableEntry(input.getValue(), input.getKey()));
return forwardPredicate.apply(
Maps.<K, V>immutableEntry(input.getValue(), input.getKey()));
}
};
}
Expand Down Expand Up @@ -3475,7 +3476,7 @@ public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
unfiltered()
.replaceAll(
(key, value) ->
predicate.apply(Maps.immutableEntry(key, value))
predicate.apply(Maps.<K, V>immutableEntry(key, value))
? function.apply(key, value)
: value);
}
Expand Down
4 changes: 2 additions & 2 deletions guava/src/com/google/common/collect/Ordering.java
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public <E extends T> E min(Iterator<E> iterator) {
E minSoFar = iterator.next();

while (iterator.hasNext()) {
minSoFar = min(minSoFar, iterator.next());
minSoFar = this.<E>min(minSoFar, iterator.next());
}

return minSoFar;
Expand Down Expand Up @@ -660,7 +660,7 @@ public <E extends T> E max(Iterator<E> iterator) {
E maxSoFar = iterator.next();

while (iterator.hasNext()) {
maxSoFar = max(maxSoFar, iterator.next());
maxSoFar = this.<E>max(maxSoFar, iterator.next());
}

return maxSoFar;
Expand Down
2 changes: 2 additions & 0 deletions guava/src/com/google/common/collect/TreeRangeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ public void remove(Range<Comparable<?>> range) {
}

@Override
// https://github.com/jspecify/jspecify-reference-checker/issues/162
@SuppressWarnings("nullness")
public void merge(
Range<Comparable<?>> range,
@CheckForNull Object value,
Expand Down

0 comments on commit 21fb201

Please sign in to comment.