Skip to content
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

Chaining Match Types fails at value level #12477

Closed
ThijsBroersen opened this issue Oct 31, 2021 · 1 comment
Closed

Chaining Match Types fails at value level #12477

ThijsBroersen opened this issue Oct 31, 2021 · 1 comment

Comments

@ThijsBroersen
Copy link

ThijsBroersen commented Oct 31, 2021

reproduction steps

using Scala 3.1.0,

type A[X] = X match
  case Int => Int
  case _   => B[X]

def a[X](x: X): A[X] = x match
  case v: Int => v
  case _      => b(x)

type B[X] = X match
  case String => String

def b[X](x: X): B[X] = x match
  case v: String => v

problem

fails to compile:

Found:    (v : X & Int)
Required: Playground.A[X]
Found:    Playground.B[X]
Required: Playground.A[X]

with some casts it works:

type A[X] = X match
  case Int => Int
  case _   => B[X]

def a[X](x: X): A[X] = (x match
  case v: Int => v
  case _      => b(x)
).asInstanceOf[A[X]]

type B[X] = X match
  case String => String

def b[X](x: X): B[X] = x match
  case v: String => v
@ThijsBroersen
Copy link
Author

ThijsBroersen commented Oct 31, 2021

will move the issue to the dotty repo
scala/scala3#13855

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant