blob: f3982f8f61c2bcab6aa8615f7c7fcc33ec454bf4 [file] [log] [blame]
// Copyright (c) 2018, 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.
// @dart=2.9
// This test checks that noSuchMethod forwarders are generated for abstract
// accessors implicitly declared via fields of abstract classes. The type
// checks should be performed for the return values of getters and for the r.h.s
// of assignments for setters.
void expectTypeError(callback()) {
try {
callback();
throw 'Expected TypeError, did not occur';
} on TypeError {}
}
abstract class I {
int foo;
}
class A implements I {
dynamic noSuchMethod(i) => "bar";
// Should have noSuchMethod forwarders for the 'foo' getter and setter.
}
class B extends A {
// Should not have noSuchMethod forwarders for the 'foo' getter and setter.
}
main() {
var a = new A();
expectTypeError(() => a.foo);
expectTypeError(() => (a as dynamic).foo = "bar");
}