| 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 | |
| 7 class Class { | 6 class Class { |
| 8 Class(var v) | 7 Class(var v) : field_ = v |
| 9 : field_ = v | 8 // Test against duplicate final field initializaion in initializing list. |
| 10 // Test against duplicate final field initializaion in initializing list. | |
| 11 , field_ = 2 // //# 01: compile-time error | 9 , field_ = 2 // //# 01: compile-time error |
| 12 ; | 10 ; |
| 13 Class.field(this.field_) | 11 Class.field(this.field_) |
| 14 // Test against duplicate final field initialization between initializing | 12 // Test against duplicate final field initialization between initializing |
| 15 // formals and initializer list. | 13 // formals and initializer list. |
| 16 : field_ = 2 // //# 02: compile-time error | 14 : field_ = 2 // //# 02: compile-time error |
| 17 ; | 15 ; |
| 18 // Test against duplicate final field initialization in initializing formals. | 16 // Test against duplicate final field initialization in initializing formals. |
| 19 Class.two_fields(this.field_ | 17 Class.two_fields(this.field_ |
| 20 , this.field_ //# 03: compile-time error | 18 , this.field_ //# 03: compile-time error |
| 21 ); | 19 ); |
| 22 final field_; | 20 final field_; |
| 23 } | 21 } |
| 24 | 22 |
| 25 main() { | 23 main() { |
| 26 new Class(42); | 24 new Class(42); |
| 27 new Class.field(42); | 25 new Class.field(42); |
| 28 new Class.two_fields(42 | 26 new Class.two_fields(42 |
| 29 , 42 // //# 03: continued | 27 , 42 // //# 03: continued |
| 30 ); | 28 ); |
| 31 } | 29 } |
| OLD | NEW |