Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…itch warnings.

RELNOTES=n/a
PiperOrigin-RevId: 686551836
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Oct 16, 2024
1 parent 10d4b1b commit 98d5528
Show file tree
Hide file tree
Showing 26 changed files with 44 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public void run() {
case FAILED:
f.setException(new Exception());
break;
default:
throw new AssertionError();
}
return f;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ void assertModelAgrees(
return;
}
break;
default:
throw new AssertionError();
}
// key is not present
int nextHigherIndex = list.size();
Expand All @@ -91,9 +89,8 @@ void assertModelAgrees(
case INVERTED_INSERTION_INDEX:
assertEquals(-1 - nextHigherIndex, answer);
return;
default:
throw new AssertionError();
}
throw new AssertionError();
}

public void testWithoutDups() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ private static MutableGraph<Integer> createGraph(EdgeType edgeType) {
return GraphBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return GraphBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

private static EdgeType oppositeType(EdgeType edgeType) {
Expand All @@ -67,9 +66,8 @@ private static EdgeType oppositeType(EdgeType edgeType) {
return EdgeType.DIRECTED;
case DIRECTED:
return EdgeType.UNDIRECTED;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

@Test
Expand Down Expand Up @@ -150,8 +148,6 @@ public void equivalent_edgeDirectionsDiffer() {
case DIRECTED:
assertThat(graph).isNotEqualTo(g2);
break;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ private static MutableNetwork<Integer, String> createNetwork(EdgeType edgeType)
return NetworkBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return NetworkBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

private static EdgeType oppositeType(EdgeType edgeType) {
Expand All @@ -72,9 +71,8 @@ private static EdgeType oppositeType(EdgeType edgeType) {
return EdgeType.DIRECTED;
case DIRECTED:
return EdgeType.UNDIRECTED;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

@Test
Expand Down Expand Up @@ -184,8 +182,6 @@ public void equivalent_edgeDirectionsDiffer() {
case DIRECTED:
assertThat(network).isNotEqualTo(g2);
break;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ void awaitTimedWaiting(Thread thread) {
case TIMED_WAITING:
return;
case TERMINATED:
default:
throw new AssertionError();
}
}
Expand Down
3 changes: 1 addition & 2 deletions android/guava/src/com/google/common/base/Stopwatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ private static String abbreviate(TimeUnit unit) {
return "h";
case DAYS:
return "d";
default:
throw new AssertionError();
}
throw new AssertionError();
}
}
12 changes: 4 additions & 8 deletions android/guava/src/com/google/common/collect/Cut.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,8 @@ Cut<C> withLowerBoundType(BoundType boundType, DiscreteDomain<C> domain) {
case OPEN:
C previous = domain.previous(endpoint);
return (previous == null) ? Cut.<C>belowAll() : new AboveValue<C>(previous);
default:
throw new AssertionError();
}
throw new AssertionError();
}

@Override
Expand All @@ -352,9 +351,8 @@ Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
return (previous == null) ? Cut.<C>aboveAll() : new AboveValue<C>(previous);
case OPEN:
return this;
default:
throw new AssertionError();
}
throw new AssertionError();
}

@Override
Expand Down Expand Up @@ -423,9 +421,8 @@ Cut<C> withLowerBoundType(BoundType boundType, DiscreteDomain<C> domain) {
case CLOSED:
C next = domain.next(endpoint);
return (next == null) ? Cut.<C>belowAll() : belowValue(next);
default:
throw new AssertionError();
}
throw new AssertionError();
}

@Override
Expand All @@ -436,9 +433,8 @@ Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
return (next == null) ? Cut.<C>aboveAll() : belowValue(next);
case CLOSED:
return this;
default:
throw new AssertionError();
}
throw new AssertionError();
}

@Override
Expand Down
6 changes: 2 additions & 4 deletions android/guava/src/com/google/common/collect/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ public static <C extends Comparable<?>> Range<C> upTo(C endpoint, BoundType boun
return lessThan(endpoint);
case CLOSED:
return atMost(endpoint);
default:
throw new AssertionError();
}
throw new AssertionError();
}

