mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:27:43 +00:00
Use FutureOr in Completer.complete.
R=floitsch@google.com
Committed: a4a7d98dce
Review-Url: https://codereview.chromium.org/2722203002 .
This commit is contained in:
parent
ce58e89d3c
commit
00cd7580c1
|
@ -553,11 +553,9 @@ abstract class Future<T> {
|
|||
* }
|
||||
*
|
||||
*/
|
||||
// The `Function` below can stand for several types:
|
||||
// - (dynamic) -> T
|
||||
// - (dynamic, StackTrace) -> T
|
||||
// - (dynamic) -> Future<T>
|
||||
// - (dynamic, StackTrace) -> Future<T>
|
||||
// The `Function` below stands for one of two types:
|
||||
// - (dynamic) -> FutureOr<T>
|
||||
// - (dynamic, StackTrace) -> FutureOr<T>
|
||||
// Given that there is a `test` function that is usually used to do an
|
||||
// `isCheck` we should also expect functions that take a specific argument.
|
||||
// Note: making `catchError` return a `Future<T>` in non-strong mode could be
|
||||
|
@ -785,7 +783,7 @@ abstract class Completer<T> {
|
|||
*
|
||||
* All listeners on the future are informed about the value.
|
||||
*/
|
||||
void complete([value]);
|
||||
void complete([FutureOr<T> value]);
|
||||
|
||||
/**
|
||||
* Complete [future] with an error.
|
||||
|
@ -827,5 +825,4 @@ void _completeWithErrorCallback(_Future result, error, stackTrace) {
|
|||
}
|
||||
|
||||
/** Helper function that converts `null` to a [NullThrownError]. */
|
||||
Object _nonNullError(Object error) =>
|
||||
(error != null) ? error : new NullThrownError();
|
||||
Object _nonNullError(Object error) => error ?? new NullThrownError();
|
||||
|
|
|
@ -14,7 +14,7 @@ typedef _FutureAction();
|
|||
abstract class _Completer<T> implements Completer<T> {
|
||||
final _Future<T> future = new _Future<T>();
|
||||
|
||||
void complete([value]);
|
||||
void complete([FutureOr<T> value]);
|
||||
|
||||
void completeError(Object error, [StackTrace stackTrace]) {
|
||||
error = _nonNullError(error);
|
||||
|
@ -36,7 +36,7 @@ abstract class _Completer<T> implements Completer<T> {
|
|||
|
||||
class _AsyncCompleter<T> extends _Completer<T> {
|
||||
|
||||
void complete([value]) {
|
||||
void complete([FutureOr<T> value]) {
|
||||
if (!future._mayComplete) throw new StateError("Future already completed");
|
||||
future._asyncComplete(value);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class _AsyncCompleter<T> extends _Completer<T> {
|
|||
}
|
||||
|
||||
class _SyncCompleter<T> extends _Completer<T> {
|
||||
void complete([value]) {
|
||||
void complete([FutureOr<T> value]) {
|
||||
if (!future._mayComplete) throw new StateError("Future already completed");
|
||||
future._complete(value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue