Skip to content

Unsoundness due to erased #4060

@sir-wabbit

Description

@sir-wabbit

Related to #50 #4042 #4031.

object App { def coerce[U, V](u: U): V = { trait X { type R >: U } trait Y { type R = V } class T[A <: X](ghost val a: A)(val value: a.R) object O { lazy val x : Y & X = ??? } val a = new T[Y & X](O.x)(u) a.value } def main(args: Array[String]): Unit = { val x: Int = coerce[String, Int]("a") println(x + 1) } } ////////////////////////////////////////////////////////////// Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer	at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:101)	at App$.main(HelloWorld.scala:15)	at App.main(HelloWorld.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions