Skip to content

Pattern matching on Foo[F[_]] where F is a type alias with phantom type parameter doesn't work #10195

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

Closed
scabug opened this issue Feb 17, 2017 · 1 comment
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Feb 17, 2017

The smallest example I was able to distill involves a type lambda:

sealed trait Foo[F[_]]
case class Bar[F[_]]() extends Foo[F]

object Test {

  val foo: Foo[({ type Out[X] = String })#Out] = ???

  foo match {
    case Bar() => // error: constructor cannot be instantiated to expected type
                  //  found   : Bar[F]
                  //  required: Foo[[X]String]
  }
}

It is reproducible also without type lambdas, but the example is slightly more involved (some simpler cases do work):

sealed trait Foo[F[_]]
case class Bar[F[_]]() extends Foo[F]

trait TC[A, B] {
  type F[X] = B
}

object TC {
  implicit val intInstance: TC[Int, String] =
    new TC[Int, String] {}

  implicit class Ops[A, B](a: A)(implicit val tc: TC[A, B]) {
    def getFoo: Foo[tc.F] = ???
  }

  1.getFoo match {
    case Bar() => // error: constructor cannot be instantiated to expected type
                  //  found   : Bar[F]
                  //  required: Foo[[X]String]
  }
}

In both cases, it seems it got the shape of type arguments right, but doesn't unify F[_] with [X]String.

@scabug
Copy link
Author

scabug commented Feb 17, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10195?orig=1
Reporter: Tomas Mikula (tomas.mikula-at-gmail.com)
Affected Versions: 2.12.1

@scabug scabug added the patmat label Apr 7, 2017
TomasMikula added a commit to TomasMikula/scala that referenced this issue Sep 27, 2017
Can cause ambiguous implicits, so is under the compiler flag
-Xsource:2.13

Fixes scala/bug#10185
Fixes scala/bug#10195
Fixes scala/bug#10197
Fixes scala/bug#10213
Fixes scala/bug#10238
Fixes scala/bug#10372
Presents an alternative fix to scala/bug#6895.
TomasMikula added a commit to TomasMikula/scala that referenced this issue Sep 27, 2017
Can cause ambiguous implicits, so is under the compiler flag
-Xsource:2.13

Fixes scala/bug#10185
Fixes scala/bug#10195
Fixes scala/bug#10197
Fixes scala/bug#10213
Fixes scala/bug#10238
Fixes scala/bug#10372
Presents an alternative fix to scala/bug#6895.
TomasMikula added a commit to TomasMikula/scala that referenced this issue Sep 28, 2017
Can cause ambiguous implicits, so is under the compiler flag
-Xsource:2.13

Fixes scala/bug#10185
Fixes scala/bug#10195
Fixes scala/bug#10197
Fixes scala/bug#10213
Fixes scala/bug#10238
Fixes scala/bug#10372
Presents an alternative fix to scala/bug#6895.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants