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

Side by Side Diff: tests/language_2/type_variable_bounds2_test.dart

Issue 3007803002: Migrate block 162 to Dart 2.0.
Patch Set: Created 3 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 // Test of parameterized types with invalid bounds.
8
9 abstract class J<T> {}
10
11 abstract class K<T> {}
12
13 abstract class I<
14 T
15 extends num //# 00: continued
16 extends num //# 01: continued
17 extends num //# 02: continued
18 extends num //# 03: continued
19 extends num //# 04: continued
20 extends num //# 05: continued
21 extends num //# 06: continued
22 > {}
23
24 class A<T> implements I<T>, J<T> {}
eernst 2017/09/04 17:04:59 We have the following in the language specificatio
25
26 main() {
27 // 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.
28 dynamic a = new A<String>();
eernst 2017/09/04 17:05:00 The static-only test was discussed in the comment
29
30 {
31 // Anything having to do with a here should point out that String does
32 // not extend num.
eernst 2017/09/04 17:05:00 The static type of `a` is `dynamic`, so we shouldn
33 I i = a; // //# 00: compile-time error
34 J j = a; // //# 01: compile-time error
35 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.
36
37 // A<bool> is a subtype of I.
38 Expect.isTrue(a is I); // //# 03: compile-time error
39
40 // A<bool> is a subtype of J.
41 Expect.isTrue(a is J); // //# 04: compile-time error
42
43 // A<bool> is not a subtype of K.
44 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
45 }
46
47 a = new A<int>();
eernst 2017/09/04 17:05:00 Now this is possible!
48
49 {
50 I i = a;
51 J j = a;
52 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
53
54 // A<int> is a subtype of I.
55 Expect.isTrue(a is I);
56
57 // A<int> is a subtype of J.
58 Expect.isTrue(a is J);
59
60 // A<int> is not a subtype of K.
61 Expect.isTrue(a is! K);
eernst 2017/09/04 17:05:00 When we don't have a compile-time error, `A` is ju
62 }
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698