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.generic_f_bounded; | 5 library test.generic_f_bounded; |
6 | 6 |
7 @MirrorsUsed(targets: "test.generic_f_bounded") | 7 @MirrorsUsed(targets: "test.generic_f_bounded") |
8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
9 | 9 |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 | 11 |
12 import 'generics_helper.dart'; | 12 import 'generics_helper.dart'; |
13 | 13 |
14 class Collection<C> {} | 14 class Collection<C> {} |
| 15 |
15 class Serializable<S> {} | 16 class Serializable<S> {} |
16 | 17 |
17 class OrderedCollection<V> | 18 class OrderedCollection<V> extends Collection<V> |
18 extends Collection<V> | |
19 with Serializable<OrderedCollection<V>> {} | 19 with Serializable<OrderedCollection<V>> {} |
20 | 20 |
21 class AbstractOrderedCollection<W> | 21 class AbstractOrderedCollection<W> = Collection<W> |
22 = Collection<W> | |
23 with Serializable<AbstractOrderedCollection<W>>; | 22 with Serializable<AbstractOrderedCollection<W>>; |
24 | 23 |
25 class CustomOrderedCollection<Z> | 24 class CustomOrderedCollection<Z> extends AbstractOrderedCollection<Z> {} |
26 extends AbstractOrderedCollection<Z> {} | |
27 | 25 |
28 class OrderedIntegerCollection | 26 class OrderedIntegerCollection extends OrderedCollection<int> {} |
29 extends OrderedCollection<int> {} | |
30 | 27 |
31 class CustomOrderedIntegerCollection | 28 class CustomOrderedIntegerCollection extends CustomOrderedCollection<int> {} |
32 extends CustomOrderedCollection<int> {} | |
33 | 29 |
34 class Serializer<R extends Serializable<R>> {} | 30 class Serializer<R extends Serializable<R>> {} |
| 31 |
35 class CollectionSerializer extends Serializer<Collection> {} | 32 class CollectionSerializer extends Serializer<Collection> {} |
| 33 |
36 class OrderedCollectionSerializer extends Serializer<OrderedCollection> {} | 34 class OrderedCollectionSerializer extends Serializer<OrderedCollection> {} |
37 | 35 |
38 main() { | 36 main() { |
39 ClassMirror collectionDecl = reflectClass(Collection); | 37 ClassMirror collectionDecl = reflectClass(Collection); |
40 ClassMirror serializableDecl = reflectClass(Serializable); | 38 ClassMirror serializableDecl = reflectClass(Serializable); |
41 ClassMirror orderedCollectionDecl = reflectClass(OrderedCollection); | 39 ClassMirror orderedCollectionDecl = reflectClass(OrderedCollection); |
42 ClassMirror abstractOrderedCollectionDecl = reflectClass(AbstractOrderedCollec
tion); | 40 ClassMirror abstractOrderedCollectionDecl = |
43 ClassMirror customOrderedCollectionDecl = reflectClass(CustomOrderedCollection
); | 41 reflectClass(AbstractOrderedCollection); |
| 42 ClassMirror customOrderedCollectionDecl = |
| 43 reflectClass(CustomOrderedCollection); |
44 ClassMirror orderedIntegerCollection = reflectClass(OrderedIntegerCollection); | 44 ClassMirror orderedIntegerCollection = reflectClass(OrderedIntegerCollection); |
45 ClassMirror customOrderedIntegerCollection = reflectClass(CustomOrderedInteger
Collection); | 45 ClassMirror customOrderedIntegerCollection = |
| 46 reflectClass(CustomOrderedIntegerCollection); |
46 ClassMirror serializerDecl = reflectClass(Serializer); | 47 ClassMirror serializerDecl = reflectClass(Serializer); |
47 ClassMirror collectionSerializerDecl = reflectClass(CollectionSerializer); | 48 ClassMirror collectionSerializerDecl = reflectClass(CollectionSerializer); |
48 ClassMirror orderedCollectionSerializerDecl = reflectClass(OrderedCollectionSe
rializer); | 49 ClassMirror orderedCollectionSerializerDecl = |
| 50 reflectClass(OrderedCollectionSerializer); |
49 | 51 |
50 ClassMirror orderedCollectionOfInt = orderedIntegerCollection.superclass; | 52 ClassMirror orderedCollectionOfInt = orderedIntegerCollection.superclass; |
51 ClassMirror customOrderedCollectionOfInt = customOrderedIntegerCollection.supe
rclass; | 53 ClassMirror customOrderedCollectionOfInt = |
| 54 customOrderedIntegerCollection.superclass; |
52 ClassMirror serializerOfCollection = collectionSerializerDecl.superclass; | 55 ClassMirror serializerOfCollection = collectionSerializerDecl.superclass; |
53 ClassMirror serializerOfOrderedCollection = orderedCollectionSerializerDecl.su
perclass; | 56 ClassMirror serializerOfOrderedCollection = |
| 57 orderedCollectionSerializerDecl.superclass; |
54 ClassMirror collectionOfDynamic = reflect(new Collection()).type; | 58 ClassMirror collectionOfDynamic = reflect(new Collection()).type; |
55 ClassMirror orderedCollectionOfDynamic = reflect(new OrderedCollection()).type
; | 59 ClassMirror orderedCollectionOfDynamic = |
56 ClassMirror collectionWithSerializableOfOrderedCollection = orderedCollectionD
ecl.superclass; | 60 reflect(new OrderedCollection()).type; |
| 61 ClassMirror collectionWithSerializableOfOrderedCollection = |
| 62 orderedCollectionDecl.superclass; |
57 | 63 |
58 Expect.isTrue(collectionDecl.isOriginalDeclaration); | 64 Expect.isTrue(collectionDecl.isOriginalDeclaration); |
59 Expect.isTrue(serializableDecl.isOriginalDeclaration); | 65 Expect.isTrue(serializableDecl.isOriginalDeclaration); |
60 Expect.isTrue(orderedCollectionDecl.isOriginalDeclaration); | 66 Expect.isTrue(orderedCollectionDecl.isOriginalDeclaration); |
61 Expect.isTrue(abstractOrderedCollectionDecl.isOriginalDeclaration); | 67 Expect.isTrue(abstractOrderedCollectionDecl.isOriginalDeclaration); |
62 Expect.isTrue(customOrderedCollectionDecl.isOriginalDeclaration); | 68 Expect.isTrue(customOrderedCollectionDecl.isOriginalDeclaration); |
63 Expect.isTrue(orderedIntegerCollection.isOriginalDeclaration); | 69 Expect.isTrue(orderedIntegerCollection.isOriginalDeclaration); |
64 Expect.isTrue(customOrderedIntegerCollection.isOriginalDeclaration); | 70 Expect.isTrue(customOrderedIntegerCollection.isOriginalDeclaration); |
65 Expect.isTrue(serializerDecl.isOriginalDeclaration); | 71 Expect.isTrue(serializerDecl.isOriginalDeclaration); |
66 Expect.isTrue(collectionSerializerDecl.isOriginalDeclaration); | 72 Expect.isTrue(collectionSerializerDecl.isOriginalDeclaration); |
67 Expect.isTrue(orderedCollectionSerializerDecl.isOriginalDeclaration); | 73 Expect.isTrue(orderedCollectionSerializerDecl.isOriginalDeclaration); |
68 | 74 |
69 Expect.isFalse(orderedCollectionOfInt.isOriginalDeclaration); | 75 Expect.isFalse(orderedCollectionOfInt.isOriginalDeclaration); |
70 Expect.isFalse(customOrderedCollectionOfInt.isOriginalDeclaration); | 76 Expect.isFalse(customOrderedCollectionOfInt.isOriginalDeclaration); |
71 Expect.isFalse(serializerOfCollection.isOriginalDeclaration); | 77 Expect.isFalse(serializerOfCollection.isOriginalDeclaration); |
72 Expect.isFalse(serializerOfOrderedCollection.isOriginalDeclaration); | 78 Expect.isFalse(serializerOfOrderedCollection.isOriginalDeclaration); |
73 Expect.isFalse(collectionOfDynamic.isOriginalDeclaration); | 79 Expect.isFalse(collectionOfDynamic.isOriginalDeclaration); |
74 Expect.isFalse(collectionWithSerializableOfOrderedCollection.isOriginalDeclara
tion); | 80 Expect.isFalse( |
| 81 collectionWithSerializableOfOrderedCollection.isOriginalDeclaration); |
75 | 82 |
76 TypeVariableMirror rFromSerializer = serializerDecl.typeVariables.single; | 83 TypeVariableMirror rFromSerializer = serializerDecl.typeVariables.single; |
77 ClassMirror serializableOfR = rFromSerializer.upperBound; | 84 ClassMirror serializableOfR = rFromSerializer.upperBound; |
78 Expect.isFalse(serializableOfR.isOriginalDeclaration); | 85 Expect.isFalse(serializableOfR.isOriginalDeclaration); |
79 Expect.equals(serializableDecl, serializableOfR.originalDeclaration); | 86 Expect.equals(serializableDecl, serializableOfR.originalDeclaration); |
80 Expect.equals(rFromSerializer, serializableOfR.typeArguments.single); | 87 Expect.equals(rFromSerializer, serializableOfR.typeArguments.single); |
81 | 88 |
82 typeParameters(collectionDecl, [#C]); | 89 typeParameters(collectionDecl, [#C]); |
83 typeParameters(serializableDecl, [#S]); | 90 typeParameters(serializableDecl, [#S]); |
84 typeParameters(orderedCollectionDecl, [#V]); | 91 typeParameters(orderedCollectionDecl, [#V]); |
(...skipping 22 matching lines...) Expand all Loading... |
107 typeArguments(serializerDecl, []); | 114 typeArguments(serializerDecl, []); |
108 typeArguments(collectionSerializerDecl, []); | 115 typeArguments(collectionSerializerDecl, []); |
109 typeArguments(orderedCollectionSerializerDecl, []); | 116 typeArguments(orderedCollectionSerializerDecl, []); |
110 | 117 |
111 typeArguments(orderedCollectionOfInt, [reflectClass(int)]); | 118 typeArguments(orderedCollectionOfInt, [reflectClass(int)]); |
112 typeArguments(customOrderedCollectionOfInt, [reflectClass(int)]); | 119 typeArguments(customOrderedCollectionOfInt, [reflectClass(int)]); |
113 typeArguments(serializerOfCollection, [collectionOfDynamic]); | 120 typeArguments(serializerOfCollection, [collectionOfDynamic]); |
114 typeArguments(serializerOfOrderedCollection, [orderedCollectionOfDynamic]); | 121 typeArguments(serializerOfOrderedCollection, [orderedCollectionOfDynamic]); |
115 typeArguments(collectionWithSerializableOfOrderedCollection, []); | 122 typeArguments(collectionWithSerializableOfOrderedCollection, []); |
116 } | 123 } |
OLD | NEW |