Skip to content

Match types seem to break case classes #8649

Closed
@felixmulder

Description

@felixmulder

Minimized code

// This is crazy:
type Get0 = OK[Int, Unit]
def get0: Handler[Get0] = IO[Unit]()

case class HandlerAlt[A](value: Handler[A])

type Handler[API] = handler.Go[API]

case class IO[A]()
case class OK[A, B]()

object handler:
  // Starter for Handler reduction:
  type Go[API] = API match
    case _ =>
      HandlerSingle[API]

  type HandlerSingle[X] = X match
    case OK[_, response] =>
      IO[response]

Output

[error] -- [E007] Type Mismatch Error: ./serviteur/src/main/scala/serviteur/minimized.scala:4:41 
[error] 4 |case class HandlerAlt[A](left: Handler[A])
[error]   |                                         ^
[error]   |                          Found:    (HandlerAlt.this.left : handler.Go[A])
[error]   |                          Required: handler.Go[<?>]

Expectation

🤷‍♂

Guillaume told me to put this here.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions