Skip to content

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

Closed
@smarter

Description

@smarter

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]]

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions