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 captured variables are boxed regardless of where they are mutated. |
| 6 |
| 7 /*mutateUnused:*/ |
| 8 mutateUnused() { |
| 9 var local; |
| 10 /**/ () { |
| 11 // Use nothing. |
| 12 }; |
| 13 local = 42; |
| 14 return local; |
| 15 } |
| 16 |
| 17 /*mutateInClosure:box=box0,boxed=[local]*/ |
| 18 mutateInClosure() { |
| 19 var /*boxed*/ local; |
| 20 /*free=[box0,local]*/ () { |
| 21 local = 42; |
| 22 }; |
| 23 return local; |
| 24 } |
| 25 |
| 26 /*mutateOutsideClosure:box=box0,boxed=[local]*/ |
| 27 mutateOutsideClosure() { |
| 28 var /*boxed*/ local; |
| 29 /*free=[box0,local]*/ () { |
| 30 print(local); |
| 31 }; |
| 32 local = 42; |
| 33 return local; |
| 34 } |
| 35 |
| 36 /*mutateInOtherClosure:box=box0,boxed=[local]*/ |
| 37 mutateInOtherClosure() { |
| 38 var /*boxed*/ local; |
| 39 /*free=[box0,local]*/ () { |
| 40 print(local); |
| 41 }; |
| 42 /*free=[box0,local]*/ () { |
| 43 local = 42; |
| 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 return local; |
| 58 } |
| 59 |
| 60 main() { |
| 61 mutateUnused(); |
| 62 mutateInClosure(); |
| 63 mutateOutsideClosure(); |
| 64 mutateInOtherClosure(); |
| 65 mutateInNestedClosure(); |
| 66 } |
OLD | NEW |