Skip to content

Commit

Permalink
Use .superType instead of .underlying
Browse files Browse the repository at this point in the history
Underlying breaks kinds (the underlying of an AppliedType is a HKTypeLambda).
The edited test case was making use of that bug to implement an
impossible match type. Indeed, that test is trying to distinguish

f[Dummy] (for some f)

and

Int

But there is no way to tell that these two types are disjoint.  In fact
they are not, since `type F[X] = Any` matches the `f[Dummy]` pattern and
overlaps with `Int`.
  • Loading branch information
OlivierBlanvillain committed Dec 15, 2020
1 parent 4d4296e commit 51c4f85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2508,11 +2508,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
!(tp2 <:< tp1)
&& (provablyDisjoint(tp1, tp2.tp2) || provablyDisjoint(tp1, tp2.tp1))
case (tp1: TypeProxy, tp2: TypeProxy) =>
provablyDisjoint(tp1.underlying, tp2) || provablyDisjoint(tp1, tp2.underlying)
provablyDisjoint(tp1.superType, tp2) || provablyDisjoint(tp1, tp2.superType)
case (tp1: TypeProxy, _) =>
provablyDisjoint(tp1.underlying, tp2)
provablyDisjoint(tp1.superType, tp2)
case (_, tp2: TypeProxy) =>
provablyDisjoint(tp1, tp2.underlying)
provablyDisjoint(tp1, tp2.superType)
case _ =>
false
}
Expand Down
6 changes: 3 additions & 3 deletions tests/run-macros/tasty-simplified.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Functor[[A >: scala.Nothing <: scala.Any] => scala.collection.immutable.List[A]]
Functor[Const[scala.collection.immutable.List[Dummy]]]
Functor[Const[scala.Int]]
Functor[Id]
Functor[[A >: scala.Nothing <: scala.Any] => scala.Option[A]]
Functor[Const[Dummy]]
Functor[Const[scala.Option[Dummy]]]

0 comments on commit 51c4f85

Please sign in to comment.