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

Unified Diff: pkg/kernel/lib/transformations/closure/converter.dart

Issue 3000333002: Fix several bugs in closure conversion. (Closed)
Patch Set: Fix bugs. 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 side-by-side diff with in-line comments
Download patch
Index: pkg/kernel/lib/transformations/closure/converter.dart
diff --git a/pkg/kernel/lib/transformations/closure/converter.dart b/pkg/kernel/lib/transformations/closure/converter.dart
index 42def515583d11852bb3139399e9ea55655981c2..66820d3fbdd50db2e70ee9e227fb306a21fa1d0c 100644
--- a/pkg/kernel/lib/transformations/closure/converter.dart
+++ b/pkg/kernel/lib/transformations/closure/converter.dart
@@ -6,6 +6,7 @@ library kernel.transformations.closure.converter;
import '../../ast.dart'
show
+ AsyncMarker,
Arguments,
Block,
Catch,
@@ -347,6 +348,10 @@ class ClosureConverter extends Transformer {
}
Expression handleLocalFunction(FunctionNode function) {
+ if (function.asyncMarker == AsyncMarker.SyncYielding) {
+ function.transformChildren(this);
+ return new FunctionExpression(function);
+ }
FunctionNode enclosingFunction = currentFunction;
Map<TypeParameter, DartType> enclosingTypeSubstitution = typeSubstitution;
currentFunction = function;
@@ -554,6 +559,11 @@ class ClosureConverter extends Transformer {
TreeNode visitBlock(Block node) {
return saveContext(() {
BlockRewriter blockRewriter = rewriter = rewriter.forNestedBlock(node);
+ if (node.parent is Statement &&
+ (node.parent as Statement).isLoop &&
+ context is! NoContext) {
+ context = context.toNestedContext();
+ }
blockRewriter.transformStatements(this);
return node;
});

Powered by Google App Engine
This is Rietveld 408576698