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

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

Issue 23793006: Handle Future result from Future.sync computation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nits from floitsch Created 7 years, 3 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/future.dart ('k') | tests/lib/async/future_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/future_impl.dart
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
index ea8f9027bd8494c05685abfb90eb9fcdc69c88b0..a149161ba7ffef83552ca26fc74ec103d644aaed 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -143,7 +143,8 @@ class _Future<T> implements Future<T> {
: _onValueCallback = null, _errorTestCallback = null,
_onErrorCallback = null, _whenCompleteActionCallback = null;
- _Future.immediate(T value)
+ /// Valid types for value: `T` or `Future<T>`.
+ _Future.immediate(value)
: _onValueCallback = null, _errorTestCallback = null,
_onErrorCallback = null, _whenCompleteActionCallback = null {
_asyncComplete(value);
@@ -321,6 +322,14 @@ class _Future<T> implements Future<T> {
// Otherwise the value could complete with an error and report an
// unhandled error, even though we know we are already going to listen to
// it.
+
+ // Assign to typed variables so we get earlier checks in checked mode.
+ if (value is Future) {
+ Future<T> typedFuture = value;
+ } else {
+ T typedValue = value;
+ }
+
if (value is Future &&
(value is! _Future || !(value as _Future)._isComplete)) {
// Case 2 from above. We need to register.
« no previous file with comments | « sdk/lib/async/future.dart ('k') | tests/lib/async/future_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698