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

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart

Issue 2804113002: DDC fix for foreign futures (Closed)
Patch Set: Created 3 years, 8 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
Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart
index 2d6dbb9156673e6b413e796bbad74b4d1d59574c..bc5a719eb6b8fbac670e64ed9fd08828e033b096 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart
@@ -26,6 +26,8 @@ async_(gen, T, @rest args) => JS(
'',
'''(() => {
let iter;
+ let FutureT = ${getGenericClass(Future)}($T);
Jennifer Messerly 2017/04/06 20:01:52 const FutureT = ... ?
vsm 2017/04/06 21:31:32 Done.
+ let _Future = $Future.new(() => null).runtimeType;
vsm 2017/04/06 19:45:05 Is there a better way to get this type?
Jennifer Messerly 2017/04/06 20:01:52 good question. I'd do it like this: let _Futu
vsm 2017/04/06 21:31:32 Acknowledged.
function onValue(res) {
if (res === void 0) res = null;
return next(iter.next(res));
@@ -46,14 +48,13 @@ async_(gen, T, @rest args) => JS(
if (ret.done) {
return ret.value;
}
- // Checks if the awaited value is a Future.
- if (!$instanceOf(future, $Future)) {
+ // Wraps if future is not a native Future.
+ if (!$instanceOf(future, _Future)) {
Jennifer Messerly 2017/04/06 20:01:52 you could just match the exact runtime type here,
vsm 2017/04/06 21:31:32 I don't think that's quite right - _Future<int> !=
future = $Future.value(future);
}
// Chain the Future so `await` receives the Future's value.
return future.then($dynamic)(onValue, {onError: onError});
}
- let FutureT = ${getGenericClass(Future)(T)};
return FutureT.microtask(function() {
Jennifer Messerly 2017/04/06 20:01:52 let result = FutureT.microtask(function() { ... })
vsm 2017/04/06 21:31:32 Clever! Done with some slight mods.
iter = $gen.apply(null, $args)[Symbol.iterator]();
var result = onValue();
« no previous file with comments | « pkg/dev_compiler/test/codegen_expected/varargs.js ('k') | tests/language_strong/async_await_foreign_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698