OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, 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 import "package:expect/expect.dart"; |
| 6 |
| 7 // Checks that abstract instance methods are correctly resolved. |
| 8 |
| 9 int get length => throw "error: top-level getter called"; |
| 10 int set height(x) { throw "error: top-level setter called"; } |
| 11 width() { throw "error: top-level function called"; } |
| 12 |
| 13 class A { |
| 14 int get length; // Abstract instance getter. |
| 15 int set height(x); // Abstract instance setter. |
| 16 int width(); // Abstract instance method. |
| 17 |
| 18 // Must resolve to non-abstract length getter in subclass. |
| 19 get useLength => length; |
| 20 // Must resolve to non-abstract height setter in subclass. |
| 21 setHeight(x) => height = x; |
| 22 // Must resolve to non-abstract width() method in subclass. |
| 23 useWidth() => width(); |
| 24 } |
| 25 |
| 26 class A1 extends A { |
| 27 int length; // Implies a length getter. |
| 28 int height; // Implies a height setter. |
| 29 int width() => 345; |
| 30 A1(this.length); |
| 31 } |
| 32 |
| 33 main() { |
| 34 var a = new A1(123); |
| 35 Expect.equals(123, a.useLength); |
| 36 a.setHeight(234); |
| 37 Expect.equals(234, a.height); |
| 38 Expect.equals(345, a.useWidth()); |
| 39 print([a.useLength, a.height, a.useWidth()]); |
| 40 } |
| 41 |
OLD | NEW |