OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library constructor_test; |
| 6 |
| 7 void main() { |
| 8 var a = new A(); |
| 9 print(a.foo); |
| 10 print('******************'); |
| 11 |
| 12 var b = new B(); |
| 13 print(b.foo); |
| 14 print(b.bar); |
| 15 } |
| 16 |
| 17 class A { |
| 18 String foo = fieldInitializer(0, 'A.foo'); |
| 19 |
| 20 A() : foo = fieldInitializer(1, 'A.foo') { |
| 21 foo = fieldInitializer(2, 'A.foo'); |
| 22 } |
| 23 } |
| 24 |
| 25 class B extends A { |
| 26 String bar = fieldInitializer(0, 'B.bar'); |
| 27 |
| 28 B() : bar = fieldInitializer(1, 'B.bar') { |
| 29 bar = fieldInitializer(2, 'B.bar'); |
| 30 } |
| 31 } |
| 32 |
| 33 String fieldInitializer(int f, String s) { |
| 34 print('$s: $f'); |
| 35 return '$s: $f'; |
| 36 } |
OLD | NEW |