| Index: sdk/lib/async/future_impl.dart
|
| diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
|
| index 351e5b961e7ace93a1957013d1431d495c3ca809..cc7903b12dd74fe08302391f6fd8d95a17cbe81d 100644
|
| --- a/sdk/lib/async/future_impl.dart
|
| +++ b/sdk/lib/async/future_impl.dart
|
| @@ -157,7 +157,7 @@ class _FutureImpl<T> implements Future<T> {
|
| }
|
| }
|
|
|
| - Future<T> whenComplete(void action()) {
|
| + Future<T> whenComplete(action()) {
|
| _WhenFuture<T> whenFuture = new _WhenFuture<T>(action);
|
| if (!_isComplete) {
|
| _addListener(whenFuture);
|
| @@ -416,7 +416,16 @@ class _WhenFuture<T> extends _TransformFuture<T, T> {
|
|
|
| void _sendValue(T value) {
|
| try {
|
| - _action();
|
| + var result = _action();
|
| + if (result is Future) {
|
| + Future resultFuture = result;
|
| + result.then((_) {
|
| + _setValue(value);
|
| + }, onError: (AsyncError e) {
|
| + _setError(e);
|
| + });
|
| + return;
|
| + }
|
| } catch (e, s) {
|
| _setError(new AsyncError(e, s));
|
| return;
|
| @@ -426,7 +435,18 @@ class _WhenFuture<T> extends _TransformFuture<T, T> {
|
|
|
| void _sendError(AsyncError error) {
|
| try {
|
| - _action();
|
| + var result = _action();
|
| + if (result is Future) {
|
| + Future resultFuture = result;
|
| + result.then((_) {
|
| + _setError(error);
|
| + }, onError: (AsyncError e) {
|
| + // TODO(lrn): Find a way to combine error into the
|
| + // resulting error.
|
| + _setError(e);
|
| + });
|
| + return;
|
| + }
|
| } catch (e, s) {
|
| error = new AsyncError.withCause(e, s, error);
|
| }
|
| @@ -454,7 +474,7 @@ class _FutureWrapper<T> implements Future<T> {
|
| return _future.catchError(function, test: test);
|
| }
|
|
|
| - Future whenComplete(void action()) {
|
| + Future whenComplete(action()) {
|
| return _future.whenComplete(action);
|
| }
|
|
|
|
|