[fasta] Add test for runtime checks in mixins with implicit covariance
Change-Id: I7e9d7cd6d3a8e27570dd6b7a882e3ad7a63acb60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104783
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
diff --git a/tests/language_2/mixin_implicit_covariance_test.dart b/tests/language_2/mixin_implicit_covariance_test.dart
new file mode 100644
index 0000000..5606bd7
--- /dev/null
+++ b/tests/language_2/mixin_implicit_covariance_test.dart
@@ -0,0 +1,32 @@
+// 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 "Soudness 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>()));
+}