Skip to content

Commit b973cf9

Browse files
committed
Allow some kindness in provablyDisjoint
1 parent 6fd207f commit b973cf9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,8 +2841,9 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
28412841
case (tp1: TypeRef, tp2: TypeRef) if tp1.symbol.isClass && tp2.symbol.isClass =>
28422842
val cls1 = tp1.classSymbol
28432843
val cls2 = tp2.classSymbol
2844-
def isDecomposable(sym: Symbol, tp: Type): Boolean =
2845-
tp.hasSimpleKind && sym.is(Sealed) && !sym.hasAnonymousChild
2844+
val sameKind = tp1.hasSameKindAs(tp2)
2845+
def isDecomposable(sym: Symbol): Boolean =
2846+
sameKind && sym.is(Sealed) && !sym.hasAnonymousChild
28462847
def decompose(sym: Symbol, tp: Type): List[Type] =
28472848
sym.children.map(x => refineUsingParent(tp, x)).filter(_.exists)
28482849
if (cls1.derivesFrom(cls2) || cls2.derivesFrom(cls1))
@@ -2857,13 +2858,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
28572858
// subtype, so they must be unrelated by single inheritance
28582859
// of classes.
28592860
true
2860-
else if (isDecomposable(cls1, tp1))
2861+
else if (isDecomposable(cls1))
28612862
// At this point, !cls1.derivesFrom(cls2): we know that direct
28622863
// instantiations of `cls1` (terms of the form `new cls1`) are not
28632864
// of type `tp2`. Therefore, we can safely decompose `cls1` using
28642865
// `.children`, even if `cls1` is non abstract.
28652866
decompose(cls1, tp1).forall(x => provablyDisjoint(x, tp2))
2866-
else if (isDecomposable(cls2, tp2))
2867+
else if (isDecomposable(cls2))
28672868
decompose(cls2, tp2).forall(x => provablyDisjoint(x, tp1))
28682869
else
28692870
false

0 commit comments

Comments
 (0)