- Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Milestone
Description
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)