Chromium Code Reviews| Index: tests/compiler/dart2js/closure/data/mixed.dart |
| diff --git a/tests/compiler/dart2js/closure/data/mixed.dart b/tests/compiler/dart2js/closure/data/mixed.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1d4cc15b08efda81723ff54dca34ea517c9e062a |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/closure/data/mixed.dart |
| @@ -0,0 +1,71 @@ |
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// Test that free variables aren't mixed between capturing and non-capturing |
| +// closures. |
| + |
| +/*mutateInClosure:box=box0,boxed=[local]*/ |
|
Siggi Cherem (dart-lang)
2017/08/28 17:33:45
nit: consider using a different variable name - I
|
| +mutateInClosure() { |
| + var /*boxed*/ local; |
| + /*free=[box0,local]*/ () { |
| + local = 42; |
| + }; |
| + /**/ () { |
| + // Use nothing. |
| + }; |
| + return local; |
| +} |
| + |
| +/*mutateOutsideClosure:box=box0,boxed=[local]*/ |
| +mutateOutsideClosure() { |
| + var /*boxed*/ local; |
| + /*free=[box0,local]*/ () { |
| + print(local); |
| + }; |
| + /**/ () { |
| + // Use nothing. |
| + }; |
| + local = 42; |
| + return local; |
| +} |
| + |
| +/*mutateInOtherClosure:box=box0,boxed=[local]*/ |
| +mutateInOtherClosure() { |
| + var /*boxed*/ local; |
| + /*free=[box0,local]*/ () { |
| + print(local); |
| + }; |
| + /*free=[box0,local]*/ () { |
| + local = 42; |
| + }; |
| + /**/ () { |
| + // Use nothing. |
| + }; |
| + return local; |
| +} |
| + |
| +/*mutateInNestedClosure:box=box0,boxed=[local]*/ |
| +mutateInNestedClosure() { |
| + var /*boxed*/ local; |
| + /*free=[box0,local]*/ () { |
| + print(local); |
| + /*free=[box0,local]*/ () { |
| + local = 42; |
| + }; |
| + /**/ () { |
| + // Use nothing. |
| + }; |
| + }; |
| + /**/ () { |
| + // Use nothing. |
| + }; |
| + return local; |
| +} |
| + |
| +main() { |
| + mutateInClosure(); |
| + mutateOutsideClosure(); |
| + mutateInOtherClosure(); |
| + mutateInNestedClosure(); |
| +} |