OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, 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 fields; |
| 6 |
| 7 init(x) { |
| 8 print(x); |
| 9 return x; |
| 10 } |
| 11 |
| 12 class Base { |
| 13 var x = init('Base.x'); |
| 14 } |
| 15 class Mixin1 { |
| 16 var x = init('Mixin1.x'); |
| 17 } |
| 18 class Mixin2 { |
| 19 var x = init('Mixin2.x'); |
| 20 } |
| 21 class Derived extends Base with Mixin1, Mixin2 { |
| 22 var x = init('Derived.x'); |
| 23 } |
| 24 |
| 25 // Private within the same library also needs this treatment. |
| 26 class _Base { |
| 27 var x = init('_Base.x'); |
| 28 } |
| 29 class _Mixin1 { |
| 30 var _x = init('_Mixin1.x'); |
| 31 } |
| 32 class _Mixin2 { |
| 33 var _x = init('_Mixin2.x'); |
| 34 } |
| 35 class _Derived extends _Base with _Mixin1, _Mixin2 { |
| 36 var _x = init('_Derived.x'); |
| 37 } |
| 38 |
| 39 |
| 40 main() { |
| 41 print('Creating Derived'); |
| 42 print('Derived.x == ' + new Derived().x); |
| 43 print('Creating _Derived'); |
| 44 print('_Derived.x == ' + new _Derived()._x); |
| 45 } |
OLD | NEW |