Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
8258972: unexpected compilation error with generic sealed interface
Reviewed-by: jlahoda
  • Loading branch information
Vicente Romero committed Jan 7, 2021
1 parent c1fb521 commit acdd90b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -1667,11 +1667,11 @@ public boolean isCastable(Type t, Type s, Warner warn) {
}
// 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()) {
Expand Down
11 changes: 11 additions & 0 deletions test/langtools/tools/javac/sealed/SealedCompilationTests.java
Expand Up @@ -1247,6 +1247,17 @@ void m(A a, C c) {
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);
Expand Down

1 comment on commit acdd90b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.