OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Check that initializers are not duplicated | 4 // Check that initializers are not duplicated |
5 | 5 |
6 class Class { | 6 class Class { |
7 Class(var v) : field_ = v | 7 Class(var v) : field_ = v |
8 // Test against duplicate final field initializaion in initializing list. | 8 // Test against duplicate final field initialization in initializing list. |
9 , field_ = 2 // //# 01: compile-time error | 9 , field_ = 2 // //# 01: compile-time error |
10 ; | 10 ; |
11 Class.field(this.field_) | 11 Class.field(this.field_) |
12 // Test against duplicate final field initialization between initializing | 12 // Test against duplicate final field initialization between initializing |
13 // formals and initializer list. | 13 // formals and initializer list. |
14 : field_ = 2 // //# 02: compile-time error | 14 : field_ = 2 // //# 02: compile-time error |
15 ; | 15 ; |
16 // Test against duplicate final field initialization in initializing formals. | 16 // Test against duplicate final field initialization in initializing formals. |
17 Class.two_fields(this.field_ | 17 Class.two_fields(this.field_ |
18 , this.field_ //# 03: compile-time error | 18 , this.field_ //# 03: compile-time error |
19 ); | 19 ); |
20 final field_; | 20 final field_; |
21 } | 21 } |
22 | 22 |
23 main() { | 23 main() { |
24 new Class(42); | 24 new Class(42); |
25 new Class.field(42); | 25 new Class.field(42); |
26 new Class.two_fields(42 | 26 new Class.two_fields(42 |
27 , 42 // //# 03: continued | 27 , 42 // //# 03: continued |
28 ); | 28 ); |
29 } | 29 } |
OLD | NEW |