Skip to content

Class cast exception on inlined varargs #6858

Closed
@nicolasstucki

Description

@nicolasstucki

Minimized code

object Test extends App {
  inline def foo(ys: Int*): Unit = Array(ys: _*)
  val xs = new Array[Int](3)
  foo(xs: _*)
}

fails with

Caused by: java.lang.ClassCastException: [I cannot be cast to scala.collection.Seq
	at Test$.<init>(foo.scala:5)
	at Test$.<clinit>(foo.scala)
	... 7 more

but adding an explicit type to xs makes it work

val xs: scala.collection.Seq[Int] = new Array[Int](3)

Expectation

The code should work

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions