Skip to content

Commit

Permalink
Skip ErrorTypes in Types#directSupertypes for compatibility with …
Browse files Browse the repository at this point in the history
…javac.

PiperOrigin-RevId: 715569286
  • Loading branch information
cushon authored and Javac Team committed Jan 15, 2025
1 parent 706588c commit 370011c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion java/com/google/turbine/processing/TurbineTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,10 @@ private ImmutableList<Type> directSupertypes(ClassTy t) {
builder.add(ClassTy.OBJECT);
}
for (Type interfaceType : info.interfaceTypes()) {
builder.add(raw ? erasure(interfaceType) : subst(interfaceType, mapping));
// ErrorTypes are not included in directSupertypes for compatibility with javac
if (interfaceType.tyKind() == TyKind.CLASS_TY) {
builder.add(raw ? erasure(interfaceType) : subst(interfaceType, mapping));
}
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,23 @@ public void superType() throws IOException {
assertThat(diags).containsExactly("could not resolve S", "S [S]").inOrder();
}

@Test
public void superTypeInterfaces() throws IOException {
ImmutableList<Tree.CompUnit> units =
parseUnit(
"=== T.java ===", //
"abstract class T implements NoSuch, java.util.List<String> {",
"}");
TurbineError e = runProcessors(units, new SuperTypeProcessor());
ImmutableList<String> diags =
e.diagnostics().stream().map(d -> d.message()).collect(toImmutableList());
assertThat(diags)
.containsExactly(
"could not resolve NoSuch",
"java.lang.Object [java.lang.Object, java.util.List<java.lang.String>]")
.inOrder();
}

@SupportedAnnotationTypes("*")
public static class GenerateAnnotationProcessor extends AbstractProcessor {

Expand Down

0 comments on commit 370011c

Please sign in to comment.