Skip to content

pass Array[String with Int] to Scala 2 causes ClassCastException #12203

Open
@bishabosha

Description

@bishabosha

Compiler version

3.0.0-RC2 (depending on 2.13.5)

Minimized code

// compile with Scala 2.13.5
package scala2Erasure

class Z {
  def stringARRAY_131(x: Array[String with Int]): Unit = {}
}
// compile with 3.0.0-RC2
@main def Test =
  val z = new scala2Erasure.Z
  z.stringARRAY_131(new Array(10))

Output

Exception in thread "main" java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.String;
	at test$package$.Test(test.scala:3)
	at Test.main(test.scala:1)

Expectation

maybe error on constructing the array?

Note

The erasure difference is expected because Scala 3 will prioritise primitive classes over reference classes in intersection erasure

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