Skip to content

Nonunified types in GADT pattern match #15554

Closed
@Swoorup

Description

@Swoorup

Compiler version

3.1.3

Minimized code

enum PingMessage[Response]:
  case Ping(from: String) extends PingMessage[String]

val pongBehavior: [O] => (Unit, PingMessage[O]) => (Unit, O) = [O] =>
  (state: Unit, msg: PingMessage[O]) =>
    msg match
      case PingMessage.Ping(from) => ((), s"Pong from $from")

Scastie: https://scastie.scala-lang.org/omCKwdwSQ2uGyiYSPRbOLQ

Output

Found:    [O] => (Unit, PingMessage[O]) => (Unit, String)
Required: [O] => (Unit, PingMessage[O²]) => (Unit, O²)

where:    O  is a type variable
          O² is a type variable

Expectation

Compiles successfully

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions