Skip to content

Commit 664c80b

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Fix another accidental use of varargs min/max calls.
As in cl/689775552, I'm fixing a mistaken change from cl/687381111. RELNOTES=n/a PiperOrigin-RevId: 691549601
1 parent 5a63833 commit 664c80b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

android/guava/src/com/google/common/primitives/UnsignedInts.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import static com.google.common.base.Preconditions.checkArgument;
1818
import static com.google.common.base.Preconditions.checkNotNull;
1919
import static com.google.common.base.Preconditions.checkPositionIndexes;
20-
import static java.lang.Math.min;
2120

2221
import com.google.common.annotations.GwtCompatible;
2322
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -196,8 +195,10 @@ enum LexicographicalComparator implements Comparator<int[]> {
196195
INSTANCE;
197196

198197
@Override
198+
// A call to bare "min" or "max" would resolve to our varargs method, not to any static import.
199+
@SuppressWarnings("StaticImportPreferred")
199200
public int compare(int[] left, int[] right) {
200-
int minLength = min(left.length, right.length);
201+
int minLength = Math.min(left.length, right.length);
201202
for (int i = 0; i < minLength; i++) {
202203
if (left[i] != right[i]) {
203204
return UnsignedInts.compare(left[i], right[i]);

guava/src/com/google/common/primitives/UnsignedInts.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import static com.google.common.base.Preconditions.checkArgument;
1818
import static com.google.common.base.Preconditions.checkNotNull;
1919
import static com.google.common.base.Preconditions.checkPositionIndexes;
20-
import static java.lang.Math.min;
2120

2221
import com.google.common.annotations.GwtCompatible;
2322
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -196,8 +195,10 @@ enum LexicographicalComparator implements Comparator<int[]> {
196195
INSTANCE;
197196

198197
@Override
198+
// A call to bare "min" or "max" would resolve to our varargs method, not to any static import.
199+
@SuppressWarnings("StaticImportPreferred")
199200
public int compare(int[] left, int[] right) {
200-
int minLength = min(left.length, right.length);
201+
int minLength = Math.min(left.length, right.length);
201202
for (int i = 0; i < minLength; i++) {
202203
if (left[i] != right[i]) {
203204
return UnsignedInts.compare(left[i], right[i]);

0 commit comments

Comments
 (0)