OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Test instantiation of object with malbounded types. | 5 // Test instantiation of object with malbounded types. |
6 | 6 |
7 class A<T | 7 class A<T |
8 extends num /// 01: static type warning | 8 extends num //# 01: static type warning |
9 > {} | 9 > {} |
10 class B<T> implements A<T> {} | 10 class B<T> implements A<T> {} |
11 class C<T | 11 class C<T |
12 extends num /// 01: continued | 12 extends num //# 01: continued |
13 > implements B<T> {} | 13 > implements B<T> {} |
14 | 14 |
15 class Class<T> { | 15 class Class<T> { |
16 newA() { | 16 newA() { |
17 new A<T>(); /// 01: continued | 17 new A<T>(); //# 01: continued |
18 } | 18 } |
19 newB() { | 19 newB() { |
20 new B<T>(); /// 01: continued | 20 new B<T>(); //# 01: continued |
21 } | 21 } |
22 newC() { | 22 newC() { |
23 new C<T>(); /// 01: continued | 23 new C<T>(); //# 01: continued |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 bool inCheckedMode() { | 27 bool inCheckedMode() { |
28 try { | 28 try { |
29 var i = 42; | 29 var i = 42; |
30 String s = i; | 30 String s = i; |
31 } on TypeError catch (e) { | 31 } on TypeError catch (e) { |
32 return true; | 32 return true; |
33 } | 33 } |
(...skipping 12 matching lines...) Expand all Loading... |
46 } | 46 } |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 void main() { | 51 void main() { |
52 test(false, () => new A<int>()); | 52 test(false, () => new A<int>()); |
53 test(false, () => new B<int>()); | 53 test(false, () => new B<int>()); |
54 test(false, () => new C<int>()); | 54 test(false, () => new C<int>()); |
55 | 55 |
56 test(true, () => new A<String>()); /// 01: continued | 56 test(true, () => new A<String>()); //# 01: continued |
57 test(true, () => new B<String>()); /// 01: continued | 57 test(true, () => new B<String>()); //# 01: continued |
58 test(true, () => new C<String>()); /// 01: continued | 58 test(true, () => new C<String>()); //# 01: continued |
59 | 59 |
60 var c = new Class<int>(); | 60 var c = new Class<int>(); |
61 test(false, () => c.newA()); | 61 test(false, () => c.newA()); |
62 test(false, () => c.newB()); | 62 test(false, () => c.newB()); |
63 test(false, () => c.newC()); | 63 test(false, () => c.newC()); |
64 | 64 |
65 c = new Class<String>(); | 65 c = new Class<String>(); |
66 test(true, () => c.newA()); /// 01: continued | 66 test(true, () => c.newA()); //# 01: continued |
67 test(true, () => c.newB()); /// 01: continued | 67 test(true, () => c.newB()); //# 01: continued |
68 test(true, () => c.newC()); /// 01: continued | 68 test(true, () => c.newC()); //# 01: continued |
69 } | 69 } |
OLD | NEW |