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

Unified Diff: tests/language_2/type_variable_bounds2_test.dart

Issue 3007803002: Migrate block 162 to Dart 2.0.
Patch Set: Created 3 years, 4 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_2/type_variable_bounds2_test.dart
diff --git a/tests/language_2/type_variable_bounds2_test.dart b/tests/language_2/type_variable_bounds2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e396a666a39e63761186d93d5b0e8268726b04e4
--- /dev/null
+++ b/tests/language_2/type_variable_bounds2_test.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2012, 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";
+
+// Test of parameterized types with invalid bounds.
+
+abstract class J<T> {}
+
+abstract class K<T> {}
+
+abstract class I<
+ T
+ extends num //# 00: continued
+ extends num //# 01: continued
+ extends num //# 02: continued
+ extends num //# 03: continued
+ extends num //# 04: continued
+ extends num //# 05: continued
+ extends num //# 06: continued
+ > {}
+
+class A<T> implements I<T>, J<T> {}
eernst 2017/09/04 17:04:59 We have the following in the language specificatio
+
+main() {
+ // TODO(jcollins-g): Should this be a compile-time error as well?
Bob Nystrom 2017/08/30 20:02:44 This looks OK to me.
+ dynamic a = new A<String>();
eernst 2017/09/04 17:05:00 The static-only test was discussed in the comment
+
+ {
+ // Anything having to do with a here should point out that String does
+ // not extend num.
eernst 2017/09/04 17:05:00 The static type of `a` is `dynamic`, so we shouldn
+ I i = a; // //# 00: compile-time error
+ J j = a; // //# 01: compile-time error
+ K k = a; // //# 02: compile-time error
Bob Nystrom 2017/08/30 20:02:44 I would expect to see a compile error at the decla
eernst 2017/09/04 17:05:00 Agreed.
+
+ // A<bool> is a subtype of I.
+ Expect.isTrue(a is I); // //# 03: compile-time error
+
+ // A<bool> is a subtype of J.
+ Expect.isTrue(a is J); // //# 04: compile-time error
+
+ // A<bool> is not a subtype of K.
+ Expect.isTrue(a is !K); // //# 05: compile-time error
eernst 2017/09/04 17:05:00 I have no idea where `A<bool>` enters the situatio
+ }
+
+ a = new A<int>();
eernst 2017/09/04 17:05:00 Now this is possible!
+
+ {
+ I i = a;
+ J j = a;
+ K k = a; // //# 06: compile-time error
eernst 2017/09/04 17:05:00 But it should not be a compile-time error to initi
+
+ // A<int> is a subtype of I.
+ Expect.isTrue(a is I);
+
+ // A<int> is a subtype of J.
+ Expect.isTrue(a is J);
+
+ // A<int> is not a subtype of K.
+ Expect.isTrue(a is! K);
eernst 2017/09/04 17:05:00 When we don't have a compile-time error, `A` is ju
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698