Skip to content

Array[A[Int]] where A[_] is an abstract type member causes ClassCastException at runtime #22888

Closed
@albertpchen

Description

@albertpchen

Compiler version

3.6.3

Minimized code

trait Foo:
  type A[T]
  var arr: Array[A[Int]] = null

class Bar() extends Foo:
  type A[T] = Int

object Main:
  def main(args: Array[String]) =
    val bar = new Bar()
    bar.arr = Array.ofDim[Int](1)
    bar.arr(0) = 123

Output

Exception in thread "main" java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [I ([Ljava.lang.Object; and [I are in module java.base of loader 'bootstrap')

Expectation

It should run without crashing

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:typeritype:bugitype:soundnessSoundness bug (it lets us compile code that crashes at runtime with a ClassCastException)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions