Skip to content

Recursive match type fails to type check #8313

@mpilquist

Description

@mpilquist

minimized code

scala> type I[A <: Tuple] <: Tuple = A match {
     |   case Unit => Unit
     |   case hd *: tl => hd *: I[tl]
     | }

scala> (1, 2): I[(Int, Int)]
val res4: (Int, Int) = (1,2)

scala> type DU[A <: Tuple] <: Tuple = A match {
     |   case Unit => Unit
     |   case Unit *: tl => DU[tl]
     |   case hd *: tl => hd *: DU[tl]
     | }

scala> (1, 2): DU[(Int, Int)]
1 |(1, 2): DU[(Int, Int)]
  |^^^^^^
  |Found:    (Int, Int)
  |Required: DU[(Int, Int)]

expectation

DU[(Int, Int)] should expand to (Int, Int) but doesn't. Only difference between DU and I (which works), is the Unit *: tl case.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions