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 // VMOptions=--constructor_name_check | 4 // VMOptions=--constructor_name_check |
5 | 5 |
6 class A { | 6 class A { |
7 // Constructor may not be static. | 7 // Constructor may not be static. |
8 static A(); /// 00: compile-time error | 8 static A(); /// 00: compile-time error |
9 | 9 |
10 // Factory may not be static. | 10 // Factory may not be static. |
11 static factory A() { return null; } /// 01: compile-time error | 11 static factory A() { return null; } /// 01: compile-time error |
12 | 12 |
13 // Constructor may not be abstract. | |
14 abstract A(); /// 02: compile-time error | |
15 | |
16 // Factory may not be abstract | |
17 abstract factory A() { return null; } /// 03: compile-time error | |
18 | |
19 // Named constructor may not conflict with names of methods and fields. | 13 // Named constructor may not conflict with names of methods and fields. |
20 var m; | 14 var m; |
21 A.m() { m = 0; } /// 04: compile-time error | 15 A.m() { m = 0; } /// 04: compile-time error |
22 | 16 |
23 set q(var value) { m = q; } | 17 set q(var value) { m = q; } |
24 A.q(); /// 05: compile-time error | 18 A.q(); /// 05: compile-time error |
25 | 19 |
26 A.foo() : m = 0; /// 06: compile-time error | 20 A.foo() : m = 0; /// 06: compile-time error |
27 int foo(int a, int b) => a + b * m; | 21 int foo(int a, int b) => a + b * m; |
28 } | 22 } |
29 | 23 |
30 main() { | 24 main() { |
31 new A(); | 25 new A(); |
32 } | 26 } |
OLD | NEW |