mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 13:22:01 +00:00
14011f47e3
They're back from the grave, and ready to party! Change-Id: I088134a9be7ecabf1fbf751c015a656a15cabff9 Reviewed-on: https://dart-review.googlesource.com/12821 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: William Hesse <whesse@google.com>
46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
// Checks that abstract instance methods are correctly resolved.
|
|
|
|
int get length => throw "error: top-level getter called";
|
|
set height(x) {
|
|
throw "error: top-level setter called";
|
|
}
|
|
|
|
width() {
|
|
throw "error: top-level function called";
|
|
}
|
|
|
|
abstract class A {
|
|
int get length; // Abstract instance getter.
|
|
set height(x); // Abstract instance setter.
|
|
int width(); // Abstract instance method.
|
|
|
|
// Must resolve to non-abstract length getter in subclass.
|
|
get useLength => length;
|
|
// Must resolve to non-abstract height setter in subclass.
|
|
setHeight(x) => height = x;
|
|
// Must resolve to non-abstract width() method in subclass.
|
|
useWidth() => width();
|
|
}
|
|
|
|
class A1 extends A {
|
|
int length; // Implies a length getter.
|
|
int height; // Implies a height setter.
|
|
int width() => 345;
|
|
A1(this.length);
|
|
}
|
|
|
|
main() {
|
|
var a = new A1(123);
|
|
Expect.equals(123, a.useLength);
|
|
a.setHeight(234);
|
|
Expect.equals(234, a.height);
|
|
Expect.equals(345, a.useWidth());
|
|
print([a.useLength, a.height, a.useWidth()]);
|
|
}
|