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<T |
14 extends num /// 00: continued | 14 extends num //# 00: continued |
15 extends num /// 01: continued | 15 extends num //# 01: continued |
16 extends num /// 02: continued | 16 extends num //# 02: continued |
17 extends num /// 03: continued | 17 extends num //# 03: continued |
18 extends num /// 04: continued | 18 extends num //# 04: continued |
19 extends num /// 05: continued | 19 extends num //# 05: continued |
20 extends num /// 06: continued | 20 extends num //# 06: continued |
21 > { } | 21 > { } |
22 | 22 |
23 class A<T> implements I<T>, J<T> { | 23 class A<T> implements I<T>, J<T> { |
24 } | 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. |
35 var x = a is I; /// 03: dynamic type error, static type warning | 35 var x = a is I; //# 03: dynamic type error, static type warning |
36 | 36 |
37 // In both production and checked modes, A<String> is a subtype of J. | 37 // In both production and checked modes, A<String> is a subtype of J. |
38 Expect.isTrue(a is J); /// 04: static type warning | 38 Expect.isTrue(a is J); //# 04: static type warning |
39 | 39 |
40 // In both production and checked modes, A<String> is not a subtype of K. | 40 // In both production and checked modes, A<String> is not a subtype of K. |
41 // However, while unsuccessfully trying to prove that A<String> is a K, | 41 // However, while unsuccessfully trying to prove that A<String> is a K, |
42 // a malformed type is encountered in checked mode, resulting in a dynamic | 42 // a malformed type is encountered in checked mode, resulting in a dynamic |
43 // type error. | 43 // type error. |
44 Expect.isTrue(a is !K); /// 05: dynamic type error, static type warning | 44 Expect.isTrue(a is !K); //# 05: dynamic type error, static type warning |
45 } | 45 } |
46 | 46 |
47 a = new A<int>(); | 47 a = new A<int>(); |
48 | 48 |
49 { | 49 { |
50 I i = a; | 50 I i = a; |
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 |