Skip to content

Commit 04428d6

Browse files
committed
Rename Future#await --> Future#value
Avoid confusion with `Async#await`, which returns a different type.
1 parent d92a450 commit 04428d6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/pos/suspend-strawman-2/futures.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Future[+T](body: Async ?=> T):
5555
/** Wait for this future to be completed, return its value in case of success,
5656
* or rethrow exception in case of failure.
5757
*/
58-
def await(using a: Async): T = a.await(this).get
58+
def value(using async: Async): T = async.await(this).get
5959

6060
// a handler for Async
6161
private def async(body: Async ?=> Unit): Unit =
@@ -186,8 +186,8 @@ object Future:
186186
val f1 = Future(body1).linked
187187
val f2 = Future(body2).linked
188188
async.awaitEither(f1, f2) match
189-
case Left(Success(x1)) => (x1, f2.await)
190-
case Right(Success(x2)) => (f1.await, x2)
189+
case Left(Success(x1)) => (x1, f2.value)
190+
case Right(Success(x2)) => (f1.value, x2)
191191
case Left(Failure(ex)) => throw ex
192192
case Right(Failure(ex)) => throw ex
193193

@@ -202,13 +202,13 @@ object Future:
202202
async.awaitEither(f1, f2) match
203203
case Left(Success(x1)) => x1
204204
case Right(Success(x2)) => x2
205-
case Left(_: Failure[?]) => f2.await
206-
case Right(_: Failure[?]) => f1.await
205+
case Left(_: Failure[?]) => f2.value
206+
case Right(_: Failure[?]) => f1.value
207207
end Future
208208

209209
def Test(x: Future[Int], xs: List[Future[Int]])(using Scheduler): Future[Int] =
210210
Future.spawn:
211-
x.await + xs.map(_.await).sum
211+
x.value + xs.map(_.value).sum
212212

213213
def Main(x: Future[Int], xs: List[Future[Int]])(using Scheduler): Int =
214214
Test(x, xs).force()

0 commit comments

Comments
 (0)