aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpovirk <cpovirk@google.com>2023-11-21 13:41:09 -0800
committerGoogle Java Core Libraries <jake-team+copybara@google.com>2023-11-21 13:43:01 -0800
commite5cc39c9e0bcca1347a937cb090321fb96de0e5c (patch)
treebf6c072db7dc7c8341f3da469b8c582ebf70856c
parent3856cacfa59fdd2fe2bf47c787e7407e6e81479b (diff)
downloadguava-e5cc39c9e0bcca1347a937cb090321fb96de0e5c.tar.gz
Work around or suppress forthcoming nullness errors.
This CL also provides a little more progress toward https://github.com/google/guava/issues/3679: One of the workarounds involves removing a call to the long-obsolete `Iterators.cast`, and I went ahead and removed the method itself, too. RELNOTES=n/a PiperOrigin-RevId: 584417248
-rw-r--r--android/guava/src/com/google/common/collect/Iterators.java6
-rw-r--r--android/guava/src/com/google/common/collect/TableCollectors.java2
-rw-r--r--android/guava/src/com/google/common/collect/TransformedListIterator.java2
-rw-r--r--guava-testlib/src/com/google/common/testing/CollectorTester.java1
-rw-r--r--guava/src/com/google/common/collect/Iterators.java6
-rw-r--r--guava/src/com/google/common/collect/Multimaps.java5
-rw-r--r--guava/src/com/google/common/collect/TableCollectors.java2
-rw-r--r--guava/src/com/google/common/collect/Tables.java5
-rw-r--r--guava/src/com/google/common/collect/TransformedListIterator.java2
9 files changed, 11 insertions, 20 deletions
diff --git a/android/guava/src/com/google/common/collect/Iterators.java b/android/guava/src/com/google/common/collect/Iterators.java
index 0699202fe..61aece3f2 100644
--- a/android/guava/src/com/google/common/collect/Iterators.java
+++ b/android/guava/src/com/google/common/collect/Iterators.java
@@ -42,7 +42,6 @@ import java.util.Deque;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
@@ -1444,9 +1443,4 @@ public final class Iterators {
toRemove = null;
}
}
-
- /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> ListIterator<T> cast(Iterator<T> iterator) {
- return (ListIterator<T>) iterator;
- }
}
diff --git a/android/guava/src/com/google/common/collect/TableCollectors.java b/android/guava/src/com/google/common/collect/TableCollectors.java
index 9e71d80ab..64ee1d587 100644
--- a/android/guava/src/com/google/common/collect/TableCollectors.java
+++ b/android/guava/src/com/google/common/collect/TableCollectors.java
@@ -93,7 +93,7 @@ final class TableCollectors {
java.util.function.Function<? super T, ? extends C> columnFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<I> tableSupplier) {
- return toTable(
+ return TableCollectors.<T, R, C, V, I>toTable(
rowFunction,
columnFunction,
valueFunction,
diff --git a/android/guava/src/com/google/common/collect/TransformedListIterator.java b/android/guava/src/com/google/common/collect/TransformedListIterator.java
index 66b42e4c6..22b4b7c42 100644
--- a/android/guava/src/com/google/common/collect/TransformedListIterator.java
+++ b/android/guava/src/com/google/common/collect/TransformedListIterator.java
@@ -36,7 +36,7 @@ abstract class TransformedListIterator<F extends @Nullable Object, T extends @Nu
}
private ListIterator<? extends F> backingIterator() {
- return Iterators.cast(backingIterator);
+ return (ListIterator<? extends F>) backingIterator;
}
@Override
diff --git a/guava-testlib/src/com/google/common/testing/CollectorTester.java b/guava-testlib/src/com/google/common/testing/CollectorTester.java
index 656edbd41..2e154c175 100644
--- a/guava-testlib/src/com/google/common/testing/CollectorTester.java
+++ b/guava-testlib/src/com/google/common/testing/CollectorTester.java
@@ -147,6 +147,7 @@ public final class CollectorTester<
*/
@SafeVarargs
@CanIgnoreReturnValue
+ @SuppressWarnings("nullness") // TODO(cpovirk): Remove after we fix whatever the bug is.
public final CollectorTester<T, A, R> expectCollects(R expectedResult, T... inputs) {
List<T> list = Arrays.asList(inputs);
doExpectCollects(expectedResult, list);
diff --git a/guava/src/com/google/common/collect/Iterators.java b/guava/src/com/google/common/collect/Iterators.java
index 0699202fe..61aece3f2 100644
--- a/guava/src/com/google/common/collect/Iterators.java
+++ b/guava/src/com/google/common/collect/Iterators.java
@@ -42,7 +42,6 @@ import java.util.Deque;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
@@ -1444,9 +1443,4 @@ public final class Iterators {
toRemove = null;
}
}
-
- /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> ListIterator<T> cast(Iterator<T> iterator) {
- return (ListIterator<T>) iterator;
- }
}
diff --git a/guava/src/com/google/common/collect/Multimaps.java b/guava/src/com/google/common/collect/Multimaps.java
index 90401fb25..c158c6519 100644
--- a/guava/src/com/google/common/collect/Multimaps.java
+++ b/guava/src/com/google/common/collect/Multimaps.java
@@ -122,7 +122,7 @@ public final class Multimaps {
java.util.function.Function<? super T, ? extends K> keyFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<M> multimapSupplier) {
- return CollectCollectors.toMultimap(keyFunction, valueFunction, multimapSupplier);
+ return CollectCollectors.<T, K, V, M>toMultimap(keyFunction, valueFunction, multimapSupplier);
}
/**
@@ -167,7 +167,8 @@ public final class Multimaps {
java.util.function.Function<? super T, ? extends K> keyFunction,
java.util.function.Function<? super T, ? extends Stream<? extends V>> valueFunction,
java.util.function.Supplier<M> multimapSupplier) {
- return CollectCollectors.flatteningToMultimap(keyFunction, valueFunction, multimapSupplier);
+ return CollectCollectors.<T, K, V, M>flatteningToMultimap(
+ keyFunction, valueFunction, multimapSupplier);
}
/**
diff --git a/guava/src/com/google/common/collect/TableCollectors.java b/guava/src/com/google/common/collect/TableCollectors.java
index 16fcb1669..0257954ee 100644
--- a/guava/src/com/google/common/collect/TableCollectors.java
+++ b/guava/src/com/google/common/collect/TableCollectors.java
@@ -90,7 +90,7 @@ final class TableCollectors {
java.util.function.Function<? super T, ? extends C> columnFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<I> tableSupplier) {
- return toTable(
+ return TableCollectors.<T, R, C, V, I>toTable(
rowFunction,
columnFunction,
valueFunction,
diff --git a/guava/src/com/google/common/collect/Tables.java b/guava/src/com/google/common/collect/Tables.java
index 887eafff9..a9d0bb654 100644
--- a/guava/src/com/google/common/collect/Tables.java
+++ b/guava/src/com/google/common/collect/Tables.java
@@ -77,7 +77,8 @@ public final class Tables {
java.util.function.Function<? super T, ? extends C> columnFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<I> tableSupplier) {
- return TableCollectors.toTable(rowFunction, columnFunction, valueFunction, tableSupplier);
+ return TableCollectors.<T, R, C, V, I>toTable(
+ rowFunction, columnFunction, valueFunction, tableSupplier);
}
/**
@@ -106,7 +107,7 @@ public final class Tables {
java.util.function.Function<? super T, ? extends V> valueFunction,
BinaryOperator<V> mergeFunction,
java.util.function.Supplier<I> tableSupplier) {
- return TableCollectors.toTable(
+ return TableCollectors.<T, R, C, V, I>toTable(
rowFunction, columnFunction, valueFunction, mergeFunction, tableSupplier);
}
diff --git a/guava/src/com/google/common/collect/TransformedListIterator.java b/guava/src/com/google/common/collect/TransformedListIterator.java
index 66b42e4c6..22b4b7c42 100644
--- a/guava/src/com/google/common/collect/TransformedListIterator.java
+++ b/guava/src/com/google/common/collect/TransformedListIterator.java
@@ -36,7 +36,7 @@ abstract class TransformedListIterator<F extends @Nullable Object, T extends @Nu
}
private ListIterator<? extends F> backingIterator() {
- return Iterators.cast(backingIterator);
+ return (ListIterator<? extends F>) backingIterator;
}
@Override