Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 19841002: Remove calls to [new Future] work around issue 11911. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review change. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/hosted.dart ('k') | sdk/lib/_internal/pub/test/error_group_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/hosted.dart ('k') | sdk/lib/_internal/pub/test/error_group_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698