Skip to content

GADT pattern matching produces conformance constraints instead of equality (HKTs) #5068

Closed
@sir-wabbit

Description

@sir-wabbit
object App {
  case class Box[F[_]](value: F[Int])
  sealed trait IsK[F[_], G[_]]
  final case class ReflK[F[_]]() extends IsK[F, F]

  def foo[F[_], G[_]](r: F IsK G, a: Box[F]): Box[G] = r match { case ReflK() => a }
  
  def main(args: Array[String]): Unit = {
    println(foo(ReflK(), Box(Option(10))))
  }
}
-- [E007] Type Mismatch Error: foo.scala:6:81 ----------------------------------
6 |  def foo[F[_], G[_]](r: F IsK G, a: Box[F]): Box[G] = r match { case ReflK() => a }
  |                                                                                 ^
  |                   found:    App.Box[F](a)
  |                   required: App.Box[G]
  |                   
  |                   where:    F is a type in method foo with bounds <: G[_]
  |                             G is a type in method foo with bounds <: F[_]
one error found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions