@@ -2841,8 +2841,9 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2841
2841
case (tp1 : TypeRef , tp2 : TypeRef ) if tp1.symbol.isClass && tp2.symbol.isClass =>
2842
2842
val cls1 = tp1.classSymbol
2843
2843
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
2846
2847
def decompose (sym : Symbol , tp : Type ): List [Type ] =
2847
2848
sym.children.map(x => refineUsingParent(tp, x)).filter(_.exists)
2848
2849
if (cls1.derivesFrom(cls2) || cls2.derivesFrom(cls1))
@@ -2857,13 +2858,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2857
2858
// subtype, so they must be unrelated by single inheritance
2858
2859
// of classes.
2859
2860
true
2860
- else if (isDecomposable(cls1, tp1 ))
2861
+ else if (isDecomposable(cls1))
2861
2862
// At this point, !cls1.derivesFrom(cls2): we know that direct
2862
2863
// instantiations of `cls1` (terms of the form `new cls1`) are not
2863
2864
// of type `tp2`. Therefore, we can safely decompose `cls1` using
2864
2865
// `.children`, even if `cls1` is non abstract.
2865
2866
decompose(cls1, tp1).forall(x => provablyDisjoint(x, tp2))
2866
- else if (isDecomposable(cls2, tp2 ))
2867
+ else if (isDecomposable(cls2))
2867
2868
decompose(cls2, tp2).forall(x => provablyDisjoint(x, tp1))
2868
2869
else
2869
2870
false
0 commit comments