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

Unified Diff: lib/runtime/dart_sdk.js

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:
Download patch
« no previous file with comments | « no previous file | lib/src/compiler/code_generator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart_sdk.js
diff --git a/lib/runtime/dart_sdk.js b/lib/runtime/dart_sdk.js
index 83c6a079994205934655f5f785766889845cf6ec..2bf3a3670528a403fdb1b9892be69cb3cae128fc 100644
--- a/lib/runtime/dart_sdk.js
+++ b/lib/runtime/dart_sdk.js
@@ -59,6 +59,18 @@ dart_library.library('dart_sdk', null, /* Imports */[
dart.getImplements = function(clazz) {
return clazz[dart.implements];
};
+ dart.flattenFutures = function(builder) {
+ function flatten(T) {
+ if (!T) return builder(dart.dynamic);
+ let futureClass = dart.getGenericClass(async.Future);
+ if (dart.getGenericClass(T) == futureClass) {
+ let args = dart.getGenericArgs(T);
+ if (args) return builder(args[0]);
+ }
+ return builder(T);
+ }
+ return flatten;
+ };
dart.generic = function(typeConstructor) {
let length = typeConstructor.length;
if (length < 1) {
@@ -14900,7 +14912,7 @@ dart_library.library('dart_sdk', null, /* Imports */[
});
const _completeWithValue = Symbol('_completeWithValue');
let const$3;
- async.Future$ = dart.generic(T => {
+ async.Future$ = dart.flattenFutures(dart.generic(T => {
class Future extends core.Object {
static new(computation) {
let result = new (async._Future$(T))();
@@ -15083,7 +15095,7 @@ dart_library.library('dart_sdk', null, /* Imports */[
names: ['wait', 'any', 'forEach', 'doWhile']
});
return Future;
- });
+ }));
async.Future = async.Future$();
dart.defineLazy(async.Future, {
get _nullFuture() {
« no previous file with comments | « no previous file | lib/src/compiler/code_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698