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

Unified Diff: lib/src/compiler/code_generator.dart

Issue 1997473002: Future flattening at runtime. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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 | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/classes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/code_generator.dart
diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart
index 2445a11e873482df0803669a459da25cb287c3ed..8a97a278c6114a34e3a048de9a9dd36cedc82799 100644
--- a/lib/src/compiler/code_generator.dart
+++ b/lib/src/compiler/code_generator.dart
@@ -801,14 +801,13 @@ class CodeGenerator extends GeneralizingAstVisitor
JS.Statement _defineClassTypeArguments(TypeDefiningElement element,
List<TypeParameterElement> formals, JS.Statement body) {
assert(formals.isNotEmpty);
- var genericDef =
- js.statement('# = dart.generic((#) => { #; return #; });', [
- _emitTopLevelName(element, suffix: r'$'),
- _emitTypeFormals(formals),
- body,
- element.name
- ]);
-
+ var genericCall = js.call('dart.generic((#) => { #; return #; })',
+ [_emitTypeFormals(formals), body, element.name]);
+ if (element.type.isDartAsyncFuture) {
+ genericCall = js.call('dart.flattenFutures(#)', [genericCall]);
+ }
+ var genericDef = js.statement(
+ '# = #;', [_emitTopLevelName(element, suffix: r'$'), genericCall]);
var dynType = fillDynamicTypeArgs(element.type);
var genericInst = _emitType(dynType, lowerGeneric: true);
return js.statement(
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/classes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698