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

Side by Side Diff: sdk/lib/async/future.dart

Issue 2647833002: fix #28008, fix #28009 implement FutureOr<T> (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into 28008_futureort Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « pkg/dev_compiler/tool/sdk_expected_errors.txt ('k') | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 /// A type representing values that are either `Future<T>` or `T`. 7 /// A type representing values that are either `Future<T>` or `T`.
8 /// 8 ///
9 /// This class declaration is a public stand-in for an internal 9 /// This class declaration is a public stand-in for an internal
10 /// future-or-value generic type. References to this class are resolved to the 10 /// future-or-value generic type. References to this class are resolved to the
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 * the future returned by `then` will be completed with 490 * the future returned by `then` will be completed with
491 * the same result as the future returned by the callback. 491 * the same result as the future returned by the callback.
492 * 492 *
493 * If [onError] is not given, and this future completes with an error, 493 * If [onError] is not given, and this future completes with an error,
494 * the error is forwarded directly to the returned future. 494 * the error is forwarded directly to the returned future.
495 * 495 *
496 * In most cases, it is more readable to use [catchError] separately, possibly 496 * In most cases, it is more readable to use [catchError] separately, possibly
497 * with a `test` parameter, instead of handling both value and error in a 497 * with a `test` parameter, instead of handling both value and error in a
498 * single [then] call. 498 * single [then] call.
499 */ 499 */
500 Future<S> then<S>(onValue(T value), { Function onError }); 500 Future<S> then<S>(FutureOr<S> onValue(T value), { Function onError });
501 501
502 /** 502 /**
503 * Handles errors emitted by this [Future]. 503 * Handles errors emitted by this [Future].
504 * 504 *
505 * This is the asynchronous equivalent of a "catch" block. 505 * This is the asynchronous equivalent of a "catch" block.
506 * 506 *
507 * Returns a new [Future] that will be completed with either the result of 507 * Returns a new [Future] that will be completed with either the result of
508 * this future or the result of calling the `onError` callback. 508 * this future or the result of calling the `onError` callback.
509 * 509 *
510 * If this future completes with a value, 510 * If this future completes with a value,
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 if (replacement != null) { 820 if (replacement != null) {
821 error = _nonNullError(replacement.error); 821 error = _nonNullError(replacement.error);
822 stackTrace = replacement.stackTrace; 822 stackTrace = replacement.stackTrace;
823 } 823 }
824 result._completeError(error, stackTrace); 824 result._completeError(error, stackTrace);
825 } 825 }
826 826
827 /** Helper function that converts `null` to a [NullThrownError]. */ 827 /** Helper function that converts `null` to a [NullThrownError]. */
828 Object _nonNullError(Object error) => 828 Object _nonNullError(Object error) =>
829 (error != null) ? error : new NullThrownError(); 829 (error != null) ? error : new NullThrownError();
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/sdk_expected_errors.txt ('k') | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698