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 that type variables are passed on from subtypes that fixed the type | 5 // Test that type variables are passed on from subtypes that fixed the type |
6 // variable in inheritance. | 6 // variable in inheritance. |
7 | 7 |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 class A<T> { | 10 class A<T> { |
(...skipping 14 matching lines...) Expand all Loading... |
25 class StringB extends B<String> { | 25 class StringB extends B<String> { |
26 } | 26 } |
27 | 27 |
28 class C<T> extends A<T> { | 28 class C<T> extends A<T> { |
29 } | 29 } |
30 | 30 |
31 class IntC extends C<int> { | 31 class IntC extends C<int> { |
32 } | 32 } |
33 | 33 |
34 void main() { | 34 void main() { |
35 testA(); /// 01: ok | 35 testA(); //# 01: ok |
36 testNumA(); /// 02: ok | 36 testNumA(); //# 02: ok |
37 testB(); /// 03: ok | 37 testB(); //# 03: ok |
38 testStringB(); /// 04: ok | 38 testStringB(); //# 04: ok |
39 testC(); /// 05: ok | 39 testC(); //# 05: ok |
40 testIntC(); /// 06: ok | 40 testIntC(); //# 06: ok |
41 } | 41 } |
42 | 42 |
43 void testA() { | 43 void testA() { |
44 var instanceA = new A<String>(); | 44 var instanceA = new A<String>(); |
45 var instanceB = instanceA.createB(); | 45 var instanceB = instanceA.createB(); |
46 instanceB.test(num, false); | 46 instanceB.test(num, false); |
47 instanceB.test(int, false); | 47 instanceB.test(int, false); |
48 instanceB.test(String, true); | 48 instanceB.test(String, true); |
49 } | 49 } |
50 | 50 |
(...skipping 27 matching lines...) Expand all Loading... |
78 instanceB.test(String, true); | 78 instanceB.test(String, true); |
79 } | 79 } |
80 | 80 |
81 void testIntC() { | 81 void testIntC() { |
82 var instanceA = new IntC(); | 82 var instanceA = new IntC(); |
83 var instanceB = instanceA.createB(); | 83 var instanceB = instanceA.createB(); |
84 instanceB.test(num, false); | 84 instanceB.test(num, false); |
85 instanceB.test(int, true); | 85 instanceB.test(int, true); |
86 instanceB.test(String, false); | 86 instanceB.test(String, false); |
87 } | 87 } |
OLD | NEW |