diff options
author | Philipp Haller <hallerp@gmail.com> | 2012-02-03 10:07:07 +0100 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2012-02-03 10:07:07 +0100 |
commit | ce0bfa62aa18f2b153aa5690ed34bf05f71bb7eb (patch) | |
tree | 65435912989f255c373c94f502f8a426d7c9afee | |
parent | 14bf00cda4922b778e2df72299a2a4e8fb2fd42b (diff) | |
download | scala-ce0bfa62aa18f2b153aa5690ed34bf05f71bb7eb.tar.gz scala-ce0bfa62aa18f2b153aa5690ed34bf05f71bb7eb.tar.bz2 scala-ce0bfa62aa18f2b153aa5690ed34bf05f71bb7eb.zip |
Fix typo in Future trait. Simplify recoverWith.
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 3650e44261..73f76bbbfb 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -327,7 +327,7 @@ self => * * {{{ * val f = future { Int.MaxValue } - * future (6 / 0) rescue { case e: ArithmeticException => f } // result: Int.MaxValue + * future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue * }}} */ def recoverWith[U >: T](pf: PartialFunction[Throwable, Future[U]]): Future[U] = { @@ -336,10 +336,7 @@ self => onComplete { case Failure(t) if pf isDefinedAt t => try { - pf(t) onComplete { - case Failure(t) => p failure t - case Success(v) => p success v - } + p completeWith pf(t) } catch { case t: Throwable => p complete resolver(t) } |