OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library test.generic_mixin; | |
6 | |
7 @MirrorsUsed(targets: "test.generic_mixin") | |
8 import 'dart:mirrors'; | |
9 | |
10 import 'package:expect/expect.dart'; | |
11 | |
12 import 'generics_helper.dart'; | |
13 | |
14 class Super<S> {} | |
15 | |
16 class Mixin<M> {} | |
17 | |
18 class Nixim<N> {} | |
19 | |
20 class NonGenericMixinApplication1 = Super with Mixin; | |
21 class NonGenericMixinApplication2 = Super<num> with Mixin<String>; | |
22 | |
23 class GenericMixinApplication1<MA> = Super<MA> with Mixin<MA>; | |
24 class GenericMixinApplication2<MA> = Super<num> with Mixin<String>; | |
25 | |
26 class NonGenericClass1 extends Super with Mixin {} | |
27 | |
28 class NonGenericClass2 extends Super<num> with Mixin<String> {} | |
29 | |
30 class GenericClass1<C> extends Super<C> with Mixin<C> {} | |
31 | |
32 class GenericClass2<C> extends Super<num> with Mixin<String> {} | |
33 | |
34 class GenericMultipleMixins<A, B, C> extends Super<A> with Mixin<B>, Nixim<C> {} | |
35 | |
36 main() { | |
37 TypeMirror dynamicMirror = currentMirrorSystem().dynamicType; | |
38 | |
39 typeParameters(reflectClass(NonGenericMixinApplication1).mixin, [#M]); | |
40 typeParameters(reflectClass(NonGenericMixinApplication2).mixin, [#M]); | |
41 typeParameters(reflectClass(GenericMixinApplication1).mixin, [#M]); | |
42 typeParameters(reflectClass(GenericMixinApplication2).mixin, [#M]); | |
43 typeParameters(reflectClass(NonGenericClass1).mixin, []); | |
44 typeParameters(reflectClass(NonGenericClass2).mixin, []); | |
45 typeParameters(reflectClass(GenericClass1).mixin, [#C]); | |
46 typeParameters(reflectClass(GenericClass2).mixin, [#C]); | |
47 typeParameters(reflectClass(NonGenericClass1).superclass.mixin, [#M]); | |
48 typeParameters(reflectClass(NonGenericClass2).superclass.mixin, [#M]); | |
49 typeParameters(reflectClass(GenericClass1).superclass.mixin, [#M]); | |
50 typeParameters(reflectClass(GenericClass2).superclass.mixin, [#M]); | |
51 typeParameters(reflectClass(GenericMultipleMixins).mixin, [#A, #B, #C]); | |
52 typeParameters(reflectClass(GenericMultipleMixins).superclass.mixin, [#N]); | |
53 typeParameters( | |
54 reflectClass(GenericMultipleMixins).superclass.superclass.mixin, [#M]); | |
55 typeParameters( | |
56 reflectClass(GenericMultipleMixins) | |
57 .superclass | |
58 .superclass | |
59 .superclass | |
60 .mixin, | |
61 [#S]); | |
62 | |
63 typeArguments( | |
64 reflectClass(NonGenericMixinApplication1).mixin, [dynamicMirror]); | |
65 typeArguments( | |
66 reflectClass(NonGenericMixinApplication2).mixin, [reflectClass(String)]); | |
67 typeArguments(reflectClass(GenericMixinApplication1).mixin, | |
68 [reflectClass(GenericMixinApplication1).typeVariables.single]); | |
69 typeArguments( | |
70 reflectClass(GenericMixinApplication2).mixin, [reflectClass(String)]); | |
71 typeArguments(reflectClass(NonGenericClass1).mixin, []); | |
72 typeArguments(reflectClass(NonGenericClass2).mixin, []); | |
73 typeArguments(reflectClass(GenericClass1).mixin, []); | |
74 typeArguments(reflectClass(GenericClass2).mixin, []); | |
75 typeArguments( | |
76 reflectClass(NonGenericClass1).superclass.mixin, [dynamicMirror]); | |
77 typeArguments( | |
78 reflectClass(NonGenericClass2).superclass.mixin, [reflectClass(String)]); | |
79 typeArguments(reflectClass(GenericClass1).superclass.mixin, | |
80 [reflectClass(GenericClass1).typeVariables.single]); | |
81 typeArguments( | |
82 reflectClass(GenericClass2).superclass.mixin, [reflectClass(String)]); | |
83 typeArguments(reflectClass(GenericMultipleMixins).mixin, []); | |
84 typeArguments(reflectClass(GenericMultipleMixins).superclass.mixin, | |
85 [reflectClass(GenericMultipleMixins).typeVariables[2]]); | |
86 typeArguments(reflectClass(GenericMultipleMixins).superclass.superclass.mixin, | |
87 [reflectClass(GenericMultipleMixins).typeVariables[1]]); | |
88 typeArguments( | |
89 reflectClass(GenericMultipleMixins) | |
90 .superclass | |
91 .superclass | |
92 .superclass | |
93 .mixin, | |
94 [reflectClass(GenericMultipleMixins).typeVariables[0]]); | |
95 | |
96 typeParameters(reflect(new NonGenericMixinApplication1()).type.mixin, [#M]); | |
97 typeParameters(reflect(new NonGenericMixinApplication2()).type.mixin, [#M]); | |
98 typeParameters( | |
99 reflect(new GenericMixinApplication1<bool>()).type.mixin, [#M]); | |
100 typeParameters( | |
101 reflect(new GenericMixinApplication2<bool>()).type.mixin, [#M]); | |
102 typeParameters(reflect(new NonGenericClass1()).type.mixin, []); | |
103 typeParameters(reflect(new NonGenericClass2()).type.mixin, []); | |
104 typeParameters(reflect(new GenericClass1<bool>()).type.mixin, [#C]); | |
105 typeParameters(reflect(new GenericClass2<bool>()).type.mixin, [#C]); | |
106 typeParameters(reflect(new NonGenericClass1()).type.superclass.mixin, [#M]); | |
107 typeParameters(reflect(new NonGenericClass2()).type.superclass.mixin, [#M]); | |
108 typeParameters( | |
109 reflect(new GenericClass1<bool>()).type.superclass.mixin, [#M]); | |
110 typeParameters( | |
111 reflect(new GenericClass2<bool>()).type.superclass.mixin, [#M]); | |
112 typeParameters( | |
113 reflect(new GenericMultipleMixins<bool, String, int>()).type.mixin, | |
114 [#A, #B, #C]); | |
115 typeParameters( | |
116 reflect(new GenericMultipleMixins<bool, String, int>()) | |
117 .type | |
118 .superclass | |
119 .mixin, | |
120 [#N]); | |
121 typeParameters( | |
122 reflect(new GenericMultipleMixins<bool, String, int>()) | |
123 .type | |
124 .superclass | |
125 .superclass | |
126 .mixin, | |
127 [#M]); | |
128 typeParameters( | |
129 reflect(new GenericMultipleMixins<bool, String, int>()) | |
130 .type | |
131 .superclass | |
132 .superclass | |
133 .superclass | |
134 .mixin, | |
135 [#S]); | |
136 | |
137 typeArguments( | |
138 reflect(new NonGenericMixinApplication1()).type.mixin, [dynamicMirror]); | |
139 typeArguments(reflect(new NonGenericMixinApplication2()).type.mixin, | |
140 [reflectClass(String)]); | |
141 typeArguments(reflect(new GenericMixinApplication1<bool>()).type.mixin, | |
142 [reflectClass(bool)]); | |
143 typeArguments(reflect(new GenericMixinApplication2<bool>()).type.mixin, | |
144 [reflectClass(String)]); | |
145 typeArguments(reflect(new NonGenericClass1()).type.mixin, []); | |
146 typeArguments(reflect(new NonGenericClass2()).type.mixin, []); | |
147 typeArguments( | |
148 reflect(new GenericClass1<bool>()).type.mixin, [reflectClass(bool)]); | |
149 typeArguments( | |
150 reflect(new GenericClass2<bool>()).type.mixin, [reflectClass(bool)]); | |
151 typeArguments( | |
152 reflect(new NonGenericClass1()).type.superclass.mixin, [dynamicMirror]); | |
153 typeArguments(reflect(new NonGenericClass2()).type.superclass.mixin, | |
154 [reflectClass(String)]); | |
155 typeArguments(reflect(new GenericClass1<bool>()).type.superclass.mixin, | |
156 [reflectClass(bool)]); | |
157 typeArguments(reflect(new GenericClass2<bool>()).type.superclass.mixin, | |
158 [reflectClass(String)]); | |
159 typeArguments( | |
160 reflect(new GenericMultipleMixins<bool, String, int>()).type.mixin, | |
161 [reflectClass(bool), reflectClass(String), reflectClass(int)]); | |
162 typeArguments( | |
163 reflect(new GenericMultipleMixins<bool, String, int>()) | |
164 .type | |
165 .superclass | |
166 .mixin, | |
167 [reflectClass(int)]); | |
168 typeArguments( | |
169 reflect(new GenericMultipleMixins<bool, String, int>()) | |
170 .type | |
171 .superclass | |
172 .superclass | |
173 .mixin, | |
174 [reflectClass(String)]); | |
175 typeArguments( | |
176 reflect(new GenericMultipleMixins<bool, String, int>()) | |
177 .type | |
178 .superclass | |
179 .superclass | |
180 .superclass | |
181 .mixin, | |
182 [reflectClass(bool)]); | |
183 } | |
OLD | NEW |