Skip to content

Match type on type alias with multiple parameters fails #22644

Open
@kavedaa

Description

@kavedaa

Compiler version

3.6.3, Scala 3.7.0-RC1-bin-20250222-4dc4668-NIGHTLY

Minimized code

package bug

object ExhibitA:

  trait Foo:
    type A
    type B

  type F[X, Y] = Foo { type A = X; type B = Y }

  //  fails
  type M[T] = T match
    case F[a, b] => (a, b)

  trait Bar extends Foo { type A = Int; type B = String }

  summon[M[Bar] =:= (Int, String)]


object ExhibitB:

  trait Foo:
    type A
    
  type F[X] = Foo { type A = X }

  //  works
  type M[T] = T match
    case F[a] => a

  trait Bar extends Foo { type A = Int }

  summon[M[Bar] =:= Int]

Output

[error] .\bug.scala:14:15
[error] The match type contains an illegal case:
[error]     case bug.ExhibitA.F[a, b] => (a, b)
[error] The pattern contains a type alias `F`.
[error] (this error can be ignored for now with `-source:3.3`)

Expectation

Successful compilation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions