You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C:\Users\Sepi>scala
Welcome to Scala2.13.0-M5 (JavaHotSpot(TM) 64-BitServerVM, Java1.8.0_60).
Type in expressions for evaluation. Ortry:help.
scala>importscala.util._importscala.util._
scala>:paste
// Entering paste mode (ctrl-D to finish)vale:Try[Int] =Failure(newException("dfd"))
valpf:PartialFunction[Throwable, Int] = {
case_: RuntimeException=>1
}
vale2= e.recoverWith(pf.andThen(Try(_)))
println(e2)
// Exiting paste mode, now interpreting.Failure(java.lang.ClassCastException: java.lang.Object cannot be cast to scala.util.Try)
e: scala.util.Try[Int] =Failure(java.lang.Exception: dfd)
pf:PartialFunction[Throwable,Int] = <function1>
e2: scala.util.Try[Int] =Failure(java.lang.ClassCastException: java.lang.Object cannot be cast to scala.util.Try)
On 2.12.6:
C:\Users\Sepi>scala
Welcome to Scala2.12.6 (JavaHotSpot(TM) 64-BitServerVM, Java1.8.0_60).
Type in expressions for evaluation. Ortry:help.
scala>importscala.util._importscala.util._
scala>:paste
// Entering paste mode (ctrl-D to finish)vale:Try[Int] =Failure(newException("dfd"))
valpf:PartialFunction[Throwable, Int] = {
case_: RuntimeException=>1
}
vale2= e.recoverWith(pf.andThen(Try(_)))
println(e2)
// Exiting paste mode, now interpreting.Failure(java.lang.Exception: dfd)
e: scala.util.Try[Int] =Failure(java.lang.Exception: dfd)
pf:PartialFunction[Throwable,Int] = <function1>
e2: scala.util.Try[Int] =Failure(java.lang.Exception: dfd)
Note that 2.13.0-M5 has thrown a ClassCastException, and it has been swallowed by the Try as Failure(ClassCastException). 2.12.6 correctly reports a Failure(Exception).
See scala-js/scala-js#3480 (comment)
On 2.13.0-M5:
On 2.12.6:
Note that 2.13.0-M5 has thrown a
ClassCastException
, and it has been swallowed by theTry
asFailure(ClassCastException)
. 2.12.6 correctly reports aFailure(Exception)
.That's because
Failure.recoverWith
is broken. It should be something like:The text was updated successfully, but these errors were encountered: