Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unnecessary hack for HKT
Apparently it was fixed along the way.
  • Loading branch information
Aleksander Boruch-Gruszecki committed Nov 22, 2018
commit c23ff102f249a953f96ab0cef09fb1058e48a73c
8 changes: 0 additions & 8 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,6 @@ object Contexts {
res
}

def isEmptyBounds(tp: Type) = tp match {
case TypeBounds(lo, hi) => (lo eq defn.NothingType) && (hi eq defn.AnyType)
case _ => false
}

def unify(tv: TypeVar, tp: Type): Unit = {
gadts.println(i"manually unifying $tv with $tp")
constraint = constraint.updateEntry(tv.origin, tp)
Expand All @@ -843,9 +838,6 @@ object Contexts {
val res = tvarBound match {
case boundTvar: TypeVar =>
doAddBound(boundTvar)
// hack to normalize T and T[_]
case AppliedType(boundTvar: TypeVar, args) if args forall isEmptyBounds =>
doAddBound(boundTvar)
case tp => doAddBound(tp)
}

Expand Down
19 changes: 16 additions & 3 deletions tests/gadt/i5068.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ object i5068 {
final case class ReflK[F[_]]() extends IsK[F, F]

def foo[F[_], G[_]](r: F IsK G, a: Box[F]): Box[G] = r match { case ReflK() => a }
}

object i5068b {
type WeirdShape[A[_], B] = A[B]
// type WeirderShape[S[_[_], _], I, M] = Any
case class Box[ F[_[_[_], _], _, _[_]] ](value: F[WeirdShape, Int, Option])
sealed trait IsK[F[_[_[_], _], _, _[_]], G[_[_[_], _], _, _[_]]]
final case class ReflK[ F[_[_[_], _], _, _[_]] ]() extends IsK[F, F]

def foo[F[_[_[_], _], _, _[_]], G[_[_[_], _], _, _[_]]](
r: F IsK G,
a: Box[F]
): Box[G] = r match { case ReflK() => a }

def main(args: Array[String]): Unit = {
println(foo(ReflK(), Box(Option(10))))
}
// def main(args: Array[String]): Unit = {
// println(foo(ReflK(), Box[WeirderShape](???)))
// }
}