OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Test of parameterized types with invalid bounds. | 7 // Test of parameterized types with invalid bounds. |
8 | 8 |
9 abstract class J<T> { } | 9 abstract class J<T> {} |
10 | 10 |
11 abstract class K<T> { } | 11 abstract class K<T> {} |
12 | 12 |
13 abstract class I<T | 13 abstract class I< |
| 14 T |
14 extends num //# 00: continued | 15 extends num //# 00: continued |
15 extends num //# 01: continued | 16 extends num //# 01: continued |
16 extends num //# 02: continued | 17 extends num //# 02: continued |
17 extends num //# 03: continued | 18 extends num //# 03: continued |
18 extends num //# 04: continued | 19 extends num //# 04: continued |
19 extends num //# 05: continued | 20 extends num //# 05: continued |
20 extends num //# 06: continued | 21 extends num //# 06: continued |
21 > { } | 22 > {} |
22 | 23 |
23 class A<T> implements I<T>, J<T> { | 24 class A<T> implements I<T>, J<T> {} |
24 } | |
25 | 25 |
26 main() { | 26 main() { |
27 var a = new A<String>(); | 27 var a = new A<String>(); |
28 | 28 |
29 { | 29 { |
30 I i = a; // //# 00: dynamic type error, static type warning | 30 I i = a; // //# 00: dynamic type error, static type warning |
31 J j = a; // //# 01: static type warning | 31 J j = a; // //# 01: static type warning |
32 K k = a; // //# 02: dynamic type error, static type warning | 32 K k = a; // //# 02: dynamic type error, static type warning |
33 | 33 |
34 // In production mode, A<String> is subtype of I, error in checked mode. | 34 // In production mode, A<String> is subtype of I, error in checked mode. |
(...skipping 16 matching lines...) Expand all Loading... |
51 J j = a; | 51 J j = a; |
52 K k = a; // //# 06: dynamic type error, static type warning | 52 K k = a; // //# 06: dynamic type error, static type warning |
53 | 53 |
54 // In both production and checked modes, A<int> is a subtype of I. | 54 // In both production and checked modes, A<int> is a subtype of I. |
55 Expect.isTrue(a is I); | 55 Expect.isTrue(a is I); |
56 | 56 |
57 // In both production and checked modes, A<int> is a subtype of J. | 57 // In both production and checked modes, A<int> is a subtype of J. |
58 Expect.isTrue(a is J); | 58 Expect.isTrue(a is J); |
59 | 59 |
60 // In both production and checked modes, A<int> is not a subtype of K. | 60 // In both production and checked modes, A<int> is not a subtype of K. |
61 Expect.isTrue(a is !K); | 61 Expect.isTrue(a is! K); |
62 } | 62 } |
63 } | 63 } |
OLD | NEW |