| Index: pkg/kernel/testcases/closures_initializers/initializers.dart
|
| diff --git a/pkg/kernel/testcases/closures_initializers/initializers.dart b/pkg/kernel/testcases/closures_initializers/initializers.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..82d9285e83d55774271d01ff47a3821ae94fd7e1
|
| --- /dev/null
|
| +++ b/pkg/kernel/testcases/closures_initializers/initializers.dart
|
| @@ -0,0 +1,35 @@
|
| +// 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.
|
| +
|
| +// The purpose of this test is to detect that closures in [LocalInitializer]s
|
| +// and [FieldInitializer]s are properly converted. This test assumes that
|
| +// [ArgumentExtractionForRedirecting] transformer was run before closure
|
| +// conversion. It should introduce one [LocalInitializer] for each argument
|
| +// passed to the redirecting constructor. If such argument contains a closure,
|
| +// it would appear in a [LocalInitializer]. The [FieldInitializer] example
|
| +// requires no such elaboration.
|
| +
|
| +class X {}
|
| +
|
| +// Closure in field initializer.
|
| +//
|
| +class A {
|
| + X foo;
|
| + A(X i) : foo = ((() => i)());
|
| +}
|
| +
|
| +// Closure in local initializer.
|
| +//
|
| +class B {
|
| + X foo;
|
| + B.named(X foo) {}
|
| + B(X foo) : this.named((() => foo)());
|
| +}
|
| +
|
| +main() {
|
| + A a = new A(new X());
|
| + a.foo; // To prevent dartanalyzer from marking [a] as unused.
|
| + B b = new B(new X());
|
| + b.foo;
|
| +}
|
|
|