Revert "Create _nullFuture and _falseFuture in the root zone."

This reverts commit 9bb085a1c6 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>
This commit is contained in:
Keerti Parthasarathy 2018-04-24 20:45:38 +00:00 committed by commit-bot@chromium.org
parent ed4733e6fc
commit 9eb09d825b
3 changed files with 9 additions and 51 deletions

View file

@ -148,12 +148,10 @@ abstract class FutureOr<T> {
*/
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]

View file

@ -184,7 +184,7 @@ class _Future<T> implements Future<T> {
* 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 @@ class _Future<T> implements Future<T> {
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;

View file

@ -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();
});
}();
}