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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 916403002: cps2js: Fix translation of captured 'this'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 years, 10 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 | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
index 366f409a5402c530d03bb36588e4ee3a58807736..e45762e17e6cc81c29a39a56869bd915c10d8273 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -1822,7 +1822,12 @@ class JsIrBuilder extends IrBuilder {
ir.Primitive buildFunctionExpression(ClosureClassElement classElement) {
List<ir.Primitive> arguments = <ir.Primitive>[];
for (ClosureFieldElement field in classElement.closureFields) {
- arguments.add(environment.lookup(field.local));
+ // Captured 'this' is not available as a local in the current environment,
+ // so treat that specially.
+ ir.Primitive value = field.local is ThisLocal
+ ? buildThis()
+ : environment.lookup(field.local);
+ arguments.add(value);
}
ir.Primitive closure = new ir.CreateInstance(classElement, arguments);
add(new ir.LetPrim(closure));
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698