diff options
author | Viktor Klang <viktor.klang@gmail.com> | 2016-11-08 08:46:13 +0100 |
---|---|---|
committer | Viktor Klang <viktor.klang@gmail.com> | 2016-11-08 08:46:13 +0100 |
commit | c8e6b4e464b47bb2cd64afaf64c5249da4bbdf89 (patch) | |
tree | e81f05982a8126161290a01bbf9be09c8e40754e | |
parent | 10c609e750a7089055b126e6231e5ddb2f2e8623 (diff) | |
download | scala-c8e6b4e464b47bb2cd64afaf64c5249da4bbdf89.tar.gz scala-c8e6b4e464b47bb2cd64afaf64c5249da4bbdf89.tar.bz2 scala-c8e6b4e464b47bb2cd64afaf64c5249da4bbdf89.zip |
Regression: Make Future.failed(e).failed turn into a success instead of failure
-rw-r--r-- | src/library/scala/concurrent/impl/Promise.scala | 2 | ||||
-rw-r--r-- | test/files/jvm/future-spec/FutureTests.scala | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index 626540425f..7fcc8c9f2d 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -384,7 +384,7 @@ private[concurrent] object Promise { private[this] final def thisAs[S]: Future[S] = future.asInstanceOf[Future[S]] override def onSuccess[U](pf: PartialFunction[T, U])(implicit executor: ExecutionContext): Unit = () - override def failed: Future[Throwable] = thisAs[Throwable] + override def failed: Future[Throwable] = KeptPromise(Success(result.exception)).future override def foreach[U](f: T => U)(implicit executor: ExecutionContext): Unit = () override def map[S](f: T => S)(implicit executor: ExecutionContext): Future[S] = thisAs[S] override def flatMap[S](f: T => Future[S])(implicit executor: ExecutionContext): Future[S] = thisAs[S] diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index d0de2f5542..a1934efdd0 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -123,7 +123,7 @@ class FutureTests extends MinimalScalaTest { assert(f.mapTo[String] eq f, "Future.mapTo must be the same instance as Future.mapTo") assert(f.zip(f) eq f, "Future.zip must be the same instance as Future.zip") assert(f.flatten eq f, "Future.flatten must be the same instance as Future.flatten") - assert(f.failed eq f, "Future.failed must be the same instance as Future.failed") + assert(f.failed.value == Some(Success(e)), "Future.failed.failed must become successful") // SI-10034 ECNotUsed(ec => f.foreach(_ => fail("foreach should not have been called"))(ec)) ECNotUsed(ec => f.onSuccess({ case _ => fail("onSuccess should not have been called") })(ec)) |