summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-11-10 15:28:25 +1000
committerGitHub <noreply@github.com>2016-11-10 15:28:25 +1000
commitff32c8a4129b58839568c70a8ef76a52436366f5 (patch)
tree47c5de8c9b9df9acb1e1e9701fbac2a2f024ec84
parent754fc76ae21896a14982f948a014a1b71ce35708 (diff)
parentc8e6b4e464b47bb2cd64afaf64c5249da4bbdf89 (diff)
downloadscala-ff32c8a4129b58839568c70a8ef76a52436366f5.tar.gz
scala-ff32c8a4129b58839568c70a8ef76a52436366f5.tar.bz2
scala-ff32c8a4129b58839568c70a8ef76a52436366f5.zip
Merge pull request #5507 from viktorklang/wip-SI-10034-√
SI-10034: Regression: Make Future.failed(e).failed turn into a success instead of failure
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala2
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala2
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))