Skip to content

Commit

Permalink
Expect crash due to javac bug
Browse files Browse the repository at this point in the history
  • Loading branch information
smillst authored Oct 18, 2024
1 parent 19419ac commit cfdd5c9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,20 @@ protected boolean isContainedBy(
if (canBeCovariant) {
return isSubtype(inside, outside, currentTop);
}
return areEqualInHierarchy(inside, outside);

try {
return areEqualInHierarchy(inside, outside);
} catch (Exception e) {
// Ignore exception and try capturing.
// See https://github.com/typetools/checker-framework/issues/6867.
// https://bugs.openjdk.org/browse/JDK-8054309
}
AnnotatedTypeMirror capturedOutside = outside.atypeFactory.applyCaptureConversion(outside);
previousResult = areEqualVisitHistory.get(inside, capturedOutside, currentTop);
if (previousResult != null) {
return previousResult;
}
return areEqualInHierarchy(inside, capturedOutside);
}

/**
Expand Down
12 changes: 12 additions & 0 deletions framework/tests/all-systems/Issue6867.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class Issue6867 {
interface A<T extends Number> {}

static class B<T extends A<? super Integer>> {}

void main(B<A<Number>> b) {
@SuppressWarnings("super.wildcard") // This is a true positive.
// This code is rejected by Eclipse and IntelliJ's presentation compiler. It's a bug in javac.
// https://bugs.openjdk.org/browse/JDK-8054309
B<A<? super Number>> x = b;
}
}

0 comments on commit cfdd5c9

Please sign in to comment.