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

Unified Diff: sdk/lib/async/future.dart

Issue 2762953003: More minor type improvements in dart:async. (Closed)
Patch Set: More fixes. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/async/broadcast_stream_controller.dart ('k') | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/future.dart
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index 9d56057e1be4fd44e9698446cce64fe21ede99c6..2decb7242a462e7f3a17d3d050749168c3b2e55f 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -261,7 +261,7 @@ abstract class Future<T> {
* See also [Completer] for a way to create and complete a future at a
* later time that isn't necessarily after a known fixed duration.
*/
- factory Future.delayed(Duration duration, [computation()]) {
+ factory Future.delayed(Duration duration, [FutureOr<T> computation()]) {
_Future<T> result = new _Future<T>();
new Timer(duration, () {
try {
@@ -422,7 +422,7 @@ abstract class Future<T> {
* If [f] returns a non-[Future], iteration continues immediately. Otherwise
* it waits for the returned [Future] to complete.
*/
- static Future forEach<T>(Iterable<T> input, f(T element)) {
+ static Future forEach<T>(Iterable<T> input, dynamic f(T element)) {
var iterator = input.iterator;
return doWhile(() {
if (!iterator.moveNext()) return false;
@@ -445,7 +445,7 @@ abstract class Future<T> {
* The [f] function must return either a `bool` value or a [Future] completing
* with a `bool` value.
*/
- static Future doWhile(f()) {
+ static Future doWhile(FutureOr<bool> f()) {
_Future doneSignal = new _Future();
var nextIteration;
// Bind this callback explicitly so that each iteration isn't bound in the
@@ -599,7 +599,7 @@ abstract class Future<T> {
* });
* }
*/
- Future<T> whenComplete(action());
+ Future<T> whenComplete(dynamic action());
/**
* Creates a [Stream] containing the result of this future.
@@ -626,7 +626,7 @@ abstract class Future<T> {
* If `onTimeout` is omitted, a timeout will cause the returned future to
* complete with a [TimeoutException].
*/
- Future<T> timeout(Duration timeLimit, {onTimeout()});
+ Future<T> timeout(Duration timeLimit, {FutureOr<T> onTimeout()});
}
/**
« no previous file with comments | « sdk/lib/async/broadcast_stream_controller.dart ('k') | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698