diff options
author | James Iry <jamesiry@gmail.com> | 2013-12-05 10:01:00 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-12-05 10:01:00 -0800 |
commit | 7d748846901feb098b9e3f46dd96d93201495a20 (patch) | |
tree | 6231ae8dfb3a0c2c9b4a0f7cfcac22b4858ec747 | |
parent | 7c1d1149291e1b83c96a0f6954144b9e97c030ea (diff) | |
parent | 70634395a4ea6e05877704e655a5870692581ebc (diff) | |
download | scala-7d748846901feb098b9e3f46dd96d93201495a20.tar.gz scala-7d748846901feb098b9e3f46dd96d93201495a20.tar.bz2 scala-7d748846901feb098b9e3f46dd96d93201495a20.zip |
Merge pull request #3181 from heathermiller/issue/6913
SI-6913 Reapplies a lost fix by @viktorklang
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 5 | ||||
-rw-r--r-- | test/files/jvm/future-spec/PromiseTests.scala | 4 | ||||
-rw-r--r-- | test/files/jvm/scala-concurrent-tck.scala | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 39946e4472..b2c09ec53e 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -384,7 +384,10 @@ trait Future[+T] extends Awaitable[T] { val p = Promise[U]() onComplete { case s @ Success(_) => p complete s - case _ => p completeWith that + case f @ Failure(_) => that onComplete { + case s2 @ Success(_) => p complete s2 + case _ => p complete f // Use the first failure as the failure + } } p.future } diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala index 8e07393900..48f94666ba 100644 --- a/test/files/jvm/future-spec/PromiseTests.scala +++ b/test/files/jvm/future-spec/PromiseTests.scala @@ -38,10 +38,10 @@ object PromiseTests extends MinimalScalaTest { Await.result(failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") Await.result(timedOut fallbackTo empty, defaultTimeout) mustBe ("Timedout") - Await.result(failure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") + Await.result(otherFailure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") intercept[RuntimeException] { Await.result(failure fallbackTo otherFailure, defaultTimeout) - }.getMessage mustBe ("last") + }.getMessage mustBe ("br0ken") } } diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index 6e2b8ca033..a306a7d15b 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -344,8 +344,8 @@ def testTransformFailure(): Unit = once { def testFallbackToFailure(): Unit = once { done => val cause = new Exception - val f = future { sys.error("failed") } - val g = future { throw cause } + val f = future { throw cause } + val g = future { sys.error("failed") } val h = f fallbackTo g h onSuccess { case _ => done(false) } |