- Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Milestone
Description
Similar to #4031. Derived from this gist, which works in Scala2.
objectApp{defcoerce[U, V](u: U):V={traitX{typeR>:U } traitY{typeR=V } classT[A<:X](vala:A)(valvalue: a.R) objectO{valx:Y&X= x } vala=newT[Y&X](O.x)(u) a.value } defmain(args: Array[String]):Unit={valx: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)Tested on the most recent master branch.