Index: sdk/lib/async/future_impl.dart |
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart |
index 980f0caa4f4a724827b30d5fea32845e7961392e..9fa1e57090e2583c3485efbd6d9f6a41f5f16da6 100644 |
--- a/sdk/lib/async/future_impl.dart |
+++ b/sdk/lib/async/future_impl.dart |
@@ -203,13 +203,19 @@ class _Future<T> implements Future<T> { |
} |
Future then(f(T value), { Function onError }) { |
- _Future result = new _Future(); |
- if (!identical(result._zone, _ROOT_ZONE)) { |
- f = result._zone.registerUnaryCallback(f); |
+ Zone currentZone = Zone.current; |
+ if (!identical(currentZone, _ROOT_ZONE)) { |
+ f = currentZone.registerUnaryCallback(f); |
if (onError != null) { |
- onError = _registerErrorHandler(onError, result._zone); |
+ onError = _registerErrorHandler(onError, currentZone); |
} |
} |
+ return _thenNoZoneRegistration(f, onError); |
+ } |
+ |
+ // This function is used by async/await. |
+ Future _thenNoZoneRegistration(f(T value), Function onError) { |
+ _Future result = new _Future(); |
_addListener(new _FutureListener.then(result, f, onError)); |
return result; |
} |