41a884315f
The annotation has no semantics related to these tests, and the tests will be cleaner without the extra code. Change-Id: I0f31a30af624d2af707eae3003acb09a742bef3f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152612 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
86 lines
2.1 KiB
Dart
86 lines
2.1 KiB
Dart
// Copyright (c) 2013, 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";
|
|
|
|
class A {
|
|
var foo;
|
|
A(this.foo);
|
|
|
|
B_Sfoo() => 'A.B_Sfoo()';
|
|
}
|
|
|
|
class B extends A {
|
|
B(x) : super(x);
|
|
|
|
B_Sfoo() => super.foo;
|
|
BC_Sfoo() => super.foo;
|
|
BCD_Sfoo() => super.foo;
|
|
}
|
|
|
|
class C extends B {
|
|
var foo;
|
|
C(x, this.foo) : super(x);
|
|
|
|
BC_Sfoo() => super.foo;
|
|
BCD_Sfoo() => super.foo;
|
|
}
|
|
|
|
class D extends C {
|
|
D(x, y) : super(x, y);
|
|
|
|
BCD_Sfoo() => super.foo;
|
|
}
|
|
|
|
var inscrutable;
|
|
|
|
main() {
|
|
inscrutable = (x) => x;
|
|
|
|
var b = new B('Ba');
|
|
var c = new C('Ca', 'Cc');
|
|
var d = new D('Da', 'Dc');
|
|
|
|
// Check access via plain getter.
|
|
var b_bc = inscrutable(true) ? b : c; // B, but compiler thinks can also be C
|
|
var c_bc = inscrutable(true) ? c : b; // C, but compiler thinks can also be B
|
|
|
|
Expect.equals('Ba', b.foo);
|
|
Expect.equals('Cc', c.foo);
|
|
Expect.equals('Dc', d.foo);
|
|
Expect.equals('Ba', b_bc.foo);
|
|
Expect.equals('Cc', c_bc.foo);
|
|
|
|
Expect.equals('Ba', inscrutable(b).foo);
|
|
Expect.equals('Cc', inscrutable(c).foo);
|
|
Expect.equals('Dc', inscrutable(d).foo);
|
|
Expect.equals('Ba', inscrutable(b_bc).foo);
|
|
Expect.equals('Cc', inscrutable(c_bc).foo);
|
|
|
|
// Check access via super.foo in various contexts
|
|
Expect.equals('Ba', b.B_Sfoo());
|
|
Expect.equals('Ca', c.B_Sfoo());
|
|
Expect.equals('Da', d.B_Sfoo());
|
|
|
|
Expect.equals('Ba', b.BC_Sfoo());
|
|
Expect.equals('Ca', c.BC_Sfoo());
|
|
Expect.equals('Da', d.BC_Sfoo());
|
|
|
|
Expect.equals('Ba', b.BCD_Sfoo());
|
|
Expect.equals('Ca', c.BCD_Sfoo());
|
|
Expect.equals('Dc', d.BCD_Sfoo());
|
|
|
|
Expect.equals('Ba', inscrutable(b).B_Sfoo());
|
|
Expect.equals('Ca', inscrutable(c).B_Sfoo());
|
|
Expect.equals('Da', inscrutable(d).B_Sfoo());
|
|
|
|
Expect.equals('Ba', inscrutable(b).BC_Sfoo());
|
|
Expect.equals('Ca', inscrutable(c).BC_Sfoo());
|
|
Expect.equals('Da', inscrutable(d).BC_Sfoo());
|
|
|
|
Expect.equals('Ba', inscrutable(b).BCD_Sfoo());
|
|
Expect.equals('Ca', inscrutable(c).BCD_Sfoo());
|
|
Expect.equals('Dc', inscrutable(d).BCD_Sfoo());
|
|
}
|