Chromium Code Reviews| 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_applications; | |
| 6 | |
| 7 import 'dart:mirrors'; | |
| 8 | |
| 9 import 'package:expect/expect.dart'; | |
| 10 | |
| 11 import 'generics_test.dart'; | |
| 12 | |
| 13 class Super<S> {} | |
| 14 class Mixin<M> {} | |
| 15 | |
| 16 typedef NonGenericMixinApplication1 = Super with Mixin; | |
| 17 typedef NonGenericMixinApplication2 = Super<num> with Mixin<String>; | |
| 18 | |
| 19 typedef GenericMixinApplication1<MA> = Super<MA> with Mixin<MA>; | |
| 20 typedef GenericMixinApplication2<MA> = Super<num> with Mixin<String>; | |
| 21 | |
| 22 class NonGenericClass1 extends Super with Mixin {} | |
| 23 class NonGenericClass2 extends Super<num> with Mixin<String> {} | |
| 24 | |
| 25 class GenericClass1<C> extends Super<C> with Mixin<C> {} | |
| 26 class GenericClass2<C> extends Super<num> with Mixin<String> {} | |
| 27 | |
| 28 main() { | |
| 29 TypeMirror dynamicMirror = currentMirrorSystem().dynamicType; | |
| 30 | |
| 31 // Declarations. | |
| 32 typeParameters(reflectClass(NonGenericMixinApplication1), []); | |
| 33 typeParameters(reflectClass(NonGenericMixinApplication2), []); | |
| 34 typeParameters(reflectClass(GenericMixinApplication1), [#MA]); | |
| 35 typeParameters(reflectClass(GenericMixinApplication2), [#MA]); | |
| 36 typeParameters(reflectClass(NonGenericClass1), []); | |
| 37 typeParameters(reflectClass(NonGenericClass2), []); | |
| 38 typeParameters(reflectClass(GenericClass1), [#C]); | |
| 39 typeParameters(reflectClass(GenericClass2), [#C]); | |
| 40 // The extact name of the type variable is not specified. | |
|
gbracha
2013/10/02 20:57:14
extact -> exact
| |
| 41 // Why 2? | |
| 42 Expect.equals(2, reflectClass(NonGenericClass1).superclass.typeVariables.lengt h); | |
|
gbracha
2013/10/02 20:57:14
reflectClass(NonGenericClass1).superclass is a mir
| |
| 43 Expect.equals(2, reflectClass(NonGenericClass2).superclass.typeVariables.lengt h); | |
|
gbracha
2013/10/02 20:57:14
Again, why type variables?
| |
| 44 Expect.equals(2, reflectClass(GenericClass1).superclass.typeVariables.length); | |
|
gbracha
2013/10/02 20:57:14
Ok. Here the superclass is Super<C> with Mixin<C>
| |
| 45 Expect.equals(2, reflectClass(GenericClass2).superclass.typeVariables.length); | |
| 46 | |
| 47 typeArguments(reflectClass(NonGenericMixinApplication1), []); | |
| 48 typeArguments(reflectClass(NonGenericMixinApplication2), []); | |
| 49 typeArguments(reflectClass(GenericMixinApplication1), []); | |
| 50 typeArguments(reflectClass(GenericMixinApplication2), []); | |
| 51 typeArguments(reflectClass(NonGenericClass1), []); | |
| 52 typeArguments(reflectClass(NonGenericClass2), []); | |
| 53 typeArguments(reflectClass(GenericClass1), []); | |
| 54 typeArguments(reflectClass(GenericClass2), []); | |
| 55 typeArguments(reflectClass(NonGenericClass1).superclass.originalDeclaration, [ ]); | |
| 56 typeArguments(reflectClass(NonGenericClass2).superclass.originalDeclaration, [ ]); | |
| 57 typeArguments(reflectClass(GenericClass1).superclass.originalDeclaration, []); | |
| 58 typeArguments(reflectClass(GenericClass2).superclass.originalDeclaration, []); | |
| 59 | |
| 60 | |
| 61 // Instantiations. | |
| 62 typeParameters(reflect(new NonGenericMixinApplication1()).type, []); | |
| 63 typeParameters(reflect(new NonGenericMixinApplication2()).type, []); | |
| 64 typeParameters(reflect(new GenericMixinApplication1<bool>()).type, [#MA]); | |
| 65 typeParameters(reflect(new GenericMixinApplication2<bool>()).type, [#MA]); | |
| 66 typeParameters(reflect(new NonGenericClass1()).type, []); | |
| 67 typeParameters(reflect(new NonGenericClass2()).type, []); | |
| 68 typeParameters(reflect(new GenericClass1<bool>()).type, [#C]); | |
| 69 typeParameters(reflect(new GenericClass2<bool>()).type, [#C]); | |
| 70 // The extact name of the type variable is not specified. | |
|
gbracha
2013/10/02 20:57:14
extact -> exact
| |
| 71 // Why 2? | |
| 72 Expect.equals(2, reflect(new NonGenericClass1()).type.superclass.typeVariables .length); | |
| 73 Expect.equals(2, reflect(new NonGenericClass2()).type.superclass.typeVariables .length); | |
| 74 Expect.equals(2, reflect(new GenericClass1<bool>()).type.superclass.typeVariab les.length); | |
| 75 Expect.equals(2, reflect(new GenericClass2<bool>()).type.superclass.typeVariab les.length); | |
| 76 | |
| 77 typeArguments(reflect(new NonGenericMixinApplication1()).type, []); | |
| 78 typeArguments(reflect(new NonGenericMixinApplication2()).type, []); | |
| 79 typeArguments(reflect(new GenericMixinApplication1<bool>()).type, [reflectClas s(bool)]); | |
| 80 typeArguments(reflect(new GenericMixinApplication2<bool>()).type, [reflectClas s(bool)]); | |
| 81 typeArguments(reflect(new NonGenericClass1()).type, []); | |
| 82 typeArguments(reflect(new NonGenericClass2()).type, []); | |
| 83 typeArguments(reflect(new GenericClass1<bool>()).type, [reflectClass(bool)]); | |
| 84 typeArguments(reflect(new GenericClass2<bool>()).type, [reflectClass(bool)]); | |
| 85 // Why 2? | |
| 86 typeArguments(reflect(new NonGenericClass1()).type.superclass, [dynamicMirror, dynamicMirror]); | |
| 87 typeArguments(reflect(new NonGenericClass2()).type.superclass, [reflectClass(n um), reflectClass(String)]); | |
| 88 // Hm? | |
| 89 // typeArguments(reflect(new GenericClass1<bool>()).type.superclass, [dynamicM irror, dynamicMirror]); | |
| 90 typeArguments(reflect(new GenericClass2<bool>()).type.superclass, [reflectClas s(num), reflectClass(String)]); | |
| 91 } | |
| OLD | NEW |