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

Side by Side Diff: tests/compiler/dart2js/closure/data/captured_variable.dart

Issue 3009903002: Pass in `this` as a free variable to the closure class (Closed)
Patch Set: merge with master Created 3 years, 3 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /*readParameterInAnonymousClosure:*/ 5 /*readParameterInAnonymousClosure:*/
6 readParameterInAnonymousClosure(/**/ parameter) { 6 readParameterInAnonymousClosure(/**/ parameter) {
7 return /*free=[parameter]*/ () => parameter; 7 return /*free=[parameter]*/ () => parameter;
8 } 8 }
9 9
10 /*readParameterInClosure:*/ 10 /*readParameterInClosure:*/
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 writeLocalInClosure(/**/ parameter) { 55 writeLocalInClosure(/**/ parameter) {
56 // ignore: UNUSED_LOCAL_VARIABLE 56 // ignore: UNUSED_LOCAL_VARIABLE
57 var /*boxed*/ local = parameter; 57 var /*boxed*/ local = parameter;
58 /*free=[box0,local]*/ func() { 58 /*free=[box0,local]*/ func() {
59 local = 45; 59 local = 45;
60 } 60 }
61 61
62 return func; 62 return func;
63 } 63 }
64 64
65 class Foo {
66 int /*Foo.bar:hasThis*/ bar = 4;
67
68 /*Foo.baz:hasThis*/ baz() {
69 /*free=[this],hasThis*/ func() => bar;
70 return func;
71 }
72 }
73
65 main() { 74 main() {
66 readParameterInAnonymousClosure(null); 75 readParameterInAnonymousClosure(null);
67 readParameterInClosure(null); 76 readParameterInClosure(null);
68 writeParameterInAnonymousClosure(null); 77 writeParameterInAnonymousClosure(null);
69 writeParameterInClosure(null); 78 writeParameterInClosure(null);
70 readLocalInAnonymousClosure(null); 79 readLocalInAnonymousClosure(null);
71 readLocalInClosure(null); 80 readLocalInClosure(null);
72 writeLocalInAnonymousClosure(null); 81 writeLocalInAnonymousClosure(null);
73 writeLocalInClosure(null); 82 writeLocalInClosure(null);
83 new Foo().baz();
74 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698