Skip to content

Nested type parameter in case of match type prevent subsequent cases from being reached #8647

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
smarter opened this issue Apr 1, 2020 · 0 comments

Comments

@smarter
Copy link
Member

smarter commented Apr 1, 2020

This works:

final class Two[A, B]()

final class Bla

object Test {

  type Foo[X] = X match
    case Two[Bla, _] =>
      String
    case Two[String, _] =>
      Int

  def test: Foo[Two[String, String]] = 1
}

But if I add a type parameter to Bla, then it doesn't work anymore:

final class Two[A, B]()

final class Bla[A]

object Test {

  type Foo[X] = X match
    case Two[Bla[_], _] =>
      String
    case Two[String, _] =>
      Int

  def test: Foo[Two[String, String]] = 1
}
-- [E007] Type Mismatch Error: try/i8644.scala:28:39 ---------------------------
28 |  def test: Foo[Two[String, String]] = 1
   |                                       ^
   |                                 Found:    (1 : Int)
   |                                 Required: Test.Foo[Two[String, String]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants