Revert "Create _nullFuture and _falseFuture in the root zone."
This reverts commit 9bb085a1c6e64a5f256d9430997603437238dc42 due to
test failure in google3.
Change-Id: I63940e62bd97c83bc432db99b44c991e6c1e025e
Reviewed-on: https://dart-review.googlesource.com/52422
Reviewed-by: Dan Grove <dgrove@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index 8de4156..bcd1f22 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -148,12 +148,10 @@
*/
abstract class Future<T> {
/// A `Future<Null>` completed with `null`.
- static final _Future<Null> _nullFuture =
- new _Future<Null>.zoneValue(null, Zone.root);
+ static final _Future<Null> _nullFuture = new _Future<Null>.value(null);
/// A `Future<bool>` completed with `false`.
- static final _Future<bool> _falseFuture =
- new _Future<bool>.zoneValue(false, Zone.root);
+ static final _Future<bool> _falseFuture = new _Future<bool>.value(false);
/**
* Creates a future containing the result of calling [computation]
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
index 2b56f9d..6eeaa08 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -184,7 +184,7 @@
* Until the future is completed, the field may hold the zone that
* listener callbacks used to create this future should be run in.
*/
- final Zone _zone;
+ final Zone _zone = Zone.current;
/**
* Either the result, a list of listeners or another future.
@@ -204,24 +204,20 @@
var _resultOrListeners;
// This constructor is used by async/await.
- _Future() : _zone = Zone.current;
+ _Future();
- _Future.immediate(FutureOr<T> result) : _zone = Zone.current {
+ _Future.immediate(FutureOr<T> result) {
_asyncComplete(result);
}
- /** Creates a future with the value and the specified zone. */
- _Future.zoneValue(T value, this._zone) {
- _setValue(value);
- }
-
- _Future.immediateError(var error, [StackTrace stackTrace])
- : _zone = Zone.current {
+ _Future.immediateError(var error, [StackTrace stackTrace]) {
_asyncCompleteError(error, stackTrace);
}
/** Creates a future that is already completed with the value. */
- _Future.value(T value) : this.zoneValue(value, Zone.current);
+ _Future.value(T value) {
+ _setValue(value);
+ }
bool get _mayComplete => _state == _stateIncomplete;
bool get _isPendingComplete => _state == _statePendingComplete;
diff --git a/tests/lib_2/async/null_future_zone_test.dart b/tests/lib_2/async/null_future_zone_test.dart
deleted file mode 100644
index 802c399..0000000
--- a/tests/lib_2/async/null_future_zone_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import "package:expect/expect.dart";
-import "package:async_helper/async_helper.dart";
-import 'dart:async';
-
-main() {
- asyncStart(2);
- () async {
- var it = new StreamIterator(new Stream.fromIterable([]));
- Expect.isFalse(await it.moveNext());
-
- Future nullFuture;
- Future falseFuture;
-
- runZoned(() {
- nullFuture = (new StreamController()..stream.listen(null).cancel()).done;
- falseFuture = it.moveNext();
- }, zoneSpecification: new ZoneSpecification(scheduleMicrotask:
- (Zone self, ZoneDelegate parent, Zone zone, void f()) {
- Expect.fail("Should not be called");
- }));
-
- nullFuture.then((value) {
- Expect.isNull(value);
- asyncEnd();
- });
-
- falseFuture.then((value) {
- Expect.isFalse(value);
- asyncEnd();
- });
- }();
-}