Skip to content
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

Higher kinded type arguments not refined by GADT pattern matching #9760

Closed
scabug opened this issue Apr 19, 2016 · 4 comments
Closed

Higher kinded type arguments not refined by GADT pattern matching #9760

scabug opened this issue Apr 19, 2016 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 19, 2016

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 type Foo[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.

@scabug
Copy link
Author

scabug commented Apr 19, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9760?orig=1
Reporter: @milessabin
Affected Versions: 2.10.6, 2.11.8, 2.12.0-M4
Other Milestones: 2.12.0-M5

@scabug
Copy link
Author

scabug commented Apr 19, 2016

@milessabin said:
PR here.

@scabug scabug closed this as completed May 24, 2016
@scabug
Copy link
Author

scabug commented Aug 26, 2016

@milessabin said:
Fix backported to 2.11.8 available here.

@scabug
Copy link
Author

scabug commented Oct 18, 2016

@adriaanm said:
scala/scala#5341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants