Skip to content

Scala 3 case class with varargs parameter can't be constructed in Scala 2 #13126

@jadenPete

Description

@jadenPete

It would seem that case classs compiled in Scala 3 with varargs parameters can't be constructed in Scala 2, because the Scala 2 compiler thinks a Seq should be passed to the apply method instead of a dynamic number of arguments. If this is expected behavior, feel free to close this issue.

Reproduction steps

Scala 2 version: 2.13.16
Scala 3 version: 3.6.3

  1. Clone this minimum reproducability case:
    https://github.com/jadenPete/scala-varargs-bug-reproduction

  2. Run sbt compile

  3. Observe the following compilation error:

[error] .../scala-varargs-bug-reproduction/scala2/src/main/scala/Main.scala:2:63: too many arguments (found 3, expected 1) for method apply: (numbers: Seq[Int] @scala.annotation.internal.Repeated): NumberPrinter in object NumberPrinter
[error]   def main(arguments: Array[String]): Unit = NumberPrinter(1, 2, 3).print()

Problem

I'd expect this to compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions