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 library test.type_argument_is_type_variable; | 5 library test.type_argument_is_type_variable; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 | 10 |
11 import 'generics_helper.dart'; | 11 import 'generics_helper.dart'; |
12 | 12 |
13 class SuperSuper<SS> {} | 13 class SuperSuper<SS> {} |
| 14 |
14 class Super<S> extends SuperSuper<S> {} | 15 class Super<S> extends SuperSuper<S> {} |
| 16 |
15 class Generic<G> extends Super<G> {} | 17 class Generic<G> extends Super<G> {} |
16 | 18 |
17 main() { | 19 main() { |
18 // Declarations. | 20 // Declarations. |
19 ClassMirror generic = reflectClass(Generic); | 21 ClassMirror generic = reflectClass(Generic); |
20 ClassMirror superOfGeneric = generic.superclass; | 22 ClassMirror superOfGeneric = generic.superclass; |
21 ClassMirror superOfSuperOfGeneric = superOfGeneric.superclass; | 23 ClassMirror superOfSuperOfGeneric = superOfGeneric.superclass; |
22 | 24 |
23 TypeVariableMirror gFromGeneric = generic.typeVariables.single; | 25 TypeVariableMirror gFromGeneric = generic.typeVariables.single; |
24 TypeVariableMirror sFromSuper = superOfGeneric.typeVariables.single; | 26 TypeVariableMirror sFromSuper = superOfGeneric.typeVariables.single; |
25 TypeVariableMirror ssFromSuperSuper = superOfSuperOfGeneric.typeVariables.sing
le; | 27 TypeVariableMirror ssFromSuperSuper = |
| 28 superOfSuperOfGeneric.typeVariables.single; |
26 | 29 |
27 Expect.equals(#G, gFromGeneric.simpleName); | 30 Expect.equals(#G, gFromGeneric.simpleName); |
28 Expect.equals(#S, sFromSuper.simpleName); | 31 Expect.equals(#S, sFromSuper.simpleName); |
29 Expect.equals(#SS, ssFromSuperSuper.simpleName); | 32 Expect.equals(#SS, ssFromSuperSuper.simpleName); |
30 | 33 |
31 typeParameters(generic, [#G]); | 34 typeParameters(generic, [#G]); |
32 typeParameters(superOfGeneric, [#S]); | 35 typeParameters(superOfGeneric, [#S]); |
33 typeParameters(superOfSuperOfGeneric, [#SS]); | 36 typeParameters(superOfSuperOfGeneric, [#SS]); |
34 | 37 |
35 typeArguments(generic, []); | 38 typeArguments(generic, []); |
36 typeArguments(superOfGeneric, [gFromGeneric]); | 39 typeArguments(superOfGeneric, [gFromGeneric]); |
37 typeArguments(superOfSuperOfGeneric, [gFromGeneric]); | 40 typeArguments(superOfSuperOfGeneric, [gFromGeneric]); |
38 | 41 |
39 | |
40 // Instantiations. | 42 // Instantiations. |
41 ClassMirror genericWithInt = reflect(new Generic<int>()).type; | 43 ClassMirror genericWithInt = reflect(new Generic<int>()).type; |
42 ClassMirror superOfGenericWithInt = genericWithInt.superclass; | 44 ClassMirror superOfGenericWithInt = genericWithInt.superclass; |
43 ClassMirror superOfSuperOfGenericWithInt = superOfGenericWithInt.superclass; | 45 ClassMirror superOfSuperOfGenericWithInt = superOfGenericWithInt.superclass; |
44 | 46 |
45 typeParameters(genericWithInt, [#G]); | 47 typeParameters(genericWithInt, [#G]); |
46 typeParameters(superOfGenericWithInt, [#S]); | 48 typeParameters(superOfGenericWithInt, [#S]); |
47 typeParameters(superOfSuperOfGenericWithInt, [#SS]); | 49 typeParameters(superOfSuperOfGenericWithInt, [#SS]); |
48 | 50 |
49 typeArguments(genericWithInt, [reflectClass(int)]); | 51 typeArguments(genericWithInt, [reflectClass(int)]); |
50 typeArguments(superOfGenericWithInt, [reflectClass(int)]); | 52 typeArguments(superOfGenericWithInt, [reflectClass(int)]); |
51 typeArguments(superOfSuperOfGenericWithInt, [reflectClass(int)]); | 53 typeArguments(superOfSuperOfGenericWithInt, [reflectClass(int)]); |
52 } | 54 } |
OLD | NEW |