/**
Expand Down Expand Up @@ -266,9 +265,8 @@ public static <C extends Comparable<?>> Range<C> downTo(C endpoint, BoundType bo
return greaterThan(endpoint);
case CLOSED:
return atLeast(endpoint);
default:
throw new AssertionError();
}
throw new AssertionError();
}

private static final Range<Comparable> ALL = new Range<>(Cut.belowAll(), Cut.aboveAll());
Expand Down
6 changes: 2 additions & 4 deletions android/guava/src/com/google/common/collect/TreeMultiset.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ private long aggregateBelowRange(Aggregate aggr, @CheckForNull AvlNode<E> node)
return aggr.nodeAggregate(node) + aggr.treeAggregate(node.left);
case CLOSED:
return aggr.treeAggregate(node.left);
default:
throw new AssertionError();
}
throw new AssertionError();
} else {
return aggr.treeAggregate(node.left)
+ aggr.nodeAggregate(node)
Expand All @@ -216,9 +215,8 @@ private long aggregateAboveRange(Aggregate aggr, @CheckForNull AvlNode<E> node)
return aggr.nodeAggregate(node) + aggr.treeAggregate(node.right);
case CLOSED:
return aggr.treeAggregate(node.right);
default:
throw new AssertionError();
}
throw new AssertionError();
} else {
return aggr.treeAggregate(node.right)
+ aggr.nodeAggregate(node)
Expand Down
3 changes: 1 addition & 2 deletions android/guava/src/com/google/common/graph/ElementOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ <K extends T, V> Map<K, V> createMap(int expectedSize) {
return Maps.newLinkedHashMapWithExpectedSize(expectedSize);
case SORTED:
return Maps.newTreeMap(comparator());
default:
throw new AssertionError();
}
throw new AssertionError();
}

@SuppressWarnings("unchecked")
Expand Down
10 changes: 3 additions & 7 deletions android/guava/src/com/google/common/math/BigIntegerMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ public static int log2(BigInteger x, RoundingMode mode) {
BigInteger x2 = x.pow(2);
int logX2Floor = x2.bitLength() - 1;
return (logX2Floor < 2 * logFloor + 1) ? logFloor : logFloor + 1;

default:
throw new AssertionError();
}
throw new AssertionError();
}

/*
Expand Down Expand Up @@ -204,9 +202,8 @@ public static int log10(BigInteger x, RoundingMode mode) {
BigInteger x2 = x.pow(2);
BigInteger halfPowerSquared = floorPow.pow(2).multiply(BigInteger.TEN);
return (x2.compareTo(halfPowerSquared) <= 0) ? floorLog : floorLog + 1;
default:
throw new AssertionError();
}
throw new AssertionError();
}

private static final double LN_10 = Math.log(10);
Expand Down Expand Up @@ -250,9 +247,8 @@ public static BigInteger sqrt(BigInteger x, RoundingMode mode) {
* halfSquare.
*/
return (halfSquare.compareTo(x) >= 0) ? sqrtFloor : sqrtFloor.add(BigInteger.ONE);
default:
throw new AssertionError();
}
throw new AssertionError();
}

@GwtIncompatible // TODO
Expand Down
4 changes: 1 addition & 3 deletions android/guava/src/com/google/common/math/DoubleMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ static double roundIntermediate(double x, RoundingMode mode) {
return z;
}
}

default:
throw new AssertionError();
}
throw new AssertionError();
}

/**
Expand Down
10 changes: 3 additions & 7 deletions android/guava/src/com/google/common/math/IntMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ public static int log2(int x, RoundingMode mode) {
// floor(2^(logFloor + 0.5))
int logFloor = (Integer.SIZE - 1) - leadingZeros;
return logFloor + lessThanBranchFree(cmp, x);

default:
throw new AssertionError();
}
throw new AssertionError();
}

/** The biggest half power of two that can fit in an unsigned int. */
Expand Down Expand Up @@ -173,9 +171,8 @@ public static int log10(int x, RoundingMode mode) {
case HALF_EVEN:
// sqrt(10) is irrational, so log10(x) - logFloor is never exactly 0.5
return logFloor + lessThanBranchFree(halfPowersOf10[logFloor], x);
default:
throw new AssertionError();
}
throw new AssertionError();
}

private static int log10Floor(int x) {
Expand Down Expand Up @@ -292,9 +289,8 @@ public static int sqrt(int x, RoundingMode mode) {
* signed int, so lessThanBranchFree is safe for use.
*/
return sqrtFloor + lessThanBranchFree(halfSquare, x);
default:
throw new AssertionError();
}
throw new AssertionError();
}

private static int sqrtFloor(int x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public void run() {
case FAILED:
f.setException(new Exception());
break;
default:
throw new AssertionError();
}
return f;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ void assertModelAgrees(
return;
}
break;
default:
throw new AssertionError();
}
// key is not present
int nextHigherIndex = list.size();
Expand All @@ -91,9 +89,8 @@ void assertModelAgrees(
case INVERTED_INSERTION_INDEX:
assertEquals(-1 - nextHigherIndex, answer);
return;
default:
throw new AssertionError();
}
throw new AssertionError();
}

public void testWithoutDups() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ private static MutableGraph<Integer> createGraph(EdgeType edgeType) {
return GraphBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return GraphBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

private static EdgeType oppositeType(EdgeType edgeType) {
Expand All @@ -67,9 +66,8 @@ private static EdgeType oppositeType(EdgeType edgeType) {
return EdgeType.DIRECTED;
case DIRECTED:
return EdgeType.UNDIRECTED;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

@Test
Expand Down Expand Up @@ -150,8 +148,6 @@ public void equivalent_edgeDirectionsDiffer() {
case DIRECTED:
assertThat(graph).isNotEqualTo(g2);
break;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ private static MutableNetwork<Integer, String> createNetwork(EdgeType edgeType)
return NetworkBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return NetworkBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

private static EdgeType oppositeType(EdgeType edgeType) {
Expand All @@ -72,9 +71,8 @@ private static EdgeType oppositeType(EdgeType edgeType) {
return EdgeType.DIRECTED;
case DIRECTED:
return EdgeType.UNDIRECTED;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}

@Test
Expand Down Expand Up @@ -184,8 +182,6 @@ public void equivalent_edgeDirectionsDiffer() {
case DIRECTED:
assertThat(network).isNotEqualTo(g2);
break;
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ void awaitTimedWaiting(Thread thread) {
case TIMED_WAITING:
return;
case TERMINATED:
default:
throw new AssertionError();
}
}
Expand Down
3 changes: 1 addition & 2 deletions guava/src/com/google/common/base/Stopwatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ private static String abbreviate(TimeUnit unit) {
return "h";
case DAYS:
return "d";
default:
throw new AssertionError();
}
throw new AssertionError();
}
}
Loading

0 comments on commit 98d5528

Please sign in to comment.