diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Dumper.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Dumper.java index 7f869e0ffc927a..f1a2bfe0c044fe 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Dumper.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Dumper.java @@ -274,15 +274,12 @@ private boolean outputObjectFields(Object obj) { } private void outputField(Object parent, FieldInfo info) { - if (info instanceof PrimitiveInfo primitiveInfo) { - primitiveInfo.output(parent, out); - } else if (info instanceof ObjectInfo objectInfo) { - out.append(objectInfo.name()).append('='); - outputObject(objectInfo.getFieldValue(parent)); - } else { - // TODO: b/297857068 - it should be possible to replace this with a pattern matching switch - // which won't require this line, but that's not yet supported. - throw new IllegalArgumentException("Unexpected FieldInfo type: " + info); + switch (info) { + case PrimitiveInfo primitiveInfo -> primitiveInfo.output(parent, out); + case ObjectInfo objectInfo -> { + out.append(objectInfo.name()).append('='); + outputObject(objectInfo.getFieldValue(parent)); + } } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Fingerprinter.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Fingerprinter.java index e5dfd15895b6e0..a206dfbf353cc3 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Fingerprinter.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/Fingerprinter.java @@ -245,18 +245,15 @@ private int outputObjectFields(Object obj, StringBuilder out) { } else { out.append(", "); } - if (info instanceof PrimitiveInfo primitiveInfo) { - primitiveInfo.output(obj, out); - } else if (info instanceof ObjectInfo objectInfo) { - out.append(objectInfo.name()).append('='); - cycleOwnerIndex = - min( - cycleOwnerIndex, - outputFingerprintOrInlinedValue(objectInfo.getFieldValue(obj), out)); - } else { - // TODO: b/297857068 - it should be possible to replace this with a pattern matching - // switch which won't require this line, but that's not yet supported. - throw new IllegalArgumentException("Unexpected FieldInfo type: " + info); + switch (info) { + case PrimitiveInfo primitiveInfo -> primitiveInfo.output(obj, out); + case ObjectInfo objectInfo -> { + out.append(objectInfo.name()).append('='); + cycleOwnerIndex = + min( + cycleOwnerIndex, + outputFingerprintOrInlinedValue(objectInfo.getFieldValue(obj), out)); + } } } return cycleOwnerIndex;