Skip to content

ClassCastException with structural types, value classes #6336

Closed
@scabug

Description

@scabug

A structural type with a value class parameter throws a ClassCastException at runtime.

object D {
  def main(args: Array[String]) {
    val a = new { def y[T](x: X[T]) = x.i }
    val x = new X(3)
    val t = a.y(x)
    println(t)
  }
}
class X[T](val i: T) extends AnyVal
java.lang.ClassCastException: X cannot be cast to java.lang.Integer
	at scala.runtime.BoxesRunTime.unboxToInt(Unknown Source)
	at D$.main(D.scala:5)
	at D.main(D.scala)
{code}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions