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

Side by Side Diff: pkg/kernel/testcases/closures_initializers/local_initializers.dart

Issue 2971293002: Fix closure conversion in field and local initializers. (Closed)
Patch Set: Created 3 years, 5 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 // The purpose of this test is to detect that closures in [LocalInitializer]s 5 // The purpose of this test is to detect that closures in [LocalInitializer]s
6 // are properly converted. This test assumes that 6 // are properly converted. This test assumes that
7 // [ArgumentExtractionForRedirecting] transformer was run before closure 7 // [ArgumentExtractionForRedirecting] transformer was run before closure
8 // conversion. It should introduce one [LocalInitializer] for each argument 8 // conversion. It should introduce one [LocalInitializer] for each argument
9 // passed to the redirecting constructor. If such argument contains a closure, 9 // passed to the redirecting constructor. If such argument contains a closure,
10 // it would appear in a [LocalInitializer]. 10 // it would appear in a [LocalInitializer].
11 11
12 class X {} 12 class X {}
13 13
14 // Closure in field initializer.
Dmitry Stefantsov 2017/07/07 09:47:47 I would split this test in two or change the name
15 //
14 class A { 16 class A {
15 X foo; 17 X foo;
16 A.named(X foo) {} 18 A(X i) : foo = ((() => i)());
17 A(X foo) : this.named((() => foo)()); 19 }
20
21 // Closure in local initializer.
22 //
23 class B {
24 X foo;
25 B.named(X foo) {}
26 B(X foo) : this.named((() => foo)());
18 } 27 }
19 28
20 main() { 29 main() {
21 A a = new A(new X()); 30 A a = new A(new X());
22 a.foo; // To prevent dartanalyzer from marking [a] as unused. 31 a.foo; // To prevent dartanalyzer from marking [a] as unused.
32 B b = new B(new X());
33 b.foo;
23 } 34 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698