From aac015a84c2d64ce485078a5a854bc7533e2fc7b Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Fri, 8 Nov 2013 15:59:04 +0100 Subject: SI-7958 Deprecate methods `future` and `promise` in the `scala.concurrent` package object - The corresponding `apply` methods in the `Future` and `Promise` objects should be used instead. - Adjusted tests to use non-deprecated versions - Fixed doc comments not to use deprecated methods - Added comment about planned removal in 2.13.0 --- src/library/scala/concurrent/Future.scala | 28 ++--- src/library/scala/concurrent/package.scala | 4 + test/files/jvm/future-spec/FutureTests.scala | 46 ++++---- test/files/jvm/scala-concurrent-tck.scala | 116 ++++++++++----------- test/files/pos/t2484.scala | 2 +- .../files/run/macro-duplicate/Impls_Macros_1.scala | 2 +- test/files/run/t6448.scala | 2 +- test/files/run/t7775.scala | 4 +- test/files/run/t7805-repl-i.scala | 2 +- 9 files changed, 105 insertions(+), 101 deletions(-) diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index b9f73c2872..dd86af0dd4 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -29,11 +29,11 @@ import scala.reflect.ClassTag /** The trait that represents futures. * - * Asynchronous computations that yield futures are created with the `future` call: + * Asynchronous computations that yield futures are created with the `Future` call: * * {{{ * val s = "Hello" - * val f: Future[String] = future { + * val f: Future[String] = Future { * s + " future!" * } * f onSuccess { @@ -67,8 +67,8 @@ import scala.reflect.ClassTag * Example: * * {{{ - * val f = future { 5 } - * val g = future { 3 } + * val f = Future { 5 } + * val g = Future { 3 } * val h = for { * x: Int <- f // returns Future(5) * y: Int <- g // returns Future(3) @@ -266,7 +266,7 @@ trait Future[+T] extends Awaitable[T] { * * Example: * {{{ - * val f = future { 5 } + * val f = Future { 5 } * val g = f filter { _ % 2 == 1 } * val h = f filter { _ % 2 == 0 } * Await.result(g, Duration.Zero) // evaluates to 5 @@ -291,7 +291,7 @@ trait Future[+T] extends Awaitable[T] { * * Example: * {{{ - * val f = future { -5 } + * val f = Future { -5 } * val g = f collect { * case x if x < 0 => -x * } @@ -314,9 +314,9 @@ trait Future[+T] extends Awaitable[T] { * Example: * * {{{ - * future (6 / 0) recover { case e: ArithmeticException => 0 } // result: 0 - * future (6 / 0) recover { case e: NotFoundException => 0 } // result: exception - * future (6 / 2) recover { case e: ArithmeticException => 0 } // result: 3 + * Future (6 / 0) recover { case e: ArithmeticException => 0 } // result: 0 + * Future (6 / 0) recover { case e: NotFoundException => 0 } // result: exception + * Future (6 / 2) recover { case e: ArithmeticException => 0 } // result: 3 * }}} */ def recover[U >: T](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Future[U] = { @@ -334,8 +334,8 @@ trait Future[+T] extends Awaitable[T] { * Example: * * {{{ - * val f = future { Int.MaxValue } - * future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue + * val f = Future { Int.MaxValue } + * Future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue * }}} */ def recoverWith[U >: T](pf: PartialFunction[Throwable, Future[U]])(implicit executor: ExecutionContext): Future[U] = { @@ -373,8 +373,8 @@ trait Future[+T] extends Awaitable[T] { * * Example: * {{{ - * val f = future { sys.error("failed") } - * val g = future { 5 } + * val f = Future { sys.error("failed") } + * val g = Future { 5 } * val h = f fallbackTo g * Await.result(h, Duration.Zero) // evaluates to 5 * }}} @@ -416,7 +416,7 @@ trait Future[+T] extends Awaitable[T] { * The following example prints out `5`: * * {{{ - * val f = future { 5 } + * val f = Future { 5 } * f andThen { * case r => sys.error("runtime exception") * } andThen { diff --git a/src/library/scala/concurrent/package.scala b/src/library/scala/concurrent/package.scala index 2fe14a9c1a..cc1350f5a9 100644 --- a/src/library/scala/concurrent/package.scala +++ b/src/library/scala/concurrent/package.scala @@ -27,6 +27,8 @@ package object concurrent { * @param executor the execution context on which the future is run * @return the `Future` holding the result of the computation */ + @deprecated("Use `Future { ... }` instead.", "2.11.0") + // removal planned for 2.13.0 def future[T](body: =>T)(implicit @deprecatedName('execctx) executor: ExecutionContext): Future[T] = Future[T](body) /** Creates a promise object which can be completed with a value or an exception. @@ -34,6 +36,8 @@ package object concurrent { * @tparam T the type of the value in the promise * @return the newly created `Promise` object */ + @deprecated("Use `Promise[T]()` instead.", "2.11.0") + // removal planned for 2.13.0 def promise[T](): Promise[T] = Promise[T]() /** Used to designate a piece of code which potentially blocks, allowing the current [[BlockContext]] to adjust diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index 1595b2c862..cfdcc31ac5 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -15,7 +15,7 @@ class FutureTests extends MinimalScalaTest { /* some utils */ def testAsync(s: String)(implicit ec: ExecutionContext): Future[String] = s match { - case "Hello" => future { "World" } + case "Hello" => Future { "World" } case "Failure" => Future.failed(new RuntimeException("Expected exception; to test fault-tolerance")) case "NoReply" => Promise[String]().future } @@ -34,7 +34,7 @@ class FutureTests extends MinimalScalaTest { class ThrowableTest(m: String) extends Throwable(m) - val f1 = future[Any] { + val f1 = Future[Any] { throw new ThrowableTest("test") } @@ -43,7 +43,7 @@ class FutureTests extends MinimalScalaTest { } val latch = new TestLatch - val f2 = future { + val f2 = Future { Await.ready(latch, 5 seconds) "success" } @@ -61,7 +61,7 @@ class FutureTests extends MinimalScalaTest { Await.result(f3, defaultTimeout) mustBe ("SUCCESS") - val waiting = future { + val waiting = Future { Thread.sleep(1000) } Await.ready(waiting, 2000 millis) @@ -106,8 +106,8 @@ class FutureTests extends MinimalScalaTest { import ExecutionContext.Implicits._ "compose with for-comprehensions" in { - def async(x: Int) = future { (x * 2).toString } - val future0 = future[Any] { + def async(x: Int) = Future { (x * 2).toString } + val future0 = Future[Any] { "five!".length } @@ -119,8 +119,8 @@ class FutureTests extends MinimalScalaTest { val future2 = for { a <- future0.mapTo[Int] - b <- (future { (a * 2).toString }).mapTo[Int] - c <- future { (7 * 2).toString } + b <- (Future { (a * 2).toString }).mapTo[Int] + c <- Future { (7 * 2).toString } } yield b + "-" + c Await.result(future1, defaultTimeout) mustBe ("10-14") @@ -132,8 +132,8 @@ class FutureTests extends MinimalScalaTest { case class Req[T](req: T) case class Res[T](res: T) def async[T](req: Req[T]) = req match { - case Req(s: String) => future { Res(s.length) } - case Req(i: Int) => future { Res((i * 2).toString) } + case Req(s: String) => Future { Res(s.length) } + case Req(i: Int) => Future { Res((i * 2).toString) } } val future1 = for { @@ -224,7 +224,7 @@ class FutureTests extends MinimalScalaTest { "andThen like a boss" in { val q = new java.util.concurrent.LinkedBlockingQueue[Int] for (i <- 1 to 1000) { - val chained = future { + val chained = Future { q.add(1); 3 } andThen { case _ => q.add(2) @@ -251,7 +251,7 @@ class FutureTests extends MinimalScalaTest { } "find" in { - val futures = for (i <- 1 to 10) yield future { + val futures = for (i <- 1 to 10) yield Future { i } @@ -286,7 +286,7 @@ class FutureTests extends MinimalScalaTest { "fold" in { val timeout = 10000 millis - def async(add: Int, wait: Int) = future { + def async(add: Int, wait: Int) = Future { Thread.sleep(wait) add } @@ -306,7 +306,7 @@ class FutureTests extends MinimalScalaTest { "fold by composing" in { val timeout = 10000 millis - def async(add: Int, wait: Int) = future { + def async(add: Int, wait: Int) = Future { Thread.sleep(wait) add } @@ -321,7 +321,7 @@ class FutureTests extends MinimalScalaTest { "fold with an exception" in { val timeout = 10000 millis - def async(add: Int, wait: Int) = future { + def async(add: Int, wait: Int) = Future { Thread.sleep(wait) if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected") add @@ -357,7 +357,7 @@ class FutureTests extends MinimalScalaTest { } "shouldReduceResults" in { - def async(idx: Int) = future { + def async(idx: Int) = Future { Thread.sleep(idx * 20) idx } @@ -373,7 +373,7 @@ class FutureTests extends MinimalScalaTest { } "shouldReduceResultsWithException" in { - def async(add: Int, wait: Int) = future { + def async(add: Int, wait: Int) = Future { Thread.sleep(wait) if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected") else add @@ -404,7 +404,7 @@ class FutureTests extends MinimalScalaTest { } } - val oddFutures = List.fill(100)(future { counter.incAndGet() }).iterator + val oddFutures = List.fill(100)(Future { counter.incAndGet() }).iterator val traversed = Future.sequence(oddFutures) Await.result(traversed, defaultTimeout).sum mustBe (10000) @@ -420,11 +420,11 @@ class FutureTests extends MinimalScalaTest { "shouldBlockUntilResult" in { val latch = new TestLatch - val f = future { + val f = Future { Await.ready(latch, 5 seconds) 5 } - val f2 = future { + val f2 = Future { val res = Await.result(f, Inf) res + 9 } @@ -437,7 +437,7 @@ class FutureTests extends MinimalScalaTest { Await.result(f2, defaultTimeout) mustBe (14) - val f3 = future { + val f3 = Future { Thread.sleep(100) 5 } @@ -450,7 +450,7 @@ class FutureTests extends MinimalScalaTest { "run callbacks async" in { val latch = Vector.fill(10)(new TestLatch) - val f1 = future { + val f1 = Future { latch(0).open() Await.ready(latch(1), TestLatch.DefaultTimeout) "Hello" @@ -542,7 +542,7 @@ class FutureTests extends MinimalScalaTest { "should not throw when Await.ready" in { val expected = try Success(5 / 0) catch { case a: ArithmeticException => Failure(a) } - val f = future(5).map(_ / 0) + val f = Future(5).map(_ / 0) Await.ready(f, defaultTimeout).value.get.toString mustBe expected.toString } diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index 5006793084..b431f6b8f8 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -8,7 +8,7 @@ import scala.concurrent.{ CanAwait, Await } -import scala.concurrent.{ future, promise, blocking } +import scala.concurrent.blocking import scala.util.{ Try, Success, Failure } import scala.concurrent.duration.Duration import scala.reflect.{ classTag, ClassTag } @@ -35,14 +35,14 @@ trait FutureCallbacks extends TestBase { def testOnSuccess(): Unit = once { done => var x = 0 - val f = future { x = 1 } + val f = Future { x = 1 } f onSuccess { case _ => done(x == 1) } } def testOnSuccessWhenCompleted(): Unit = once { done => var x = 0 - val f = future { x = 1 } + val f = Future { x = 1 } f onSuccess { case _ if x == 1 => x = 2 @@ -52,21 +52,21 @@ trait FutureCallbacks extends TestBase { def testOnSuccessWhenFailed(): Unit = once { done => - val f = future[Unit] { throw new Exception } + val f = Future[Unit] { throw new Exception } f onSuccess { case _ => done(false) } f onFailure { case _ => done(true) } } def testOnFailure(): Unit = once { done => - val f = future[Unit] { throw new Exception } + val f = Future[Unit] { throw new Exception } f onSuccess { case _ => done(false) } f onFailure { case _ => done(true) } } def testOnFailureWhenSpecialThrowable(num: Int, cause: Throwable): Unit = once { done => - val f = future[Unit] { throw cause } + val f = Future[Unit] { throw cause } f onSuccess { case _ => done(false) } f onFailure { case e: ExecutionException if e.getCause == cause => done(true) @@ -76,7 +76,7 @@ trait FutureCallbacks extends TestBase { def testOnFailureWhenTimeoutException(): Unit = once { done => - val f = future[Unit] { throw new TimeoutException() } + val f = Future[Unit] { throw new TimeoutException() } f onSuccess { case _ => done(false) } f onFailure { case e: TimeoutException => done(true) @@ -108,7 +108,7 @@ trait FutureCombinators extends TestBase { def testMapSuccess(): Unit = once { done => - val f = future { 5 } + val f = Future { 5 } val g = f map { x => "result: " + x } g onSuccess { case s => done(s == "result: 5") } g onFailure { case _ => done(false) } @@ -116,7 +116,7 @@ trait FutureCombinators extends TestBase { def testMapFailure(): Unit = once { done => - val f = future[Unit] { throw new Exception("exception message") } + val f = Future[Unit] { throw new Exception("exception message") } val g = f map { x => "result: " + x } g onSuccess { case _ => done(false) } g onFailure { case t => done(t.getMessage() == "exception message") } @@ -124,7 +124,7 @@ trait FutureCombinators extends TestBase { def testMapSuccessPF(): Unit = once { done => - val f = future { 5 } + val f = Future { 5 } val g = f map { case r => "result: " + r } g onSuccess { case s => done(s == "result: 5") } g onFailure { case _ => done(false) } @@ -132,7 +132,7 @@ trait FutureCombinators extends TestBase { def testTransformSuccess(): Unit = once { done => - val f = future { 5 } + val f = Future { 5 } val g = f.transform(r => "result: " + r, identity) g onSuccess { case s => done(s == "result: 5") } g onFailure { case _ => done(false) } @@ -140,7 +140,7 @@ trait FutureCombinators extends TestBase { def testTransformSuccessPF(): Unit = once { done => - val f = future { 5 } + val f = Future { 5 } val g = f.transform( { case r => "result: " + r }, identity) g onSuccess { case s => done(s == "result: 5") } g onFailure { case _ => done(false) } @@ -149,7 +149,7 @@ trait FutureCombinators extends TestBase { def testTransformFailure(): Unit = once { done => val transformed = new Exception("transformed") - val f = future { throw new Exception("expected") } + val f = Future { throw new Exception("expected") } val g = f.transform(identity, _ => transformed) g onSuccess { case _ => done(false) } g onFailure { case e => done(e eq transformed) } @@ -159,7 +159,7 @@ def testTransformFailure(): Unit = once { done => val e = new Exception("expected") val transformed = new Exception("transformed") - val f = future[Unit] { throw e } + val f = Future[Unit] { throw e } val g = f.transform(identity, { case `e` => transformed }) g onSuccess { case _ => done(false) } g onFailure { case e => done(e eq transformed) } @@ -167,7 +167,7 @@ def testTransformFailure(): Unit = once { def testFoldFailure(): Unit = once { done => - val f = future[Unit] { throw new Exception("expected") } + val f = Future[Unit] { throw new Exception("expected") } val g = f.transform(r => "result: " + r, identity) g onSuccess { case _ => done(false) } g onFailure { case t => done(t.getMessage() == "expected") } @@ -175,23 +175,23 @@ def testTransformFailure(): Unit = once { def testFlatMapSuccess(): Unit = once { done => - val f = future { 5 } - val g = f flatMap { _ => future { 10 } } + val f = Future { 5 } + val g = f flatMap { _ => Future { 10 } } g onSuccess { case x => done(x == 10) } g onFailure { case _ => done(false) } } def testFlatMapFailure(): Unit = once { done => - val f = future[Unit] { throw new Exception("expected") } - val g = f flatMap { _ => future { 10 } } + val f = Future[Unit] { throw new Exception("expected") } + val g = f flatMap { _ => Future { 10 } } g onSuccess { case _ => done(false) } g onFailure { case t => done(t.getMessage() == "expected") } } def testFilterSuccess(): Unit = once { done => - val f = future { 4 } + val f = Future { 4 } val g = f filter { _ % 2 == 0 } g onSuccess { case x: Int => done(x == 4) } g onFailure { case _ => done(false) } @@ -199,7 +199,7 @@ def testTransformFailure(): Unit = once { def testFilterFailure(): Unit = once { done => - val f = future { 4 } + val f = Future { 4 } val g = f filter { _ % 2 == 1 } g onSuccess { case x: Int => done(false) } g onFailure { @@ -210,7 +210,7 @@ def testTransformFailure(): Unit = once { def testCollectSuccess(): Unit = once { done => - val f = future { -5 } + val f = Future { -5 } val g = f collect { case x if x < 0 => -x } g onSuccess { case x: Int => done(x == 5) } g onFailure { case _ => done(false) } @@ -218,7 +218,7 @@ def testTransformFailure(): Unit = once { def testCollectFailure(): Unit = once { done => - val f = future { -5 } + val f = Future { -5 } val g = f collect { case x if x > 0 => x * 2 } g onSuccess { case _ => done(false) } g onFailure { @@ -232,8 +232,8 @@ def testTransformFailure(): Unit = once { def testForeachSuccess(): Unit = once { done => - val p = promise[Int]() - val f = future[Int] { 5 } + val p = Promise[Int]() + val f = Future[Int] { 5 } f foreach { x => p.success(x * 2) } val g = p.future @@ -243,8 +243,8 @@ def testTransformFailure(): Unit = once { def testForeachFailure(): Unit = once { done => - val p = promise[Int]() - val f = future[Int] { throw new Exception } + val p = Promise[Int]() + val f = Future[Int] { throw new Exception } f foreach { x => p.success(x * 2) } f onFailure { case _ => p.failure(new Exception) } val g = p.future @@ -256,7 +256,7 @@ def testTransformFailure(): Unit = once { def testRecoverSuccess(): Unit = once { done => val cause = new RuntimeException - val f = future { + val f = Future { throw cause } recover { case re: RuntimeException => @@ -268,7 +268,7 @@ def testTransformFailure(): Unit = once { def testRecoverFailure(): Unit = once { done => val cause = new RuntimeException - val f = future { + val f = Future { throw cause } recover { case te: TimeoutException => "timeout" @@ -280,11 +280,11 @@ def testTransformFailure(): Unit = once { def testRecoverWithSuccess(): Unit = once { done => val cause = new RuntimeException - val f = future { + val f = Future { throw cause } recoverWith { case re: RuntimeException => - future { "recovered" } + Future { "recovered" } } f onSuccess { case x => done(x == "recovered") } f onFailure { case any => done(false) } @@ -293,11 +293,11 @@ def testTransformFailure(): Unit = once { def testRecoverWithFailure(): Unit = once { done => val cause = new RuntimeException - val f = future { + val f = Future { throw cause } recoverWith { case te: TimeoutException => - future { "timeout" } + Future { "timeout" } } f onSuccess { case x => done(false) } f onFailure { case any => done(any == cause) } @@ -305,8 +305,8 @@ def testTransformFailure(): Unit = once { def testZipSuccess(): Unit = once { done => - val f = future { 5 } - val g = future { 6 } + val f = Future { 5 } + val g = Future { 6 } val h = f zip g h onSuccess { case (l: Int, r: Int) => done(l+r == 11) } h onFailure { case _ => done(false) } @@ -315,8 +315,8 @@ def testTransformFailure(): Unit = once { def testZipFailureLeft(): Unit = once { done => val cause = new Exception("expected") - val f = future { throw cause } - val g = future { 6 } + val f = Future { throw cause } + val g = Future { 6 } val h = f zip g h onSuccess { case _ => done(false) } h onFailure { case e: Exception => done(e.getMessage == "expected") } @@ -325,8 +325,8 @@ def testTransformFailure(): Unit = once { def testZipFailureRight(): Unit = once { done => val cause = new Exception("expected") - val f = future { 5 } - val g = future { throw cause } + val f = Future { 5 } + val g = Future { throw cause } val h = f zip g h onSuccess { case _ => done(false) } h onFailure { case e: Exception => done(e.getMessage == "expected") } @@ -334,8 +334,8 @@ def testTransformFailure(): Unit = once { def testFallbackTo(): Unit = once { done => - val f = future { sys.error("failed") } - val g = future { 5 } + val f = Future { sys.error("failed") } + val g = Future { 5 } val h = f fallbackTo g h onSuccess { case x: Int => done(x == 5) } h onFailure { case _ => done(false) } @@ -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 { sys.error("failed") } + val g = Future { throw cause } val h = f fallbackTo g h onSuccess { case _ => done(false) } @@ -382,7 +382,7 @@ trait FutureProjections extends TestBase { def testFailedFailureOnComplete(): Unit = once { done => val cause = new RuntimeException - val f = future { throw cause } + val f = Future { throw cause } f.failed onComplete { case Success(t) => done(t == cause) case Failure(t) => done(false) @@ -392,13 +392,13 @@ trait FutureProjections extends TestBase { def testFailedFailureOnSuccess(): Unit = once { done => val cause = new RuntimeException - val f = future { throw cause } + val f = Future { throw cause } f.failed onSuccess { case t => done(t == cause) } } def testFailedSuccessOnComplete(): Unit = once { done => - val f = future { 0 } + val f = Future { 0 } f.failed onComplete { case Failure(_: NoSuchElementException) => done(true) case _ => done(false) @@ -407,7 +407,7 @@ trait FutureProjections extends TestBase { def testFailedSuccessOnFailure(): Unit = once { done => - val f = future { 0 } + val f = Future { 0 } f.failed onFailure { case e: NoSuchElementException => done(true) case _ => done(false) @@ -418,13 +418,13 @@ trait FutureProjections extends TestBase { def testFailedFailureAwait(): Unit = once { done => val cause = new RuntimeException - val f = future { throw cause } + val f = Future { throw cause } done(Await.result(f.failed, Duration(500, "ms")) == cause) } def testFailedSuccessAwait(): Unit = once { done => - val f = future { 0 } + val f = Future { 0 } try { Await.result(f.failed, Duration(500, "ms")) done(false) @@ -437,7 +437,7 @@ trait FutureProjections extends TestBase { def testAwaitPositiveDuration(): Unit = once { done => val p = Promise[Int]() val f = p.future - future { + Future { intercept[IllegalArgumentException] { Await.ready(f, Duration.Undefined) } p.success(0) Await.ready(f, Duration.Zero) @@ -449,7 +449,7 @@ trait FutureProjections extends TestBase { def testAwaitNegativeDuration(): Unit = once { done => val f = Promise().future - future { + Future { intercept[TimeoutException] { Await.ready(f, Duration.Zero) } intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) } intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) } @@ -473,14 +473,14 @@ trait Blocking extends TestBase { def testAwaitSuccess(): Unit = once { done => - val f = future { 0 } + val f = Future { 0 } done(Await.result(f, Duration(500, "ms")) == 0) } def testAwaitFailure(): Unit = once { done => val cause = new RuntimeException - val f = future { throw cause } + val f = Future { throw cause } try { Await.result(f, Duration(500, "ms")) done(false) @@ -562,7 +562,7 @@ trait Promises extends TestBase { def testSuccess(): Unit = once { done => - val p = promise[Int]() + val p = Promise[Int]() val f = p.future f onSuccess { case x => done(x == 5) } @@ -574,7 +574,7 @@ trait Promises extends TestBase { def testFailure(): Unit = once { done => val e = new Exception("expected") - val p = promise[Int]() + val p = Promise[Int]() val f = p.future f onSuccess { case x => done(false) } @@ -644,7 +644,7 @@ trait CustomExecutionContext extends TestBase { val count = countExecs { implicit ec => blocking { once { done => - val f = future(assertNoEC())(defaultEC) + val f = Future(assertNoEC())(defaultEC) f onSuccess { case _ => assertEC() @@ -749,14 +749,14 @@ trait ExecutionContextPrepare extends TestBase { def testOnComplete(): Unit = once { done => theLocal.set("secret") - val fut = future { 42 } + val fut = Future { 42 } fut onComplete { case _ => done(theLocal.get == "secret") } } def testMap(): Unit = once { done => theLocal.set("secret2") - val fut = future { 42 } + val fut = Future { 42 } fut map { x => done(theLocal.get == "secret2") } } diff --git a/test/files/pos/t2484.scala b/test/files/pos/t2484.scala index 29f798edf9..88da6aaac8 100755 --- a/test/files/pos/t2484.scala +++ b/test/files/pos/t2484.scala @@ -3,7 +3,7 @@ import concurrent.ExecutionContext.Implicits.global class Admin extends javax.swing.JApplet { val jScrollPane = new javax.swing.JScrollPane (null, 0, 0) def t2484: Unit = { - scala.concurrent.future {jScrollPane.synchronized { + scala.concurrent.Future {jScrollPane.synchronized { def someFunction () = {} //scala.concurrent.ops.spawn {someFunction ()} jScrollPane.addComponentListener (new java.awt.event.ComponentAdapter {override def componentShown (e: java.awt.event.ComponentEvent) = { diff --git a/test/files/run/macro-duplicate/Impls_Macros_1.scala b/test/files/run/macro-duplicate/Impls_Macros_1.scala index 85a581585f..7791df8fa4 100644 --- a/test/files/run/macro-duplicate/Impls_Macros_1.scala +++ b/test/files/run/macro-duplicate/Impls_Macros_1.scala @@ -10,7 +10,7 @@ object Macros { case Template(_, _, ctor :: defs) => val defs1 = defs collect { case ddef @ DefDef(mods, name, tparams, vparamss, tpt, body) => - val future = Select(Select(Select(Ident(TermName("scala")), TermName("concurrent")), TermName("package")), TermName("future")) + val future = Select(Select(Ident(TermName("scala")), TermName("concurrent")), TermName("Future")) val Future = Select(Select(Ident(TermName("scala")), TermName("concurrent")), TypeName("Future")) val tpt1 = if (tpt.isEmpty) tpt else AppliedTypeTree(Future, List(tpt)) val body1 = Apply(future, List(body)) diff --git a/test/files/run/t6448.scala b/test/files/run/t6448.scala index 4d1528e500..d0faaa9560 100644 --- a/test/files/run/t6448.scala +++ b/test/files/run/t6448.scala @@ -50,7 +50,7 @@ object Test { import concurrent.ExecutionContext.Implicits.global import concurrent.Await import concurrent.duration.Duration - val result = concurrent.future(1) collect { case x if f(x) => x} + val result = concurrent.Future(1) collect { case x if f(x) => x} Await.result(result, Duration.Inf) } diff --git a/test/files/run/t7775.scala b/test/files/run/t7775.scala index 5fb0327611..48b0d89974 100644 --- a/test/files/run/t7775.scala +++ b/test/files/run/t7775.scala @@ -1,4 +1,4 @@ -import scala.concurrent.{duration, future, Await, ExecutionContext} +import scala.concurrent.{duration, Future, Await, ExecutionContext} import scala.tools.nsc.Settings import ExecutionContext.Implicits.global @@ -8,7 +8,7 @@ import ExecutionContext.Implicits.global object Test { def main(args: Array[String]) { val tries = 1000 // YMMV - val compiler = future { + val compiler = Future { for(_ <- 1 to tries) new Settings(_ => {}) } for(i <- 1 to tries * 10) System.setProperty(s"foo$i", i.toString) diff --git a/test/files/run/t7805-repl-i.scala b/test/files/run/t7805-repl-i.scala index bb5203951e..208cb5da13 100644 --- a/test/files/run/t7805-repl-i.scala +++ b/test/files/run/t7805-repl-i.scala @@ -35,7 +35,7 @@ trait HangingRepl extends ReplTest { import ExecutionContext.Implicits._ import Resulting._ def timeout = 120 seconds - def hanging[A](a: =>A): A = future(a) resultWithin timeout + def hanging[A](a: =>A): A = Future(a) resultWithin timeout override def show() = Try(hanging(super.show())) recover { case e => e.printStackTrace() } -- cgit v1.2.3