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

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

Issue 2996573002: fix #28988, remove throw on Dart1 incompatible is-checks for dartdevc (Closed)
Patch Set: fix changelog Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// This library adapts ES6 generators to implement Dart's async/await. 5 /// This library adapts ES6 generators to implement Dart's async/await.
6 /// It's designed to interact with Dart's Future/Stream and follow Dart 6 /// It's designed to interact with Dart's Future/Stream and follow Dart
7 /// async/await semantics. 7 /// async/await semantics.
8 /// See https://github.com/dart-lang/sdk/issues/27315 for ideas on 8 /// See https://github.com/dart-lang/sdk/issues/27315 for ideas on
9 /// reconciling Dart's Future and ES6 Promise. 9 /// reconciling Dart's Future and ES6 Promise.
10 /// Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a 10 /// Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Wraps if future is not a native Future. 55 // Wraps if future is not a native Future.
56 if (_getRawClassType(future) !== _FutureType) { 56 if (_getRawClassType(future) !== _FutureType) {
57 future = $Future.value(future); 57 future = $Future.value(future);
58 } 58 }
59 // Chain the Future so `await` receives the Future's value. 59 // Chain the Future so `await` receives the Future's value.
60 return future.then($dynamic)(onValue, {onError: onError}); 60 return future.then($dynamic)(onValue, {onError: onError});
61 } 61 }
62 let result = FutureT.microtask(function() { 62 let result = FutureT.microtask(function() {
63 iter = $gen.apply(null, $args)[Symbol.iterator](); 63 iter = $gen.apply(null, $args)[Symbol.iterator]();
64 var result = onValue(); 64 var result = onValue();
65 if ($strongInstanceOf(result, FutureT) == null) { 65 if ($isSubtype($getReifiedType(result), FutureT) == null) {
66 // Chain the Future<dynamic> to a Future<T> to produce the correct 66 // Chain the Future<dynamic> to a Future<T> to produce the correct
67 // final type. 67 // final type.
68 return result.then($T)((x) => x, {onError: onError}); 68 return result.then($T)((x) => x, {onError: onError});
69 } else { 69 } else {
70 return result; 70 return result;
71 } 71 }
72 }); 72 });
73 // TODO(jmesserly): optimize this further. 73 // TODO(jmesserly): optimize this further.
74 _FutureType = _getRawClassType(result); 74 _FutureType = _getRawClassType(result);
75 return result; 75 return result;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 237 }
238 if (!this.controller.hasListener) return; 238 if (!this.controller.hasListener) return;
239 this.controller.addError(error, stackTrace); 239 this.controller.addError(error, stackTrace);
240 } 240 }
241 } 241 }
242 '''); 242 ''');
243 243
244 /// Returns a Stream of T implemented by an async* function. 244 /// Returns a Stream of T implemented by an async* function.
245 asyncStar(gen, T, @rest args) => JS('', 'new #(#, #, #).controller.stream', 245 asyncStar(gen, T, @rest args) => JS('', 'new #(#, #, #).controller.stream',
246 _AsyncStarStreamController, gen, T, args); 246 _AsyncStarStreamController, gen, T, args);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698