blob: 901308c68dafb3ab3d0afaf76adda6b54061e331 [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.
import "package:expect/expect.dart";
class A {}
class B extends A {}
class B2 extends A {}
class C {
void f(covariant B x) {}
abstract class I {
void f(A x);
// This class does not require a forwarding stub; the interface of D.f is (A) ->
// void and the implementation has signature (covariant B) -> void. The
// implementation satisfies the interface thanks to the presence of the
// "covariant" keyword.
class D extends C implements I {}
main() {
var d = new D();
I i = d;
A a = new A();
B b = new B();
B2 b2Null = null;
// The following two lines are statically ok because the type B2 is assignable
// to the type A. There should be no runtime error because the actual value
// at runtime is `null`, which may be assigned to A.
void Function(Object) g = d.f; // Ok; D.f reified as (Object) -> void
Expect.throwsTypeError(() {
Expect.throwsTypeError(() {