OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // Test that free variables aren't mixed between capturing and non-capturing | |
6 // closures. | |
7 | |
8 /*mutateInClosure:box=box0,boxed=[local]*/ | |
Siggi Cherem (dart-lang)
2017/08/28 17:33:45
nit: consider using a different variable name - I
| |
9 mutateInClosure() { | |
10 var /*boxed*/ local; | |
11 /*free=[box0,local]*/ () { | |
12 local = 42; | |
13 }; | |
14 /**/ () { | |
15 // Use nothing. | |
16 }; | |
17 return local; | |
18 } | |
19 | |
20 /*mutateOutsideClosure:box=box0,boxed=[local]*/ | |
21 mutateOutsideClosure() { | |
22 var /*boxed*/ local; | |
23 /*free=[box0,local]*/ () { | |
24 print(local); | |
25 }; | |
26 /**/ () { | |
27 // Use nothing. | |
28 }; | |
29 local = 42; | |
30 return local; | |
31 } | |
32 | |
33 /*mutateInOtherClosure:box=box0,boxed=[local]*/ | |
34 mutateInOtherClosure() { | |
35 var /*boxed*/ local; | |
36 /*free=[box0,local]*/ () { | |
37 print(local); | |
38 }; | |
39 /*free=[box0,local]*/ () { | |
40 local = 42; | |
41 }; | |
42 /**/ () { | |
43 // Use nothing. | |
44 }; | |
45 return local; | |
46 } | |
47 | |
48 /*mutateInNestedClosure:box=box0,boxed=[local]*/ | |
49 mutateInNestedClosure() { | |
50 var /*boxed*/ local; | |
51 /*free=[box0,local]*/ () { | |
52 print(local); | |
53 /*free=[box0,local]*/ () { | |
54 local = 42; | |
55 }; | |
56 /**/ () { | |
57 // Use nothing. | |
58 }; | |
59 }; | |
60 /**/ () { | |
61 // Use nothing. | |
62 }; | |
63 return local; | |
64 } | |
65 | |
66 main() { | |
67 mutateInClosure(); | |
68 mutateOutsideClosure(); | |
69 mutateInOtherClosure(); | |
70 mutateInNestedClosure(); | |
71 } | |
OLD | NEW |