Skip to content

Commit

Permalink
Prepare for the removal of TypeTag.UNKNOWN
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cushon authored and Error Prone Team committed Oct 28, 2024
1 parent 9ab5858 commit d67bc15
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1299,15 +1299,17 @@ public static boolean isVoidType(Type type, VisitorState state) {
}

private static final ImmutableSet<TypeTag> 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();
Expand Down

0 comments on commit d67bc15

Please sign in to comment.