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

Pattern matching on Foo[A, F[_ <: A]] doesn't compile #10185

Closed
scabug opened this issue Feb 13, 2017 · 1 comment
Closed

Pattern matching on Foo[A, F[_ <: A]] doesn't compile #10185

scabug opened this issue Feb 13, 2017 · 1 comment
Assignees

Comments

@scabug
Copy link

scabug commented Feb 13, 2017

sealed trait Foo[A, F[_ <: A]]
case class Bar[A, F[_ <: A]]() extends Foo[A, F]

class F[S <: String]

object Test {
  def f(foo: Foo[String, F]): Unit = foo match {
    case Bar() => ()
  }
}

REPL output:

$ ~/scala-2.12.1/bin/scala
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala> :paste
// Entering paste mode (ctrl-D to finish)

import scala.language.higherKinds

sealed trait Foo[A, F[_ <: A]]
case class Bar[A, F[_ <: A]]() extends Foo[A, F]

class F[S <: String]

object Test {
  def f(foo: Foo[String, F]): Unit = foo match {
    case Bar() => ()
  }
}

// Exiting paste mode, now interpreting.

<console>:20: error: constructor cannot be instantiated to expected type;
 found   : Bar[A,F(in class Bar)]
 required: Foo[String,F(in object $iw)]
           case Bar() => ()
                ^

scala> 

This might be related to #9394, but this one is more complicated (involves a higher-kinded type parameter with upper bounded parameter) and workarounds proposed in #9394 do not apply.

@scabug
Copy link
Author

scabug commented Feb 13, 2017

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

@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.
TomasMikula added a commit to TomasMikula/scala that referenced this issue Sep 29, 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
Projects
None yet
Development

No branches or pull requests

2 participants