Skip to content

Fix #9871: use toNestedPairs in provablyDisjoint #10560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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, _) =>
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/9871.scala
Original file line number Diff line number Diff line change
@@ -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
}