8258972: unexpected compilation error with generic sealed interface

Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2021-01-07 16:38:53 +00:00
parent c1fb521694
commit acdd90b699
2 changed files with 13 additions and 2 deletions

View File

@ -1667,11 +1667,11 @@ public class Types {
}
// where
private boolean areDisjoint(ClassSymbol ts, ClassSymbol ss) {
if (isSubtype(ts.type, ss.type)) {
if (isSubtype(erasure(ts.type), erasure(ss.type))) {
return false;
}
// if both are classes or both are interfaces, shortcut
if (ts.isInterface() == ss.isInterface() && isSubtype(ss.type, ts.type)) {
if (ts.isInterface() == ss.isInterface() && isSubtype(erasure(ss.type), erasure(ts.type))) {
return false;
}
if (ts.isInterface() && !ss.isInterface()) {

View File

@ -1247,6 +1247,17 @@ public class SealedCompilationTests extends CompilationTestCase {
a = (A)c;
}
}
""",
"""
sealed interface A<T> {
final class B implements A<Object> { }
}
class Test {
void f(A.B a, A<Object> b) {
a = (A.B)b;
}
}
"""
)) {
assertOK(s);