Skip to content

pattern matching on class with F-bounded type parameter leads to "Type argument does not conform to upper bound" error #9781

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
Sciss opened this issue Sep 13, 2020 · 0 comments · Fixed by #11599

Comments

@Sciss
Copy link
Contributor

Sciss commented Sep 13, 2020

Minimized code

trait Txn[T <: Txn[T]]

trait Elem[T <: Txn[T]]

sealed trait State[+T]
final case class Done[T <: Txn[T]](elem: Elem[T]) extends State[T]
case object Busy extends State[Nothing]

trait Test[Out <: Txn[Out]] {
  def apply(opt: Option[State[Out]]): Any = opt match {
    case Some(state) =>
      state match {
        case Done(out)  => "foo"    // problem here
        case Busy       => throw new IllegalStateException("Cyclic object graph")
      }
      
    case None => "bar"
  }
}

Output

https://scastie.scala-lang.org/KKu1hRdCSMuZONlMT8afZw

error: Type argument T$1 does not conform to upper bound Txn[LazyRef(T$1)]

Expectation

Should work ( https://scastie.scala-lang.org/r1Z7nuR2SRKc6HssuxVLJQ )

@smarter smarter changed the title pat-mat HK - Type argument does not conform to upper bound pattern matching on class with F-bounded type parameters leads to "Type argument does not conform to upper bound" error Sep 13, 2020
@smarter smarter changed the title pattern matching on class with F-bounded type parameters leads to "Type argument does not conform to upper bound" error pattern matching on class with F-bounded type parameter leads to "Type argument does not conform to upper bound" error Sep 13, 2020
liufengyun added a commit to dotty-staging/dotty that referenced this issue Mar 4, 2021
OlivierBlanvillain added a commit that referenced this issue Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants