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< |
| 8 T |
8 extends num //# 01: static type warning | 9 extends num //# 01: static type warning |
9 > {} | 10 > {} |
| 11 |
10 class B<T> implements A<T> {} | 12 class B<T> implements A<T> {} |
11 class C<T | 13 |
| 14 class C< |
| 15 T |
12 extends num //# 01: continued | 16 extends num //# 01: continued |
13 > implements B<T> {} | 17 > implements B<T> {} |
14 | 18 |
15 class Class<T> { | 19 class Class<T> { |
16 newA() { | 20 newA() { |
17 new A<T>(); //# 01: continued | 21 new A<T>(); //# 01: continued |
18 } | 22 } |
19 newB() { | 23 newB() { |
20 new B<T>(); //# 01: continued | 24 new B<T>(); //# 01: continued |
21 } | 25 } |
22 newC() { | 26 newC() { |
23 new C<T>(); //# 01: continued | 27 new C<T>(); //# 01: continued |
(...skipping 16 matching lines...) Expand all Loading... |
40 if (expectTypeError && inCheckedMode()) { | 44 if (expectTypeError && inCheckedMode()) { |
41 throw 'Missing type error instantiating ${v.runtimeType}'; | 45 throw 'Missing type error instantiating ${v.runtimeType}'; |
42 } | 46 } |
43 } on TypeError catch (e) { | 47 } on TypeError catch (e) { |
44 if (!expectTypeError || !inCheckedMode()) { | 48 if (!expectTypeError || !inCheckedMode()) { |
45 throw 'Unexpected type error: $e'; | 49 throw 'Unexpected type error: $e'; |
46 } | 50 } |
47 } | 51 } |
48 } | 52 } |
49 | 53 |
50 | |
51 void main() { | 54 void main() { |
52 test(false, () => new A<int>()); | 55 test(false, () => new A<int>()); |
53 test(false, () => new B<int>()); | 56 test(false, () => new B<int>()); |
54 test(false, () => new C<int>()); | 57 test(false, () => new C<int>()); |
55 | 58 |
56 test(true, () => new A<String>()); //# 01: continued | 59 test(true, () => new A<String>()); //# 01: continued |
57 test(true, () => new B<String>()); //# 01: continued | 60 test(true, () => new B<String>()); //# 01: continued |
58 test(true, () => new C<String>()); //# 01: continued | 61 test(true, () => new C<String>()); //# 01: continued |
59 | 62 |
60 var c = new Class<int>(); | 63 var c = new Class<int>(); |
61 test(false, () => c.newA()); | 64 test(false, () => c.newA()); |
62 test(false, () => c.newB()); | 65 test(false, () => c.newB()); |
63 test(false, () => c.newC()); | 66 test(false, () => c.newC()); |
64 | 67 |
65 c = new Class<String>(); | 68 c = new Class<String>(); |
66 test(true, () => c.newA()); //# 01: continued | 69 test(true, () => c.newA()); //# 01: continued |
67 test(true, () => c.newB()); //# 01: continued | 70 test(true, () => c.newB()); //# 01: continued |
68 test(true, () => c.newC()); //# 01: continued | 71 test(true, () => c.newC()); //# 01: continued |
69 } | 72 } |
OLD | NEW |