Skip to content

Commit

Permalink
Remove @CanIgnoreReturnValue from a few functional interfaces.
Browse files Browse the repository at this point in the history
RELNOTES=N/A
PiperOrigin-RevId: 482480564
  • Loading branch information
java-team-github-bot authored and Google Java Core Libraries committed Oct 20, 2022
1 parent d48418e commit f9d336f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void testMemoizeNonSerializable() throws Exception {
assertThat(memoizedSupplier.toString()).isEqualTo("Suppliers.memoize(CountingSupplier)");
checkMemoize(countingSupplier, memoizedSupplier);
// Calls to the original memoized supplier shouldn't affect its copy.
memoizedSupplier.get();
Object unused = memoizedSupplier.get();
assertThat(memoizedSupplier.toString())
.isEqualTo("Suppliers.memoize(<supplier that returned 10>)");

Expand All @@ -153,12 +153,12 @@ public void testMemoizeSerializable() throws Exception {
assertThat(memoizedSupplier.toString()).isEqualTo("Suppliers.memoize(CountingSupplier)");
checkMemoize(countingSupplier, memoizedSupplier);
// Calls to the original memoized supplier shouldn't affect its copy.
memoizedSupplier.get();
Object unused = memoizedSupplier.get();
assertThat(memoizedSupplier.toString())
.isEqualTo("Suppliers.memoize(<supplier that returned 10>)");

Supplier<Integer> copy = reserialize(memoizedSupplier);
memoizedSupplier.get();
Object unused2 = memoizedSupplier.get();

CountingSupplier countingCopy =
(CountingSupplier) ((Suppliers.MemoizingSupplier<Integer>) copy).delegate;
Expand Down Expand Up @@ -230,10 +230,10 @@ public void testMemoizeWithExpirationSerialized() throws InterruptedException {
Supplier<Integer> memoizedSupplier =
Suppliers.memoizeWithExpiration(countingSupplier, 75, TimeUnit.MILLISECONDS);
// Calls to the original memoized supplier shouldn't affect its copy.
memoizedSupplier.get();
Object unused = memoizedSupplier.get();

Supplier<Integer> copy = reserialize(memoizedSupplier);
memoizedSupplier.get();
Object unused2 = memoizedSupplier.get();

CountingSupplier countingCopy =
(CountingSupplier) ((Suppliers.ExpiringMemoizingSupplier<Integer>) copy).delegate;
Expand Down Expand Up @@ -402,7 +402,7 @@ public Integer get() {
@Override
public void run() {
for (int j = 0; j < iterations; j++) {
Suppliers.synchronizedSupplier(nonThreadSafe).get();
Object unused = Suppliers.synchronizedSupplier(nonThreadSafe).get();
}
}
};
Expand Down
2 changes: 0 additions & 2 deletions android/guava/src/com/google/common/base/Predicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.common.base;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down Expand Up @@ -63,7 +62,6 @@ public interface Predicate<T extends @Nullable Object> {
* @throws NullPointerException if {@code input} is null and this predicate does not accept null
* arguments
*/
@CanIgnoreReturnValue
boolean apply(@ParametricNullness T input);

/**
Expand Down
2 changes: 0 additions & 2 deletions android/guava/src/com/google/common/base/Supplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.common.base;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
Expand Down Expand Up @@ -54,7 +53,6 @@ public interface Supplier<T extends @Nullable Object> {
*
* @return an instance of the appropriate type
*/
@CanIgnoreReturnValue
@ParametricNullness
T get();
}
12 changes: 6 additions & 6 deletions guava-tests/test/com/google/common/base/SuppliersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void testMemoizeNonSerializable() throws Exception {
assertThat(memoizedSupplier.toString()).isEqualTo("Suppliers.memoize(CountingSupplier)");
checkMemoize(countingSupplier, memoizedSupplier);
// Calls to the original memoized supplier shouldn't affect its copy.
memoizedSupplier.get();
Object unused = memoizedSupplier.get();
assertThat(memoizedSupplier.toString())
.isEqualTo("Suppliers.memoize(<supplier that returned 10>)");

Expand All @@ -153,12 +153,12 @@ public void testMemoizeSerializable() throws Exception {
assertThat(memoizedSupplier.toString()).isEqualTo("Suppliers.memoize(CountingSupplier)");
checkMemoize(countingSupplier, memoizedSupplier);
// Calls to the original memoized supplier shouldn't affect its copy.
memoizedSupplier.get();
Object unused = memoizedSupplier.get();
assertThat(memoizedSupplier.toString())
.isEqualTo("Suppliers.memoize(<supplier that returned 10>)");

Supplier<Integer> copy = reserialize(memoizedSupplier);
memoizedSupplier.get();
Object unused2 = memoizedSupplier.get();

CountingSupplier countingCopy =
(CountingSupplier) ((Suppliers.MemoizingSupplier<Integer>) copy).delegate;
Expand Down Expand Up @@ -230,10 +230,10 @@ public void testMemoizeWithExpirationSerialized() throws InterruptedException {
Supplier<Integer> memoizedSupplier =
Suppliers.memoizeWithExpiration(countingSupplier, 75, TimeUnit.MILLISECONDS);
// Calls to the original memoized supplier shouldn't affect its copy.
memoizedSupplier.get();
Object unused = memoizedSupplier.get();

Supplier<Integer> copy = reserialize(memoizedSupplier);
memoizedSupplier.get();
Object unused2 = memoizedSupplier.get();

CountingSupplier countingCopy =
(CountingSupplier) ((Suppliers.ExpiringMemoizingSupplier<Integer>) copy).delegate;
Expand Down Expand Up @@ -402,7 +402,7 @@ public Integer get() {
@Override
public void run() {
for (int j = 0; j < iterations; j++) {
Suppliers.synchronizedSupplier(nonThreadSafe).get();
Object unused = Suppliers.synchronizedSupplier(nonThreadSafe).get();
}
}
};
Expand Down
2 changes: 0 additions & 2 deletions guava/src/com/google/common/base/Predicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.common.base;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down Expand Up @@ -60,7 +59,6 @@ public interface Predicate<T extends @Nullable Object> extends java.util.functio
* @throws NullPointerException if {@code input} is null and this predicate does not accept null
* arguments
*/
@CanIgnoreReturnValue
boolean apply(@ParametricNullness T input);

/**
Expand Down
2 changes: 0 additions & 2 deletions guava/src/com/google/common/base/Supplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.common.base;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
Expand Down Expand Up @@ -46,7 +45,6 @@ public interface Supplier<T extends @Nullable Object> extends java.util.function
*
* @return an instance of the appropriate type
*/
@CanIgnoreReturnValue
@Override
@ParametricNullness
T get();
Expand Down

0 comments on commit f9d336f

Please sign in to comment.