| 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 object_super_test; |
| 6 |
| 7 /// Simple program creating an object with super constructor invocation. |
| 8 void main() { |
| 9 var a = new A.withArgs(0); |
| 10 print(a.foo); |
| 11 |
| 12 var b1 = new B.withSuper(); |
| 13 print(b1.foo); |
| 14 print(b1.bar); |
| 15 |
| 16 var b2 = new B(); |
| 17 print(b2.foo); |
| 18 print(b2.bar); |
| 19 } |
| 20 |
| 21 class A { |
| 22 String foo; |
| 23 |
| 24 A() : this.withArgs(0); |
| 25 A.withArgs(int i) : foo = fieldInitializer(i, 'A.foo'); |
| 26 } |
| 27 |
| 28 class B extends A { |
| 29 String bar; |
| 30 |
| 31 B(); |
| 32 B.withSuper() |
| 33 : bar = fieldInitializer(0, 'B.bar'), |
| 34 super.withArgs(1); |
| 35 } |
| 36 |
| 37 String fieldInitializer(int f, String s) { |
| 38 print('$s: $f'); |
| 39 return '$s: $f'; |
| 40 } |
| OLD | NEW |