OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 | 4 |
5 library fieldtest; | 5 library fieldtest; |
6 | 6 |
7 class A { | 7 class A { |
8 int x = 42; | 8 int x = 42; |
9 } | 9 } |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 int compute() => 123; | 29 int compute() => 123; |
30 int y = compute() + 444; | 30 int y = compute() + 444; |
31 | 31 |
32 String get q => 'life, ' + 'the universe ' + 'and everything'; | 32 String get q => 'life, ' + 'the universe ' + 'and everything'; |
33 int get z => 42; | 33 int get z => 42; |
34 void set z(value) { | 34 void set z(value) { |
35 y = value; | 35 y = value; |
36 } | 36 } |
37 | 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 |
38 void main() { | 48 void main() { |
39 var a = new A(); | 49 var a = new A(); |
40 foo(a); | 50 foo(a); |
41 bar(a); | 51 bar(a); |
42 print(baz(a)); | 52 print(baz(a)); |
43 } | 53 } |
OLD | NEW |