diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index e04f3f2c6523..62b06aea39a7 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -2449,8 +2449,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling decompose(cls2, tp2).forall(x => provablyDisjoint(x, tp1)) else false - case (AppliedType(tycon1, args1), AppliedType(tycon2, args2)) - if tycon1.typeSymbol == tycon2.typeSymbol && tycon1 =:= tycon2 => + case (AppliedType(tycon1, args1), AppliedType(tycon2, args2)) if isSame(tycon1, tycon2) => // It is possible to conclude that two types applies are disjoint by // looking at covariant type parameters if the said type parameters // are disjoin and correspond to fields. @@ -2520,6 +2519,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType) case (tp1: TermRef, tp2: TermRef) if isEnumValueOrModule(tp1) && isEnumValueOrModule(tp2) => tp1.termSymbol != tp2.termSymbol + case (tp1: Type, tp2: Type) if defn.isTupleType(tp1) => + provablyDisjoint(tp1.toNestedPairs, tp2) + case (tp1: Type, tp2: Type) if defn.isTupleType(tp2) => + provablyDisjoint(tp1, tp2.toNestedPairs) case (tp1: TypeProxy, tp2: TypeProxy) => provablyDisjoint(tp1.superType, tp2) || provablyDisjoint(tp1, tp2.superType) case (tp1: TypeProxy, _) => diff --git a/tests/pos/9871.scala b/tests/pos/9871.scala new file mode 100644 index 000000000000..e5e2a9aded4c --- /dev/null +++ b/tests/pos/9871.scala @@ -0,0 +1,10 @@ +object Test { + type IsTypeInTuple[T, Tup <: Tuple] = Tup match { + case EmptyTuple => false + case T *: ts => true + case _ *: ts => IsTypeInTuple[T, ts] + } + summon[(Int *: String *: EmptyTuple) =:= (Int, String)] //they are the same + summon[IsTypeInTuple[String, Int *: String *: EmptyTuple] =:= true] //compiles + summon[IsTypeInTuple[String, (Int, String)] =:= true] //doesn't compile +}