From d67bc156b737d13ac693d73a403a11a97804423f Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Mon, 28 Oct 2024 08:16:13 -0700 Subject: [PATCH] Prepare for the removal of `TypeTag.UNKNOWN` The constant was removed as part of https://bugs.openjdk.org/browse/JDK-8339296 This is a minimal fix to avoid breaking for upcoming javac versions. I suspect this logic isn't actually necessary, we aren't supposed to process ASTs with errors and there have been a variety of improvements in how that's handled since this was added. PiperOrigin-RevId: 690616927 --- .../main/java/com/google/errorprone/util/ASTHelpers.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java b/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java index 2c52c2a3140..1491b4dbd81 100644 --- a/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java +++ b/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java @@ -1299,15 +1299,17 @@ public static boolean isVoidType(Type type, VisitorState state) { } private static final ImmutableSet SUBTYPE_UNDEFINED = - Sets.immutableEnumSet( - TypeTag.METHOD, TypeTag.PACKAGE, TypeTag.UNKNOWN, TypeTag.ERROR, TypeTag.FORALL); + Sets.immutableEnumSet(TypeTag.METHOD, TypeTag.PACKAGE, TypeTag.ERROR, TypeTag.FORALL); /** Returns true if {@code erasure(s) <: erasure(t)}. */ public static boolean isSubtype(Type s, Type t, VisitorState state) { if (s == null || t == null) { return false; } - if (SUBTYPE_UNDEFINED.contains(s.getTag()) || SUBTYPE_UNDEFINED.contains(t.getTag())) { + if (SUBTYPE_UNDEFINED.contains(s.getTag())) { + return false; + } + if (t == state.getSymtab().unknownType) { return false; } Types types = state.getTypes();