| 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 fieldtest; | |
| 6 | |
| 7 class A { | |
| 8 int x = 42; | |
| 9 } | |
| 10 | |
| 11 class B<T> { | |
| 12 int x; | |
| 13 num y; | |
| 14 T z; | |
| 15 } | |
| 16 | |
| 17 int foo(A a) { | |
| 18 print(a.x); | |
| 19 return a.x; | |
| 20 } | |
| 21 | |
| 22 int bar(a) { | |
| 23 print(a.x); | |
| 24 return a.x; | |
| 25 } | |
| 26 | |
| 27 baz(A a) => a.x; | |
| 28 | |
| 29 int compute() => 123; | |
| 30 int y = compute() + 444; | |
| 31 | |
| 32 String get q => 'life, ' + 'the universe ' + 'and everything'; | |
| 33 int get z => 42; | |
| 34 void set z(value) { | |
| 35 y = value; | |
| 36 } | |
| 37 | |
| 38 // Supported: use field to implement a getter | |
| 39 abstract class BaseWithGetter { | |
| 40 int get foo => 1; | |
| 41 int get bar; | |
| 42 } | |
| 43 class Derived extends BaseWithGetter { | |
| 44 int foo = 2; | |
| 45 int bar = 3; | |
| 46 } | |
| 47 | |
| 48 class Generic<T> { | |
| 49 foo(T t) => print(bar + (t as String)); | |
| 50 | |
| 51 static String bar = 'hello'; | |
| 52 } | |
| 53 | |
| 54 class StaticFieldOrder1 { | |
| 55 static const a = b + 1; | |
| 56 static const c = d + 2; | |
| 57 static const b = c + 3; | |
| 58 static const d = 4; | |
| 59 } | |
| 60 class StaticFieldOrder2 { | |
| 61 static const a = StaticFieldOrder2.b + 1; | |
| 62 static const c = StaticFieldOrder2.d + 2; | |
| 63 static const b = StaticFieldOrder2.c + 3; | |
| 64 static const d = 4; | |
| 65 } | |
| 66 | |
| 67 enum MyEnum { Val1, Val2, Val3, Val4 } | |
| 68 | |
| 69 void main() { | |
| 70 var a = new A(); | |
| 71 foo(a); | |
| 72 bar(a); | |
| 73 print(baz(a)); | |
| 74 | |
| 75 print(new Generic<String>().foo(' world')); | |
| 76 | |
| 77 print(MyEnum.values); | |
| 78 } | |
| OLD | NEW |