Index: sdk/lib/_internal/pub/lib/src/utils.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart |
index d3ea1b609b83e320888561f90dcaeac3808142d9..1fc3ecaca4dbba1971f6ec7e21eaaf1c90089bce 100644 |
--- a/sdk/lib/_internal/pub/lib/src/utils.dart |
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart |
@@ -72,6 +72,10 @@ class FutureGroup<T> { |
Future<List> get future => _completer.future; |
} |
+/// Like [new Future], but avoids around issue 11911 by using [new Future.value] |
+/// under the covers. |
+Future newFuture(callback()) => new Future.value().then((_) => callback()); |
+ |
// TODO(rnystrom): Move into String? |
/// Pads [source] to [length] by adding spaces at the end. |
String padRight(String source, int length) { |
@@ -407,7 +411,7 @@ Future resetStack(fn()) { |
// Using [new Future] adds an asynchronous operation that works around the |
// first and second cases described above. |
- new Future(fn).then((val) { |
+ newFuture(fn).then((val) { |
runAsync(() => completer.complete(val)); |
}).catchError((err) { |
runAsync(() => completer.completeError(err)); |