diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java index ee93d9b1ff8a..ca464fff401a 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.Spliterator; +import java.util.function.Predicate; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -64,6 +65,10 @@ public final boolean removeAll(Collection oldElements) { throw new UnsupportedOperationException(); } + public final boolean removeIf(Predicate predicate) { + throw new UnsupportedOperationException(); + } + public final boolean retainAll(Collection elementsToKeep) { throw new UnsupportedOperationException(); } diff --git a/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java b/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java index 40b2c859d20c..8cbd7ea9a766 100644 --- a/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java +++ b/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java @@ -224,6 +224,11 @@ public static void assertMultisetIsUnmodifiable(Multiset multiset, E samp } assertCollectionsAreEquivalent(multiset, copy); + try { + multiset.removeIf(x -> false); + fail("removeIf(Predicate) succeeded on unmodifiable collection"); + } catch (UnsupportedOperationException expected) { + } assertCollectionsAreEquivalent(multiset, copy); assertSetIsUnmodifiable(multiset.elementSet(), sampleElement); diff --git a/guava/src/com/google/common/collect/Multisets.java b/guava/src/com/google/common/collect/Multisets.java index fcc674472c31..ce8aee9fe532 100644 --- a/guava/src/com/google/common/collect/Multisets.java +++ b/guava/src/com/google/common/collect/Multisets.java @@ -195,6 +195,11 @@ public boolean removeAll(Collection elementsToRemove) { throw new UnsupportedOperationException(); } + @Override + public boolean removeIf(java.util.function.Predicate filter) { + throw new UnsupportedOperationException(); + } + @Override public boolean retainAll(Collection elementsToRetain) { throw new UnsupportedOperationException();