Skip to content

Match types seem to break case classes #8649

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
felixmulder opened this issue Apr 1, 2020 · 3 comments
Closed

Match types seem to break case classes #8649

felixmulder opened this issue Apr 1, 2020 · 3 comments
Assignees

Comments

@felixmulder
Copy link
Contributor

felixmulder commented Apr 1, 2020

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.

@felixmulder
Copy link
Contributor Author

Removing case from case class makes this compile

@iamrecursion
Copy link
Contributor

Hoping to get a chance to take a look at this on the weekend. @OlivierBlanvillain is it still up for grabs?

@iamrecursion
Copy link
Contributor

Life has totally got away from me recently and I've not had a chance to pick this up. If someone else wants to get to it, please don't let me stop you.

Sorry about this!

OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Jun 15, 2020
The comment in Desugar.scala doesn't apply (anymore?),
neg/t1843-variances.scala has a single error at the expected place.

The generated code for these annotations had a weird type ascription that,
I believe, cannot be written in source. Therefore this also fixes scala#8649.
OlivierBlanvillain added a commit that referenced this issue Apr 30, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue May 1, 2021
It looks like this bug got fixed in scala#11704!
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