OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Redirection constructors must not have a function body. | 4 // Redirection constructors must not have a function body. |
5 | 5 |
6 class A { | 6 class A { |
7 var x; | 7 var x; |
8 A(this.x) {} | 8 A(this.x) {} |
9 | 9 |
10 // Redirecting constructor must not have a function body. | 10 // Redirecting constructor must not have a function body. |
11 A.illegalBody(x) : this(3) {} // /// 01: compile-time error | 11 A.illegalBody(x) : this(3) {} // //# 01: compile-time error |
12 | 12 |
13 // Redirecting constructor must not initialize any fields. | 13 // Redirecting constructor must not initialize any fields. |
14 A.illegalInit() : this(3), x = 5; // /// 02: compile-time error | 14 A.illegalInit() : this(3), x = 5; // //# 02: compile-time error |
15 | 15 |
16 // Redirecting constructor must not have initializing formal parameters. | 16 // Redirecting constructor must not have initializing formal parameters. |
17 A.illegalFormal(this.x) : this(3); // /// 03: compile-time error | 17 A.illegalFormal(this.x) : this(3); // //# 03: compile-time error |
18 | 18 |
19 // Redirection constructors must not call super constructor. | 19 // Redirection constructors must not call super constructor. |
20 A.illegalSuper() : this(3), super(3); // /// 04: compile-time error | 20 A.illegalSuper() : this(3), super(3); // //# 04: compile-time error |
21 } | 21 } |
22 | 22 |
23 main() { | 23 main() { |
24 new A(3); | 24 new A(3); |
25 new A.illegalBody(10); // /// 01: continued | 25 new A.illegalBody(10); // //# 01: continued |
26 new A.illegalInit(); // /// 02: continued | 26 new A.illegalInit(); // //# 02: continued |
27 new A.illegalFormal(10); // /// 03: continued | 27 new A.illegalFormal(10); // //# 03: continued |
28 new A.illegalSuper(); // /// 04: continued | 28 new A.illegalSuper(); // //# 04: continued |
29 } | 29 } |
OLD | NEW |