Skip to content

pattern matching with given and vararg fails #21742

Closed
@sjbiaga

Description

@sjbiaga

Compiler version

3.5.2-RC1

Minimized example

case  class C(n: Int, ds: Double*)
def m(using n: Int)  = n+1
C(1, 2, 3, 4) match { case C(given Int, ds*)  => m }

Output Error/Warning message

1 |C(1, 2, 3, 4) match { case C(given Int, ds*) => m }
  |                                                 ^
  |No given instance of type Int was found for parameter n of method m
  |
  |Note: given instance given_Int was not considered because it was not imported with `import given`.
1 error found

Suggested improvement

Just as if the vararg parameter were a Seq .

case  class C(n: Int, ds: Seq[Double])
def m(using n: Int)  = n+1
C(1, Seq(2, 3, 4)) match { case C(given Int, ds)  => m }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions