Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: tests/language_strong/covariant_subtyping_unsafe_call3_test.dart

Issue 2725563003: Add some tests for calls with checks in strong mode. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/language_strong/covariant_subtyping_unsafe_call3_test.dart
diff --git a/tests/language_strong/covariant_subtyping_unsafe_call3_test.dart b/tests/language_strong/covariant_subtyping_unsafe_call3_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..71143e696361c6e24338cf83fa3738c4dedf2dd1
--- /dev/null
+++ b/tests/language_strong/covariant_subtyping_unsafe_call3_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2016, 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 Implementation {
+ dynamic method(int x) {}
+}
+
+abstract class Interface1<T> {
+ dynamic method(T x);
+}
+
+abstract class Interface2<T> {
+ dynamic method(T x);
+}
+
+class Subclass extends Implementation
+ implements Interface1<int>, Interface2<int> {}
+
+main() {
+ Subclass subclass = new Subclass();
+
+ Interface1<int> intInterface1 = subclass;
+ Interface1<num> numInterface1 = intInterface1;
+ Expect.throws(() => numInterface1.method(2.5));
+
+ Interface2<int> intInterface2 = subclass;
+ Interface2<num> numInterface2 = intInterface2;
+ Expect.throws(() => numInterface2.method(2.5));
+}
« no previous file with comments | « tests/language_strong/covariant_subtyping_unsafe_call2_test.dart ('k') | tests/language_strong/tearoff_dynamic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698