Chromium Code Reviews| Index: sdk/lib/async/future_impl.dart |
| diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart |
| index eb4d6cfcaaf090a9c862cdaabeac192afdff1a69..c15dcd41502df9c74d4eab674fbd95afea50b4a1 100644 |
| --- a/sdk/lib/async/future_impl.dart |
| +++ b/sdk/lib/async/future_impl.dart |
| @@ -277,6 +277,11 @@ class _Future<T> implements Future<T> { |
| _state = _PENDING_COMPLETE; |
| } |
| + void _clearPendingComplete() { |
| + assert(_isPendingComplete); |
| + _state = _INCOMPLETE; |
| + } |
| + |
| AsyncError get _error { |
| assert(_hasError); |
| return _resultOrListeners; |
| @@ -405,7 +410,11 @@ class _Future<T> implements Future<T> { |
| try { |
| source.then((value) { |
| assert(target._isPendingComplete); |
| - target._completeWithValue(value); |
| + // The "value" may be another future if the foreign future |
| + // implementation is mis-behaving, |
| + // so use _complete in stead of _completeWithValue. |
|
floitsch
2016/05/10 15:39:51
instead
Lasse Reichstein Nielsen
2016/05/11 10:19:36
Done.
|
| + target._clearPendingComplete(); // Clear this first, it's set again. |
| + target._complete(value); |
| }, |
| // TODO(floitsch): eventually we would like to make this non-optional |
| // and dependent on the listeners of the target future. If none of |
| @@ -650,7 +659,7 @@ class _Future<T> implements Future<T> { |
| } |
| } |
| - |
| + |
| if (listener.handlesComplete) { |
| handleWhenCompleteCallback(); |
| } else if (!hasError) { |
| @@ -662,7 +671,7 @@ class _Future<T> implements Future<T> { |
| handleError(); |
| } |
| } |
| - |
| + |
| // If we changed zone, oldZone will not be null. |
| if (oldZone != null) Zone._leave(oldZone); |