Chromium Code Reviews| 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(); |