-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
In the following the, pattern matches should refine F
to List
,
object HKGADT {
sealed trait Foo[F[_]]
final case class Bar() extends Foo[List]
def frob[F[_]](foo: Foo[F]): F[Int] =
foo match {
case Bar() => // dotc accepts the pattern, scalac doesn't.
List(1) // both dotc and scalac error here
}
sealed trait Foo1[F]
final case class Bar1() extends Foo1[Int]
def frob1[A](foo: Foo1[A]) = foo match {
case Bar1() => 1 // alles klar in scalac, dotc
}
}
It doesn't because of this defensive move ... according to @retronym this,
does not treat
F
in the type of the scrutinee of the match as a free type param, which is needed to allow the constructor pattern of typeFoo[List]
to be allowed.
It turns out that this exclusion is overly conservative and the bug it was originally introduced to avoid was later fixed independently in this commit.