| OLD | NEW |
| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 * the `then` call, it would not catch errors from the `bar` call. | 128 * the `then` call, it would not catch errors from the `bar` call. |
| 129 * | 129 * |
| 130 * Futures can have more than one callback-pair registered. Each successor is | 130 * Futures can have more than one callback-pair registered. Each successor is |
| 131 * treated independently and is handled as if it was the only successor. | 131 * treated independently and is handled as if it was the only successor. |
| 132 * | 132 * |
| 133 * A future may also fail to ever complete. In that case, no callbacks are | 133 * A future may also fail to ever complete. In that case, no callbacks are |
| 134 * called. | 134 * called. |
| 135 */ | 135 */ |
| 136 abstract class Future<T> { | 136 abstract class Future<T> { |
| 137 // The `_nullFuture` is a completed Future with the value `null`. | 137 // The `_nullFuture` is a completed Future with the value `null`. |
| 138 static final _Future<Null> _nullFuture = new Future.value(null); | 138 static final _Future<Null> _nullFuture = new _Future<Null>.value(null); |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Creates a future containing the result of calling [computation] | 141 * Creates a future containing the result of calling [computation] |
| 142 * asynchronously with [Timer.run]. | 142 * asynchronously with [Timer.run]. |
| 143 * | 143 * |
| 144 * If the result of executing [computation] throws, the returned future is | 144 * If the result of executing [computation] throws, the returned future is |
| 145 * completed with the error. | 145 * completed with the error. |
| 146 * | 146 * |
| 147 * If the returned value is itself a [Future], completion of | 147 * If the returned value is itself a [Future], completion of |
| 148 * the created future will wait until the returned future completes, | 148 * the created future will wait until the returned future completes, |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); | 887 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); |
| 888 if (replacement != null) { | 888 if (replacement != null) { |
| 889 error = _nonNullError(replacement.error); | 889 error = _nonNullError(replacement.error); |
| 890 stackTrace = replacement.stackTrace; | 890 stackTrace = replacement.stackTrace; |
| 891 } | 891 } |
| 892 result._asyncCompleteError(error, stackTrace); | 892 result._asyncCompleteError(error, stackTrace); |
| 893 } | 893 } |
| 894 | 894 |
| 895 /** Helper function that converts `null` to a [NullThrownError]. */ | 895 /** Helper function that converts `null` to a [NullThrownError]. */ |
| 896 Object _nonNullError(Object error) => error ?? new NullThrownError(); | 896 Object _nonNullError(Object error) => error ?? new NullThrownError(); |
| OLD | NEW |