Files
sdk/tests/language/mixin/implicit_covariance_test.dart
T
Nicholas Shahan 1d34f60b66 [ddc] Fix missing covariant checks from mixins
Collect all forwarding stubs from anonymous mixin classes and insert
them in the target class if no override exists.

Change-Id: Id62f20b644ce7bbabe114d0d1648664392748a2d
Fixes: https://github.com/dart-lang/sdk/issues/43027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161760
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-09-16 18:56:58 +00:00

33 lines
712 B
Dart

// Copyright (c) 2019, 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';
abstract class A<T> {
foo(T x);
}
abstract class B<T> implements A<T> {}
class C {
foo(num x) {
if (x is! num) {
throw "Soundness issue: expected x to be num, got ${x.runtimeType}.";
}
}
}
class D<T extends num> extends C with B<T> {}
class E<T extends num> = C with B<T>;
test(B<dynamic> b) {
b.foo("bar");
}
main() {
Expect.throws<TypeError>(() => test(new D<int>()));
Expect.throws<TypeError>(() => test(new E<int>()));
}