Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: pkg/analyzer/test/generated/element_test.dart

Issue 712083003: Create fewer unnecessary lists (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/test/generated/ast_test.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.element_test; 8 library engine.element_test;
9 9
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 void test_TWO_WAY() { 49 void test_TWO_WAY() {
50 AngularPropertyKind kind = AngularPropertyKind.TWO_WAY; 50 AngularPropertyKind kind = AngularPropertyKind.TWO_WAY;
51 expect(kind.callsGetter(), isTrue); 51 expect(kind.callsGetter(), isTrue);
52 expect(kind.callsSetter(), isTrue); 52 expect(kind.callsSetter(), isTrue);
53 } 53 }
54 } 54 }
55 55
56 class ClassElementImplTest extends EngineTestCase { 56 class ClassElementImplTest extends EngineTestCase {
57 void test_getAllSupertypes_interface() { 57 void test_getAllSupertypes_interface() {
58 ClassElement classA = ElementFactory.classElement2("A", []); 58 ClassElement classA = ElementFactory.classElement2("A");
59 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 59 ClassElement classB = ElementFactory.classElement("B", classA.type);
60 ClassElementImpl elementC = ElementFactory.classElement2("C", []); 60 ClassElementImpl elementC = ElementFactory.classElement2("C");
61 InterfaceType typeObject = classA.supertype; 61 InterfaceType typeObject = classA.supertype;
62 InterfaceType typeA = classA.type; 62 InterfaceType typeA = classA.type;
63 InterfaceType typeB = classB.type; 63 InterfaceType typeB = classB.type;
64 InterfaceType typeC = elementC.type; 64 InterfaceType typeC = elementC.type;
65 elementC.interfaces = <InterfaceType> [typeB]; 65 elementC.interfaces = <InterfaceType> [typeB];
66 List<InterfaceType> supers = elementC.allSupertypes; 66 List<InterfaceType> supers = elementC.allSupertypes;
67 List<InterfaceType> types = new List<InterfaceType>(); 67 List<InterfaceType> types = new List<InterfaceType>();
68 types.addAll(supers); 68 types.addAll(supers);
69 expect(types.contains(typeA), isTrue); 69 expect(types.contains(typeA), isTrue);
70 expect(types.contains(typeB), isTrue); 70 expect(types.contains(typeB), isTrue);
71 expect(types.contains(typeObject), isTrue); 71 expect(types.contains(typeObject), isTrue);
72 expect(types.contains(typeC), isFalse); 72 expect(types.contains(typeC), isFalse);
73 } 73 }
74 74
75 void test_getAllSupertypes_mixins() { 75 void test_getAllSupertypes_mixins() {
76 ClassElement classA = ElementFactory.classElement2("A", []); 76 ClassElement classA = ElementFactory.classElement2("A");
77 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 77 ClassElement classB = ElementFactory.classElement("B", classA.type);
78 ClassElementImpl classC = ElementFactory.classElement2("C", []); 78 ClassElementImpl classC = ElementFactory.classElement2("C");
79 InterfaceType typeObject = classA.supertype; 79 InterfaceType typeObject = classA.supertype;
80 InterfaceType typeA = classA.type; 80 InterfaceType typeA = classA.type;
81 InterfaceType typeB = classB.type; 81 InterfaceType typeB = classB.type;
82 InterfaceType typeC = classC.type; 82 InterfaceType typeC = classC.type;
83 classC.mixins = <InterfaceType> [typeB]; 83 classC.mixins = <InterfaceType> [typeB];
84 List<InterfaceType> supers = classC.allSupertypes; 84 List<InterfaceType> supers = classC.allSupertypes;
85 List<InterfaceType> types = new List<InterfaceType>(); 85 List<InterfaceType> types = new List<InterfaceType>();
86 types.addAll(supers); 86 types.addAll(supers);
87 expect(types.contains(typeA), isFalse); 87 expect(types.contains(typeA), isFalse);
88 expect(types.contains(typeB), isTrue); 88 expect(types.contains(typeB), isTrue);
89 expect(types.contains(typeObject), isTrue); 89 expect(types.contains(typeObject), isTrue);
90 expect(types.contains(typeC), isFalse); 90 expect(types.contains(typeC), isFalse);
91 } 91 }
92 92
93 void test_getAllSupertypes_recursive() { 93 void test_getAllSupertypes_recursive() {
94 ClassElementImpl classA = ElementFactory.classElement2("A", []); 94 ClassElementImpl classA = ElementFactory.classElement2("A");
95 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 95 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
96 classA.supertype = classB.type; 96 classA.supertype = classB.type;
97 List<InterfaceType> supers = classB.allSupertypes; 97 List<InterfaceType> supers = classB.allSupertypes;
98 expect(supers, hasLength(1)); 98 expect(supers, hasLength(1));
99 } 99 }
100 100
101 void test_getField() { 101 void test_getField() {
102 ClassElementImpl classA = ElementFactory.classElement2("A", []); 102 ClassElementImpl classA = ElementFactory.classElement2("A");
103 String fieldName = "f"; 103 String fieldName = "f";
104 FieldElementImpl field = ElementFactory.fieldElement(fieldName, false, false , false, null); 104 FieldElementImpl field = ElementFactory.fieldElement(fieldName, false, false , false, null);
105 classA.fields = <FieldElement> [field]; 105 classA.fields = <FieldElement> [field];
106 expect(classA.getField(fieldName), same(field)); 106 expect(classA.getField(fieldName), same(field));
107 // no such field 107 // no such field
108 expect(classA.getField("noSuchField"), same(null)); 108 expect(classA.getField("noSuchField"), same(null));
109 } 109 }
110 110
111 void test_getMethod_declared() { 111 void test_getMethod_declared() {
112 ClassElementImpl classA = ElementFactory.classElement2("A", []); 112 ClassElementImpl classA = ElementFactory.classElement2("A");
113 String methodName = "m"; 113 String methodName = "m";
114 MethodElement method = ElementFactory.methodElement(methodName, null, []); 114 MethodElement method = ElementFactory.methodElement(methodName, null);
115 classA.methods = <MethodElement> [method]; 115 classA.methods = <MethodElement> [method];
116 expect(classA.getMethod(methodName), same(method)); 116 expect(classA.getMethod(methodName), same(method));
117 } 117 }
118 118
119 void test_getMethod_undeclared() { 119 void test_getMethod_undeclared() {
120 ClassElementImpl classA = ElementFactory.classElement2("A", []); 120 ClassElementImpl classA = ElementFactory.classElement2("A");
121 String methodName = "m"; 121 String methodName = "m";
122 MethodElement method = ElementFactory.methodElement(methodName, null, []); 122 MethodElement method = ElementFactory.methodElement(methodName, null);
123 classA.methods = <MethodElement> [method]; 123 classA.methods = <MethodElement> [method];
124 expect(classA.getMethod("${methodName}x"), isNull); 124 expect(classA.getMethod("${methodName}x"), isNull);
125 } 125 }
126 126
127 void test_getNode() { 127 void test_getNode() {
128 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); 128 AnalysisContextHelper contextHelper = new AnalysisContextHelper();
129 AnalysisContext context = contextHelper.context; 129 AnalysisContext context = contextHelper.context;
130 Source source = contextHelper.addSource("/test.dart", r''' 130 Source source = contextHelper.addSource("/test.dart", r'''
131 class A {} 131 class A {}
132 class B {}'''); 132 class B {}''');
(...skipping 12 matching lines...) Expand all
145 { 145 {
146 ClassElement elementB = unitElement.getType("B"); 146 ClassElement elementB = unitElement.getType("B");
147 ClassDeclaration nodeB = elementB.node; 147 ClassDeclaration nodeB = elementB.node;
148 expect(nodeB, isNotNull); 148 expect(nodeB, isNotNull);
149 expect(nodeB.name.name, "B"); 149 expect(nodeB.name.name, "B");
150 expect(nodeB.element, same(elementB)); 150 expect(nodeB.element, same(elementB));
151 } 151 }
152 } 152 }
153 153
154 void test_hasNonFinalField_false_const() { 154 void test_hasNonFinalField_false_const() {
155 ClassElementImpl classA = ElementFactory.classElement2("A", []); 155 ClassElementImpl classA = ElementFactory.classElement2("A");
156 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, true, classA.type)]; 156 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, true, classA.type)];
157 expect(classA.hasNonFinalField, isFalse); 157 expect(classA.hasNonFinalField, isFalse);
158 } 158 }
159 159
160 void test_hasNonFinalField_false_final() { 160 void test_hasNonFinalField_false_final() {
161 ClassElementImpl classA = ElementFactory.classElement2("A", []); 161 ClassElementImpl classA = ElementFactory.classElement2("A");
162 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, true , false, classA.type)]; 162 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, true , false, classA.type)];
163 expect(classA.hasNonFinalField, isFalse); 163 expect(classA.hasNonFinalField, isFalse);
164 } 164 }
165 165
166 void test_hasNonFinalField_false_recursive() { 166 void test_hasNonFinalField_false_recursive() {
167 ClassElementImpl classA = ElementFactory.classElement2("A", []); 167 ClassElementImpl classA = ElementFactory.classElement2("A");
168 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 168 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
169 classA.supertype = classB.type; 169 classA.supertype = classB.type;
170 expect(classA.hasNonFinalField, isFalse); 170 expect(classA.hasNonFinalField, isFalse);
171 } 171 }
172 172
173 void test_hasNonFinalField_true_immediate() { 173 void test_hasNonFinalField_true_immediate() {
174 ClassElementImpl classA = ElementFactory.classElement2("A", []); 174 ClassElementImpl classA = ElementFactory.classElement2("A");
175 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)]; 175 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)];
176 expect(classA.hasNonFinalField, isTrue); 176 expect(classA.hasNonFinalField, isTrue);
177 } 177 }
178 178
179 void test_hasNonFinalField_true_inherited() { 179 void test_hasNonFinalField_true_inherited() {
180 ClassElementImpl classA = ElementFactory.classElement2("A", []); 180 ClassElementImpl classA = ElementFactory.classElement2("A");
181 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 181 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
182 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)]; 182 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)];
183 expect(classB.hasNonFinalField, isTrue); 183 expect(classB.hasNonFinalField, isTrue);
184 } 184 }
185 185
186 void test_hasStaticMember_false_empty() { 186 void test_hasStaticMember_false_empty() {
187 ClassElementImpl classA = ElementFactory.classElement2("A", []); 187 ClassElementImpl classA = ElementFactory.classElement2("A");
188 // no members 188 // no members
189 expect(classA.hasStaticMember, isFalse); 189 expect(classA.hasStaticMember, isFalse);
190 } 190 }
191 191
192 void test_hasStaticMember_false_instanceMethod() { 192 void test_hasStaticMember_false_instanceMethod() {
193 ClassElementImpl classA = ElementFactory.classElement2("A", []); 193 ClassElementImpl classA = ElementFactory.classElement2("A");
194 MethodElement method = ElementFactory.methodElement("foo", null, []); 194 MethodElement method = ElementFactory.methodElement("foo", null);
195 classA.methods = <MethodElement> [method]; 195 classA.methods = <MethodElement> [method];
196 expect(classA.hasStaticMember, isFalse); 196 expect(classA.hasStaticMember, isFalse);
197 } 197 }
198 198
199 void test_hasStaticMember_instanceGetter() { 199 void test_hasStaticMember_instanceGetter() {
200 ClassElementImpl classA = ElementFactory.classElement2("A", []); 200 ClassElementImpl classA = ElementFactory.classElement2("A");
201 PropertyAccessorElement getter = ElementFactory.getterElement("foo", false, null); 201 PropertyAccessorElement getter = ElementFactory.getterElement("foo", false, null);
202 classA.accessors = <PropertyAccessorElement> [getter]; 202 classA.accessors = <PropertyAccessorElement> [getter];
203 expect(classA.hasStaticMember, isFalse); 203 expect(classA.hasStaticMember, isFalse);
204 } 204 }
205 205
206 void test_hasStaticMember_true_getter() { 206 void test_hasStaticMember_true_getter() {
207 ClassElementImpl classA = ElementFactory.classElement2("A", []); 207 ClassElementImpl classA = ElementFactory.classElement2("A");
208 PropertyAccessorElementImpl getter = ElementFactory.getterElement("foo", fal se, null); 208 PropertyAccessorElementImpl getter = ElementFactory.getterElement("foo", fal se, null);
209 classA.accessors = <PropertyAccessorElement> [getter]; 209 classA.accessors = <PropertyAccessorElement> [getter];
210 // "foo" is static 210 // "foo" is static
211 getter.static = true; 211 getter.static = true;
212 expect(classA.hasStaticMember, isTrue); 212 expect(classA.hasStaticMember, isTrue);
213 } 213 }
214 214
215 void test_hasStaticMember_true_method() { 215 void test_hasStaticMember_true_method() {
216 ClassElementImpl classA = ElementFactory.classElement2("A", []); 216 ClassElementImpl classA = ElementFactory.classElement2("A");
217 MethodElementImpl method = ElementFactory.methodElement("foo", null, []); 217 MethodElementImpl method = ElementFactory.methodElement("foo", null);
218 classA.methods = <MethodElement> [method]; 218 classA.methods = <MethodElement> [method];
219 // "foo" is static 219 // "foo" is static
220 method.static = true; 220 method.static = true;
221 expect(classA.hasStaticMember, isTrue); 221 expect(classA.hasStaticMember, isTrue);
222 } 222 }
223 223
224 void test_hasStaticMember_true_setter() { 224 void test_hasStaticMember_true_setter() {
225 ClassElementImpl classA = ElementFactory.classElement2("A", []); 225 ClassElementImpl classA = ElementFactory.classElement2("A");
226 PropertyAccessorElementImpl setter = ElementFactory.setterElement("foo", fal se, null); 226 PropertyAccessorElementImpl setter = ElementFactory.setterElement("foo", fal se, null);
227 classA.accessors = <PropertyAccessorElement> [setter]; 227 classA.accessors = <PropertyAccessorElement> [setter];
228 // "foo" is static 228 // "foo" is static
229 setter.static = true; 229 setter.static = true;
230 expect(classA.hasStaticMember, isTrue); 230 expect(classA.hasStaticMember, isTrue);
231 } 231 }
232 232
233 void test_lookUpConcreteMethod_declared() { 233 void test_lookUpConcreteMethod_declared() {
234 // class A { 234 // class A {
235 // m() {} 235 // m() {}
236 // } 236 // }
237 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 237 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
238 ClassElementImpl classA = ElementFactory.classElement2("A", []); 238 ClassElementImpl classA = ElementFactory.classElement2("A");
239 String methodName = "m"; 239 String methodName = "m";
240 MethodElement method = ElementFactory.methodElement(methodName, null, []); 240 MethodElement method = ElementFactory.methodElement(methodName, null);
241 classA.methods = <MethodElement> [method]; 241 classA.methods = <MethodElement> [method];
242 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 242 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
243 expect(classA.lookUpConcreteMethod(methodName, library), same(method)); 243 expect(classA.lookUpConcreteMethod(methodName, library), same(method));
244 } 244 }
245 245
246 void test_lookUpConcreteMethod_declaredAbstract() { 246 void test_lookUpConcreteMethod_declaredAbstract() {
247 // class A { 247 // class A {
248 // m(); 248 // m();
249 // } 249 // }
250 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 250 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
251 ClassElementImpl classA = ElementFactory.classElement2("A", []); 251 ClassElementImpl classA = ElementFactory.classElement2("A");
252 String methodName = "m"; 252 String methodName = "m";
253 MethodElementImpl method = ElementFactory.methodElement(methodName, null, [] ); 253 MethodElementImpl method = ElementFactory.methodElement(methodName, null);
254 method.abstract = true; 254 method.abstract = true;
255 classA.methods = <MethodElement> [method]; 255 classA.methods = <MethodElement> [method];
256 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 256 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
257 expect(classA.lookUpConcreteMethod(methodName, library), isNull); 257 expect(classA.lookUpConcreteMethod(methodName, library), isNull);
258 } 258 }
259 259
260 void test_lookUpConcreteMethod_declaredAbstractAndInherited() { 260 void test_lookUpConcreteMethod_declaredAbstractAndInherited() {
261 // class A { 261 // class A {
262 // m() {} 262 // m() {}
263 // } 263 // }
264 // class B extends A { 264 // class B extends A {
265 // m(); 265 // m();
266 // } 266 // }
267 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 267 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
268 ClassElementImpl classA = ElementFactory.classElement2("A", []); 268 ClassElementImpl classA = ElementFactory.classElement2("A");
269 String methodName = "m"; 269 String methodName = "m";
270 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 270 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
271 classA.methods = <MethodElement> [inheritedMethod]; 271 classA.methods = <MethodElement> [inheritedMethod];
272 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 272 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
273 MethodElementImpl method = ElementFactory.methodElement(methodName, null, [] ); 273 MethodElementImpl method = ElementFactory.methodElement(methodName, null);
274 method.abstract = true; 274 method.abstract = true;
275 classB.methods = <MethodElement> [method]; 275 classB.methods = <MethodElement> [method];
276 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 276 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
277 expect(classB.lookUpConcreteMethod(methodName, library), same(inheritedMetho d)); 277 expect(classB.lookUpConcreteMethod(methodName, library), same(inheritedMetho d));
278 } 278 }
279 279
280 void test_lookUpConcreteMethod_declaredAndInherited() { 280 void test_lookUpConcreteMethod_declaredAndInherited() {
281 // class A { 281 // class A {
282 // m() {} 282 // m() {}
283 // } 283 // }
284 // class B extends A { 284 // class B extends A {
285 // m() {} 285 // m() {}
286 // } 286 // }
287 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 287 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
288 ClassElementImpl classA = ElementFactory.classElement2("A", []); 288 ClassElementImpl classA = ElementFactory.classElement2("A");
289 String methodName = "m"; 289 String methodName = "m";
290 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 290 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
291 classA.methods = <MethodElement> [inheritedMethod]; 291 classA.methods = <MethodElement> [inheritedMethod];
292 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 292 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
293 MethodElement method = ElementFactory.methodElement(methodName, null, []); 293 MethodElement method = ElementFactory.methodElement(methodName, null);
294 classB.methods = <MethodElement> [method]; 294 classB.methods = <MethodElement> [method];
295 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 295 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
296 expect(classB.lookUpConcreteMethod(methodName, library), same(method)); 296 expect(classB.lookUpConcreteMethod(methodName, library), same(method));
297 } 297 }
298 298
299 void test_lookUpConcreteMethod_declaredAndInheritedAbstract() { 299 void test_lookUpConcreteMethod_declaredAndInheritedAbstract() {
300 // abstract class A { 300 // abstract class A {
301 // m(); 301 // m();
302 // } 302 // }
303 // class B extends A { 303 // class B extends A {
304 // m() {} 304 // m() {}
305 // } 305 // }
306 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 306 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
307 ClassElementImpl classA = ElementFactory.classElement2("A", []); 307 ClassElementImpl classA = ElementFactory.classElement2("A");
308 classA.abstract = true; 308 classA.abstract = true;
309 String methodName = "m"; 309 String methodName = "m";
310 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName, null, []); 310 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName, null);
311 inheritedMethod.abstract = true; 311 inheritedMethod.abstract = true;
312 classA.methods = <MethodElement> [inheritedMethod]; 312 classA.methods = <MethodElement> [inheritedMethod];
313 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 313 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
314 MethodElement method = ElementFactory.methodElement(methodName, null, []); 314 MethodElement method = ElementFactory.methodElement(methodName, null);
315 classB.methods = <MethodElement> [method]; 315 classB.methods = <MethodElement> [method];
316 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 316 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
317 expect(classB.lookUpConcreteMethod(methodName, library), same(method)); 317 expect(classB.lookUpConcreteMethod(methodName, library), same(method));
318 } 318 }
319 319
320 void test_lookUpConcreteMethod_inherited() { 320 void test_lookUpConcreteMethod_inherited() {
321 // class A { 321 // class A {
322 // m() {} 322 // m() {}
323 // } 323 // }
324 // class B extends A { 324 // class B extends A {
325 // } 325 // }
326 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 326 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
327 ClassElementImpl classA = ElementFactory.classElement2("A", []); 327 ClassElementImpl classA = ElementFactory.classElement2("A");
328 String methodName = "m"; 328 String methodName = "m";
329 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 329 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
330 classA.methods = <MethodElement> [inheritedMethod]; 330 classA.methods = <MethodElement> [inheritedMethod];
331 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 331 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
332 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 332 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
333 expect(classB.lookUpConcreteMethod(methodName, library), same(inheritedMetho d)); 333 expect(classB.lookUpConcreteMethod(methodName, library), same(inheritedMetho d));
334 } 334 }
335 335
336 void test_lookUpConcreteMethod_undeclared() { 336 void test_lookUpConcreteMethod_undeclared() {
337 // class A { 337 // class A {
338 // } 338 // }
339 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 339 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
340 ClassElementImpl classA = ElementFactory.classElement2("A", []); 340 ClassElementImpl classA = ElementFactory.classElement2("A");
341 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 341 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
342 expect(classA.lookUpConcreteMethod("m", library), isNull); 342 expect(classA.lookUpConcreteMethod("m", library), isNull);
343 } 343 }
344 344
345 void test_lookUpGetter_declared() { 345 void test_lookUpGetter_declared() {
346 // class A { 346 // class A {
347 // get g {} 347 // get g {}
348 // } 348 // }
349 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 349 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
350 ClassElementImpl classA = ElementFactory.classElement2("A", []); 350 ClassElementImpl classA = ElementFactory.classElement2("A");
351 String getterName = "g"; 351 String getterName = "g";
352 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null); 352 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
353 classA.accessors = <PropertyAccessorElement> [getter]; 353 classA.accessors = <PropertyAccessorElement> [getter];
354 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 354 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
355 expect(classA.lookUpGetter(getterName, library), same(getter)); 355 expect(classA.lookUpGetter(getterName, library), same(getter));
356 } 356 }
357 357
358 void test_lookUpGetter_inherited() { 358 void test_lookUpGetter_inherited() {
359 // class A { 359 // class A {
360 // get g {} 360 // get g {}
361 // } 361 // }
362 // class B extends A { 362 // class B extends A {
363 // } 363 // }
364 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 364 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
365 ClassElementImpl classA = ElementFactory.classElement2("A", []); 365 ClassElementImpl classA = ElementFactory.classElement2("A");
366 String getterName = "g"; 366 String getterName = "g";
367 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null); 367 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
368 classA.accessors = <PropertyAccessorElement> [getter]; 368 classA.accessors = <PropertyAccessorElement> [getter];
369 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 369 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
370 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 370 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
371 expect(classB.lookUpGetter(getterName, library), same(getter)); 371 expect(classB.lookUpGetter(getterName, library), same(getter));
372 } 372 }
373 373
374 void test_lookUpGetter_undeclared() { 374 void test_lookUpGetter_undeclared() {
375 // class A { 375 // class A {
376 // } 376 // }
377 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 377 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
378 ClassElementImpl classA = ElementFactory.classElement2("A", []); 378 ClassElementImpl classA = ElementFactory.classElement2("A");
379 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 379 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
380 expect(classA.lookUpGetter("g", library), isNull); 380 expect(classA.lookUpGetter("g", library), isNull);
381 } 381 }
382 382
383 void test_lookUpGetter_undeclared_recursive() { 383 void test_lookUpGetter_undeclared_recursive() {
384 // class A extends B { 384 // class A extends B {
385 // } 385 // }
386 // class B extends A { 386 // class B extends A {
387 // } 387 // }
388 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 388 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
389 ClassElementImpl classA = ElementFactory.classElement2("A", []); 389 ClassElementImpl classA = ElementFactory.classElement2("A");
390 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 390 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
391 classA.supertype = classB.type; 391 classA.supertype = classB.type;
392 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 392 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
393 expect(classA.lookUpGetter("g", library), isNull); 393 expect(classA.lookUpGetter("g", library), isNull);
394 } 394 }
395 395
396 void test_lookUpInheritedConcreteGetter_declared() { 396 void test_lookUpInheritedConcreteGetter_declared() {
397 // class A { 397 // class A {
398 // get g {} 398 // get g {}
399 // } 399 // }
400 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 400 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
401 ClassElementImpl classA = ElementFactory.classElement2("A", []); 401 ClassElementImpl classA = ElementFactory.classElement2("A");
402 String getterName = "g"; 402 String getterName = "g";
403 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null); 403 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
404 classA.accessors = <PropertyAccessorElement> [getter]; 404 classA.accessors = <PropertyAccessorElement> [getter];
405 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 405 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
406 expect(classA.lookUpInheritedConcreteGetter(getterName, library), isNull); 406 expect(classA.lookUpInheritedConcreteGetter(getterName, library), isNull);
407 } 407 }
408 408
409 void test_lookUpInheritedConcreteGetter_inherited() { 409 void test_lookUpInheritedConcreteGetter_inherited() {
410 // class A { 410 // class A {
411 // get g {} 411 // get g {}
412 // } 412 // }
413 // class B extends A { 413 // class B extends A {
414 // } 414 // }
415 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 415 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
416 ClassElementImpl classA = ElementFactory.classElement2("A", []); 416 ClassElementImpl classA = ElementFactory.classElement2("A");
417 String getterName = "g"; 417 String getterName = "g";
418 PropertyAccessorElement inheritedGetter = ElementFactory.getterElement(gette rName, false, null); 418 PropertyAccessorElement inheritedGetter = ElementFactory.getterElement(gette rName, false, null);
419 classA.accessors = <PropertyAccessorElement> [inheritedGetter]; 419 classA.accessors = <PropertyAccessorElement> [inheritedGetter];
420 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 420 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
421 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 421 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
422 expect(classB.lookUpInheritedConcreteGetter(getterName, library), same(inher itedGetter)); 422 expect(classB.lookUpInheritedConcreteGetter(getterName, library), same(inher itedGetter));
423 } 423 }
424 424
425 void test_lookUpInheritedConcreteGetter_undeclared() { 425 void test_lookUpInheritedConcreteGetter_undeclared() {
426 // class A { 426 // class A {
427 // } 427 // }
428 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 428 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
429 ClassElementImpl classA = ElementFactory.classElement2("A", []); 429 ClassElementImpl classA = ElementFactory.classElement2("A");
430 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 430 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
431 expect(classA.lookUpInheritedConcreteGetter("g", library), isNull); 431 expect(classA.lookUpInheritedConcreteGetter("g", library), isNull);
432 } 432 }
433 433
434 void test_lookUpInheritedConcreteGetter_undeclared_recursive() { 434 void test_lookUpInheritedConcreteGetter_undeclared_recursive() {
435 // class A extends B { 435 // class A extends B {
436 // } 436 // }
437 // class B extends A { 437 // class B extends A {
438 // } 438 // }
439 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 439 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
440 ClassElementImpl classA = ElementFactory.classElement2("A", []); 440 ClassElementImpl classA = ElementFactory.classElement2("A");
441 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 441 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
442 classA.supertype = classB.type; 442 classA.supertype = classB.type;
443 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 443 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
444 expect(classA.lookUpInheritedConcreteGetter("g", library), isNull); 444 expect(classA.lookUpInheritedConcreteGetter("g", library), isNull);
445 } 445 }
446 446
447 void test_lookUpInheritedConcreteMethod_declared() { 447 void test_lookUpInheritedConcreteMethod_declared() {
448 // class A { 448 // class A {
449 // m() {} 449 // m() {}
450 // } 450 // }
451 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 451 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
452 ClassElementImpl classA = ElementFactory.classElement2("A", []); 452 ClassElementImpl classA = ElementFactory.classElement2("A");
453 String methodName = "m"; 453 String methodName = "m";
454 MethodElement method = ElementFactory.methodElement(methodName, null, []); 454 MethodElement method = ElementFactory.methodElement(methodName, null);
455 classA.methods = <MethodElement> [method]; 455 classA.methods = <MethodElement> [method];
456 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 456 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
457 expect(classA.lookUpInheritedConcreteMethod(methodName, library), isNull); 457 expect(classA.lookUpInheritedConcreteMethod(methodName, library), isNull);
458 } 458 }
459 459
460 void test_lookUpInheritedConcreteMethod_declaredAbstractAndInherited() { 460 void test_lookUpInheritedConcreteMethod_declaredAbstractAndInherited() {
461 // class A { 461 // class A {
462 // m() {} 462 // m() {}
463 // } 463 // }
464 // class B extends A { 464 // class B extends A {
465 // m(); 465 // m();
466 // } 466 // }
467 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 467 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
468 ClassElementImpl classA = ElementFactory.classElement2("A", []); 468 ClassElementImpl classA = ElementFactory.classElement2("A");
469 String methodName = "m"; 469 String methodName = "m";
470 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 470 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
471 classA.methods = <MethodElement> [inheritedMethod]; 471 classA.methods = <MethodElement> [inheritedMethod];
472 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 472 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
473 MethodElementImpl method = ElementFactory.methodElement(methodName, null, [] ); 473 MethodElementImpl method = ElementFactory.methodElement(methodName, null);
474 method.abstract = true; 474 method.abstract = true;
475 classB.methods = <MethodElement> [method]; 475 classB.methods = <MethodElement> [method];
476 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 476 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
477 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod)); 477 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod));
478 } 478 }
479 479
480 void test_lookUpInheritedConcreteMethod_declaredAndInherited() { 480 void test_lookUpInheritedConcreteMethod_declaredAndInherited() {
481 // class A { 481 // class A {
482 // m() {} 482 // m() {}
483 // } 483 // }
484 // class B extends A { 484 // class B extends A {
485 // m() {} 485 // m() {}
486 // } 486 // }
487 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 487 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
488 ClassElementImpl classA = ElementFactory.classElement2("A", []); 488 ClassElementImpl classA = ElementFactory.classElement2("A");
489 String methodName = "m"; 489 String methodName = "m";
490 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 490 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
491 classA.methods = <MethodElement> [inheritedMethod]; 491 classA.methods = <MethodElement> [inheritedMethod];
492 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 492 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
493 MethodElement method = ElementFactory.methodElement(methodName, null, []); 493 MethodElement method = ElementFactory.methodElement(methodName, null);
494 classB.methods = <MethodElement> [method]; 494 classB.methods = <MethodElement> [method];
495 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 495 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
496 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod)); 496 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod));
497 } 497 }
498 498
499 void test_lookUpInheritedConcreteMethod_declaredAndInheritedAbstract() { 499 void test_lookUpInheritedConcreteMethod_declaredAndInheritedAbstract() {
500 // abstract class A { 500 // abstract class A {
501 // m(); 501 // m();
502 // } 502 // }
503 // class B extends A { 503 // class B extends A {
504 // m() {} 504 // m() {}
505 // } 505 // }
506 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 506 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
507 ClassElementImpl classA = ElementFactory.classElement2("A", []); 507 ClassElementImpl classA = ElementFactory.classElement2("A");
508 classA.abstract = true; 508 classA.abstract = true;
509 String methodName = "m"; 509 String methodName = "m";
510 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName, null, []); 510 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName, null);
511 inheritedMethod.abstract = true; 511 inheritedMethod.abstract = true;
512 classA.methods = <MethodElement> [inheritedMethod]; 512 classA.methods = <MethodElement> [inheritedMethod];
513 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 513 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
514 MethodElement method = ElementFactory.methodElement(methodName, null, []); 514 MethodElement method = ElementFactory.methodElement(methodName, null);
515 classB.methods = <MethodElement> [method]; 515 classB.methods = <MethodElement> [method];
516 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 516 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
517 expect(classB.lookUpInheritedConcreteMethod(methodName, library), isNull); 517 expect(classB.lookUpInheritedConcreteMethod(methodName, library), isNull);
518 } 518 }
519 519
520 void test_lookUpInheritedConcreteMethod_declaredAndInheritedWithAbstractBetwee n() { 520 void test_lookUpInheritedConcreteMethod_declaredAndInheritedWithAbstractBetwee n() {
521 // class A { 521 // class A {
522 // m() {} 522 // m() {}
523 // } 523 // }
524 // class B extends A { 524 // class B extends A {
525 // m(); 525 // m();
526 // } 526 // }
527 // class C extends B { 527 // class C extends B {
528 // m() {} 528 // m() {}
529 // } 529 // }
530 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 530 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
531 ClassElementImpl classA = ElementFactory.classElement2("A", []); 531 ClassElementImpl classA = ElementFactory.classElement2("A");
532 String methodName = "m"; 532 String methodName = "m";
533 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 533 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
534 classA.methods = <MethodElement> [inheritedMethod]; 534 classA.methods = <MethodElement> [inheritedMethod];
535 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 535 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
536 MethodElementImpl abstractMethod = ElementFactory.methodElement(methodName, null, []); 536 MethodElementImpl abstractMethod = ElementFactory.methodElement(methodName, null);
537 abstractMethod.abstract = true; 537 abstractMethod.abstract = true;
538 classB.methods = <MethodElement> [abstractMethod]; 538 classB.methods = <MethodElement> [abstractMethod];
539 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); 539 ClassElementImpl classC = ElementFactory.classElement("C", classB.type);
540 MethodElementImpl method = ElementFactory.methodElement(methodName, null, [] ); 540 MethodElementImpl method = ElementFactory.methodElement(methodName, null);
541 classC.methods = <MethodElement> [method]; 541 classC.methods = <MethodElement> [method];
542 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB, classC]; 542 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB, classC];
543 expect(classC.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod)); 543 expect(classC.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod));
544 } 544 }
545 545
546 void test_lookUpInheritedConcreteMethod_inherited() { 546 void test_lookUpInheritedConcreteMethod_inherited() {
547 // class A { 547 // class A {
548 // m() {} 548 // m() {}
549 // } 549 // }
550 // class B extends A { 550 // class B extends A {
551 // } 551 // }
552 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 552 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
553 ClassElementImpl classA = ElementFactory.classElement2("A", []); 553 ClassElementImpl classA = ElementFactory.classElement2("A");
554 String methodName = "m"; 554 String methodName = "m";
555 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 555 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
556 classA.methods = <MethodElement> [inheritedMethod]; 556 classA.methods = <MethodElement> [inheritedMethod];
557 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 557 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
558 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 558 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
559 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod)); 559 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher itedMethod));
560 } 560 }
561 561
562 void test_lookUpInheritedConcreteMethod_undeclared() { 562 void test_lookUpInheritedConcreteMethod_undeclared() {
563 // class A { 563 // class A {
564 // } 564 // }
565 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 565 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
566 ClassElementImpl classA = ElementFactory.classElement2("A", []); 566 ClassElementImpl classA = ElementFactory.classElement2("A");
567 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 567 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
568 expect(classA.lookUpInheritedConcreteMethod("m", library), isNull); 568 expect(classA.lookUpInheritedConcreteMethod("m", library), isNull);
569 } 569 }
570 570
571 void test_lookUpInheritedConcreteSetter_declared() { 571 void test_lookUpInheritedConcreteSetter_declared() {
572 // class A { 572 // class A {
573 // set g(x) {} 573 // set g(x) {}
574 // } 574 // }
575 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 575 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
576 ClassElementImpl classA = ElementFactory.classElement2("A", []); 576 ClassElementImpl classA = ElementFactory.classElement2("A");
577 String setterName = "s"; 577 String setterName = "s";
578 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null); 578 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
579 classA.accessors = <PropertyAccessorElement> [setter]; 579 classA.accessors = <PropertyAccessorElement> [setter];
580 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 580 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
581 expect(classA.lookUpInheritedConcreteSetter(setterName, library), isNull); 581 expect(classA.lookUpInheritedConcreteSetter(setterName, library), isNull);
582 } 582 }
583 583
584 void test_lookUpInheritedConcreteSetter_inherited() { 584 void test_lookUpInheritedConcreteSetter_inherited() {
585 // class A { 585 // class A {
586 // set g(x) {} 586 // set g(x) {}
587 // } 587 // }
588 // class B extends A { 588 // class B extends A {
589 // } 589 // }
590 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 590 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
591 ClassElementImpl classA = ElementFactory.classElement2("A", []); 591 ClassElementImpl classA = ElementFactory.classElement2("A");
592 String setterName = "s"; 592 String setterName = "s";
593 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null); 593 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
594 classA.accessors = <PropertyAccessorElement> [setter]; 594 classA.accessors = <PropertyAccessorElement> [setter];
595 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 595 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
596 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 596 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
597 expect(classB.lookUpInheritedConcreteSetter(setterName, library), same(sette r)); 597 expect(classB.lookUpInheritedConcreteSetter(setterName, library), same(sette r));
598 } 598 }
599 599
600 void test_lookUpInheritedConcreteSetter_undeclared() { 600 void test_lookUpInheritedConcreteSetter_undeclared() {
601 // class A { 601 // class A {
602 // } 602 // }
603 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 603 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
604 ClassElementImpl classA = ElementFactory.classElement2("A", []); 604 ClassElementImpl classA = ElementFactory.classElement2("A");
605 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 605 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
606 expect(classA.lookUpInheritedConcreteSetter("s", library), isNull); 606 expect(classA.lookUpInheritedConcreteSetter("s", library), isNull);
607 } 607 }
608 608
609 void test_lookUpInheritedConcreteSetter_undeclared_recursive() { 609 void test_lookUpInheritedConcreteSetter_undeclared_recursive() {
610 // class A extends B { 610 // class A extends B {
611 // } 611 // }
612 // class B extends A { 612 // class B extends A {
613 // } 613 // }
614 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 614 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
615 ClassElementImpl classA = ElementFactory.classElement2("A", []); 615 ClassElementImpl classA = ElementFactory.classElement2("A");
616 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 616 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
617 classA.supertype = classB.type; 617 classA.supertype = classB.type;
618 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 618 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
619 expect(classA.lookUpInheritedConcreteSetter("s", library), isNull); 619 expect(classA.lookUpInheritedConcreteSetter("s", library), isNull);
620 } 620 }
621 621
622 void test_lookUpInheritedMethod_declared() { 622 void test_lookUpInheritedMethod_declared() {
623 // class A { 623 // class A {
624 // m() {} 624 // m() {}
625 // } 625 // }
626 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 626 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
627 ClassElementImpl classA = ElementFactory.classElement2("A", []); 627 ClassElementImpl classA = ElementFactory.classElement2("A");
628 String methodName = "m"; 628 String methodName = "m";
629 MethodElement method = ElementFactory.methodElement(methodName, null, []); 629 MethodElement method = ElementFactory.methodElement(methodName, null);
630 classA.methods = <MethodElement> [method]; 630 classA.methods = <MethodElement> [method];
631 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 631 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
632 expect(classA.lookUpInheritedMethod(methodName, library), isNull); 632 expect(classA.lookUpInheritedMethod(methodName, library), isNull);
633 } 633 }
634 634
635 void test_lookUpInheritedMethod_declaredAndInherited() { 635 void test_lookUpInheritedMethod_declaredAndInherited() {
636 // class A { 636 // class A {
637 // m() {} 637 // m() {}
638 // } 638 // }
639 // class B extends A { 639 // class B extends A {
640 // m() {} 640 // m() {}
641 // } 641 // }
642 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 642 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
643 ClassElementImpl classA = ElementFactory.classElement2("A", []); 643 ClassElementImpl classA = ElementFactory.classElement2("A");
644 String methodName = "m"; 644 String methodName = "m";
645 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 645 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
646 classA.methods = <MethodElement> [inheritedMethod]; 646 classA.methods = <MethodElement> [inheritedMethod];
647 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 647 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
648 MethodElement method = ElementFactory.methodElement(methodName, null, []); 648 MethodElement method = ElementFactory.methodElement(methodName, null);
649 classB.methods = <MethodElement> [method]; 649 classB.methods = <MethodElement> [method];
650 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 650 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
651 expect(classB.lookUpInheritedMethod(methodName, library), same(inheritedMeth od)); 651 expect(classB.lookUpInheritedMethod(methodName, library), same(inheritedMeth od));
652 } 652 }
653 653
654 void test_lookUpInheritedMethod_inherited() { 654 void test_lookUpInheritedMethod_inherited() {
655 // class A { 655 // class A {
656 // m() {} 656 // m() {}
657 // } 657 // }
658 // class B extends A { 658 // class B extends A {
659 // } 659 // }
660 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 660 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
661 ClassElementImpl classA = ElementFactory.classElement2("A", []); 661 ClassElementImpl classA = ElementFactory.classElement2("A");
662 String methodName = "m"; 662 String methodName = "m";
663 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l, []); 663 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul l);
664 classA.methods = <MethodElement> [inheritedMethod]; 664 classA.methods = <MethodElement> [inheritedMethod];
665 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 665 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
666 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 666 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
667 expect(classB.lookUpInheritedMethod(methodName, library), same(inheritedMeth od)); 667 expect(classB.lookUpInheritedMethod(methodName, library), same(inheritedMeth od));
668 } 668 }
669 669
670 void test_lookUpInheritedMethod_undeclared() { 670 void test_lookUpInheritedMethod_undeclared() {
671 // class A { 671 // class A {
672 // } 672 // }
673 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 673 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
674 ClassElementImpl classA = ElementFactory.classElement2("A", []); 674 ClassElementImpl classA = ElementFactory.classElement2("A");
675 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 675 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
676 expect(classA.lookUpInheritedMethod("m", library), isNull); 676 expect(classA.lookUpInheritedMethod("m", library), isNull);
677 } 677 }
678 678
679 void test_lookUpMethod_declared() { 679 void test_lookUpMethod_declared() {
680 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 680 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
681 ClassElementImpl classA = ElementFactory.classElement2("A", []); 681 ClassElementImpl classA = ElementFactory.classElement2("A");
682 String methodName = "m"; 682 String methodName = "m";
683 MethodElement method = ElementFactory.methodElement(methodName, null, []); 683 MethodElement method = ElementFactory.methodElement(methodName, null);
684 classA.methods = <MethodElement> [method]; 684 classA.methods = <MethodElement> [method];
685 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 685 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
686 expect(classA.lookUpMethod(methodName, library), same(method)); 686 expect(classA.lookUpMethod(methodName, library), same(method));
687 } 687 }
688 688
689 void test_lookUpMethod_inherited() { 689 void test_lookUpMethod_inherited() {
690 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 690 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
691 ClassElementImpl classA = ElementFactory.classElement2("A", []); 691 ClassElementImpl classA = ElementFactory.classElement2("A");
692 String methodName = "m"; 692 String methodName = "m";
693 MethodElement method = ElementFactory.methodElement(methodName, null, []); 693 MethodElement method = ElementFactory.methodElement(methodName, null);
694 classA.methods = <MethodElement> [method]; 694 classA.methods = <MethodElement> [method];
695 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 695 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
696 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 696 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
697 expect(classB.lookUpMethod(methodName, library), same(method)); 697 expect(classB.lookUpMethod(methodName, library), same(method));
698 } 698 }
699 699
700 void test_lookUpMethod_undeclared() { 700 void test_lookUpMethod_undeclared() {
701 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 701 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
702 ClassElementImpl classA = ElementFactory.classElement2("A", []); 702 ClassElementImpl classA = ElementFactory.classElement2("A");
703 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 703 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
704 expect(classA.lookUpMethod("m", library), isNull); 704 expect(classA.lookUpMethod("m", library), isNull);
705 } 705 }
706 706
707 void test_lookUpMethod_undeclared_recursive() { 707 void test_lookUpMethod_undeclared_recursive() {
708 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 708 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
709 ClassElementImpl classA = ElementFactory.classElement2("A", []); 709 ClassElementImpl classA = ElementFactory.classElement2("A");
710 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 710 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
711 classA.supertype = classB.type; 711 classA.supertype = classB.type;
712 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 712 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
713 expect(classA.lookUpMethod("m", library), isNull); 713 expect(classA.lookUpMethod("m", library), isNull);
714 } 714 }
715 715
716 void test_lookUpSetter_declared() { 716 void test_lookUpSetter_declared() {
717 // class A { 717 // class A {
718 // set g(x) {} 718 // set g(x) {}
719 // } 719 // }
720 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 720 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
721 ClassElementImpl classA = ElementFactory.classElement2("A", []); 721 ClassElementImpl classA = ElementFactory.classElement2("A");
722 String setterName = "s"; 722 String setterName = "s";
723 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null); 723 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
724 classA.accessors = <PropertyAccessorElement> [setter]; 724 classA.accessors = <PropertyAccessorElement> [setter];
725 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 725 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
726 expect(classA.lookUpSetter(setterName, library), same(setter)); 726 expect(classA.lookUpSetter(setterName, library), same(setter));
727 } 727 }
728 728
729 void test_lookUpSetter_inherited() { 729 void test_lookUpSetter_inherited() {
730 // class A { 730 // class A {
731 // set g(x) {} 731 // set g(x) {}
732 // } 732 // }
733 // class B extends A { 733 // class B extends A {
734 // } 734 // }
735 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 735 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
736 ClassElementImpl classA = ElementFactory.classElement2("A", []); 736 ClassElementImpl classA = ElementFactory.classElement2("A");
737 String setterName = "s"; 737 String setterName = "s";
738 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null); 738 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
739 classA.accessors = <PropertyAccessorElement> [setter]; 739 classA.accessors = <PropertyAccessorElement> [setter];
740 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 740 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
741 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 741 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
742 expect(classB.lookUpSetter(setterName, library), same(setter)); 742 expect(classB.lookUpSetter(setterName, library), same(setter));
743 } 743 }
744 744
745 void test_lookUpSetter_undeclared() { 745 void test_lookUpSetter_undeclared() {
746 // class A { 746 // class A {
747 // } 747 // }
748 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 748 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
749 ClassElementImpl classA = ElementFactory.classElement2("A", []); 749 ClassElementImpl classA = ElementFactory.classElement2("A");
750 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 750 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
751 expect(classA.lookUpSetter("s", library), isNull); 751 expect(classA.lookUpSetter("s", library), isNull);
752 } 752 }
753 753
754 void test_lookUpSetter_undeclared_recursive() { 754 void test_lookUpSetter_undeclared_recursive() {
755 // class A extends B { 755 // class A extends B {
756 // } 756 // }
757 // class B extends A { 757 // class B extends A {
758 // } 758 // }
759 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 759 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
760 ClassElementImpl classA = ElementFactory.classElement2("A", []); 760 ClassElementImpl classA = ElementFactory.classElement2("A");
761 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 761 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
762 classA.supertype = classB.type; 762 classA.supertype = classB.type;
763 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 763 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
764 expect(classA.lookUpSetter("s", library), isNull); 764 expect(classA.lookUpSetter("s", library), isNull);
765 } 765 }
766 } 766 }
767 767
768 class CompilationUnitElementImplTest extends EngineTestCase { 768 class CompilationUnitElementImplTest extends EngineTestCase {
769 void test_getEnum_declared() { 769 void test_getEnum_declared() {
770 TestTypeProvider typeProvider = new TestTypeProvider(); 770 TestTypeProvider typeProvider = new TestTypeProvider();
771 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" ); 771 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" );
772 String enumName = "E"; 772 String enumName = "E";
773 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName , []); 773 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName );
774 unit.enums = <ClassElement> [enumElement]; 774 unit.enums = <ClassElement> [enumElement];
775 expect(unit.getEnum(enumName), same(enumElement)); 775 expect(unit.getEnum(enumName), same(enumElement));
776 } 776 }
777 777
778 void test_getEnum_undeclared() { 778 void test_getEnum_undeclared() {
779 TestTypeProvider typeProvider = new TestTypeProvider(); 779 TestTypeProvider typeProvider = new TestTypeProvider();
780 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" ); 780 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" );
781 String enumName = "E"; 781 String enumName = "E";
782 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName , []); 782 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName );
783 unit.enums = <ClassElement> [enumElement]; 783 unit.enums = <ClassElement> [enumElement];
784 expect(unit.getEnum("${enumName}x"), isNull); 784 expect(unit.getEnum("${enumName}x"), isNull);
785 } 785 }
786 786
787 void test_getType_declared() { 787 void test_getType_declared() {
788 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" ); 788 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" );
789 String className = "C"; 789 String className = "C";
790 ClassElement classElement = ElementFactory.classElement2(className, []); 790 ClassElement classElement = ElementFactory.classElement2(className);
791 unit.types = <ClassElement> [classElement]; 791 unit.types = <ClassElement> [classElement];
792 expect(unit.getType(className), same(classElement)); 792 expect(unit.getType(className), same(classElement));
793 } 793 }
794 794
795 void test_getType_undeclared() { 795 void test_getType_undeclared() {
796 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" ); 796 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart" );
797 String className = "C"; 797 String className = "C";
798 ClassElement classElement = ElementFactory.classElement2(className, []); 798 ClassElement classElement = ElementFactory.classElement2(className);
799 unit.types = <ClassElement> [classElement]; 799 unit.types = <ClassElement> [classElement];
800 expect(unit.getType("${className}x"), isNull); 800 expect(unit.getType("${className}x"), isNull);
801 } 801 }
802 } 802 }
803 803
804 class ElementImplTest extends EngineTestCase { 804 class ElementImplTest extends EngineTestCase {
805 void test_equals() { 805 void test_equals() {
806 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 806 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
807 ClassElementImpl classElement = ElementFactory.classElement2("C", []); 807 ClassElementImpl classElement = ElementFactory.classElement2("C");
808 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement]; 808 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
809 FieldElement field = ElementFactory.fieldElement("next", false, false, false , classElement.type); 809 FieldElement field = ElementFactory.fieldElement("next", false, false, false , classElement.type);
810 classElement.fields = <FieldElement> [field]; 810 classElement.fields = <FieldElement> [field];
811 expect(field == field, isTrue); 811 expect(field == field, isTrue);
812 expect(field == field.getter, isFalse); 812 expect(field == field.getter, isFalse);
813 expect(field == field.setter, isFalse); 813 expect(field == field.setter, isFalse);
814 expect(field.getter == field.setter, isFalse); 814 expect(field.getter == field.setter, isFalse);
815 } 815 }
816 816
817 void test_isAccessibleIn_private_differentLibrary() { 817 void test_isAccessibleIn_private_differentLibrary() {
818 AnalysisContextImpl context = createAnalysisContext(); 818 AnalysisContextImpl context = createAnalysisContext();
819 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); 819 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
820 ClassElement classElement = ElementFactory.classElement2("_C", []); 820 ClassElement classElement = ElementFactory.classElement2("_C");
821 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement]; 821 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement];
822 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); 822 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
823 expect(classElement.isAccessibleIn(library2), isFalse); 823 expect(classElement.isAccessibleIn(library2), isFalse);
824 } 824 }
825 825
826 void test_isAccessibleIn_private_sameLibrary() { 826 void test_isAccessibleIn_private_sameLibrary() {
827 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 827 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
828 ClassElement classElement = ElementFactory.classElement2("_C", []); 828 ClassElement classElement = ElementFactory.classElement2("_C");
829 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement]; 829 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
830 expect(classElement.isAccessibleIn(library), isTrue); 830 expect(classElement.isAccessibleIn(library), isTrue);
831 } 831 }
832 832
833 void test_isAccessibleIn_public_differentLibrary() { 833 void test_isAccessibleIn_public_differentLibrary() {
834 AnalysisContextImpl context = createAnalysisContext(); 834 AnalysisContextImpl context = createAnalysisContext();
835 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); 835 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
836 ClassElement classElement = ElementFactory.classElement2("C", []); 836 ClassElement classElement = ElementFactory.classElement2("C");
837 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement]; 837 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement];
838 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); 838 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
839 expect(classElement.isAccessibleIn(library2), isTrue); 839 expect(classElement.isAccessibleIn(library2), isTrue);
840 } 840 }
841 841
842 void test_isAccessibleIn_public_sameLibrary() { 842 void test_isAccessibleIn_public_sameLibrary() {
843 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 843 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
844 ClassElement classElement = ElementFactory.classElement2("C", []); 844 ClassElement classElement = ElementFactory.classElement2("C");
845 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement]; 845 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
846 expect(classElement.isAccessibleIn(library), isTrue); 846 expect(classElement.isAccessibleIn(library), isTrue);
847 } 847 }
848 848
849 void test_isPrivate_false() { 849 void test_isPrivate_false() {
850 Element element = ElementFactory.classElement2("C", []); 850 Element element = ElementFactory.classElement2("C");
851 expect(element.isPrivate, isFalse); 851 expect(element.isPrivate, isFalse);
852 } 852 }
853 853
854 void test_isPrivate_null() { 854 void test_isPrivate_null() {
855 Element element = ElementFactory.classElement2(null, []); 855 Element element = ElementFactory.classElement2(null);
856 expect(element.isPrivate, isTrue); 856 expect(element.isPrivate, isTrue);
857 } 857 }
858 858
859 void test_isPrivate_true() { 859 void test_isPrivate_true() {
860 Element element = ElementFactory.classElement2("_C", []); 860 Element element = ElementFactory.classElement2("_C");
861 expect(element.isPrivate, isTrue); 861 expect(element.isPrivate, isTrue);
862 } 862 }
863 863
864 void test_isPublic_false() { 864 void test_isPublic_false() {
865 Element element = ElementFactory.classElement2("_C", []); 865 Element element = ElementFactory.classElement2("_C");
866 expect(element.isPublic, isFalse); 866 expect(element.isPublic, isFalse);
867 } 867 }
868 868
869 void test_isPublic_null() { 869 void test_isPublic_null() {
870 Element element = ElementFactory.classElement2(null, []); 870 Element element = ElementFactory.classElement2(null);
871 expect(element.isPublic, isFalse); 871 expect(element.isPublic, isFalse);
872 } 872 }
873 873
874 void test_isPublic_true() { 874 void test_isPublic_true() {
875 Element element = ElementFactory.classElement2("C", []); 875 Element element = ElementFactory.classElement2("C");
876 expect(element.isPublic, isTrue); 876 expect(element.isPublic, isTrue);
877 } 877 }
878 878
879 void test_SORT_BY_OFFSET() { 879 void test_SORT_BY_OFFSET() {
880 ClassElementImpl classElementA = ElementFactory.classElement2("A", []); 880 ClassElementImpl classElementA = ElementFactory.classElement2("A");
881 classElementA.nameOffset = 1; 881 classElementA.nameOffset = 1;
882 ClassElementImpl classElementB = ElementFactory.classElement2("B", []); 882 ClassElementImpl classElementB = ElementFactory.classElement2("B");
883 classElementB.nameOffset = 2; 883 classElementB.nameOffset = 2;
884 expect(Element.SORT_BY_OFFSET(classElementA, classElementA), 0); 884 expect(Element.SORT_BY_OFFSET(classElementA, classElementA), 0);
885 expect(Element.SORT_BY_OFFSET(classElementA, classElementB) < 0, isTrue); 885 expect(Element.SORT_BY_OFFSET(classElementA, classElementB) < 0, isTrue);
886 expect(Element.SORT_BY_OFFSET(classElementB, classElementA) > 0, isTrue); 886 expect(Element.SORT_BY_OFFSET(classElementB, classElementA) > 0, isTrue);
887 } 887 }
888 } 888 }
889 889
890 class ElementKindTest extends EngineTestCase { 890 class ElementKindTest extends EngineTestCase {
891 void test_of_nonNull() { 891 void test_of_nonNull() {
892 expect(ElementKind.of(ElementFactory.classElement2("A", [])), same(ElementKi nd.CLASS)); 892 expect(ElementKind.of(ElementFactory.classElement2("A")), same(ElementKind.C LASS));
893 } 893 }
894 894
895 void test_of_null() { 895 void test_of_null() {
896 expect(ElementKind.of(null), same(ElementKind.ERROR)); 896 expect(ElementKind.of(null), same(ElementKind.ERROR));
897 } 897 }
898 } 898 }
899 899
900 class ElementLocationImplTest extends EngineTestCase { 900 class ElementLocationImplTest extends EngineTestCase {
901 void test_create_encoding() { 901 void test_create_encoding() {
902 String encoding = "a;b;c"; 902 String encoding = "a;b;c";
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 type.hashCode; 1004 type.hashCode;
1005 } 1005 }
1006 1006
1007 void test_hashCode_noElement() { 1007 void test_hashCode_noElement() {
1008 FunctionTypeImpl type = new FunctionTypeImpl.con1(null); 1008 FunctionTypeImpl type = new FunctionTypeImpl.con1(null);
1009 type.hashCode; 1009 type.hashCode;
1010 } 1010 }
1011 1011
1012 void test_isAssignableTo_normalAndPositionalArgs() { 1012 void test_isAssignableTo_normalAndPositionalArgs() {
1013 // ([a]) -> void <: (a) -> void 1013 // ([a]) -> void <: (a) -> void
1014 ClassElement a = ElementFactory.classElement2("A", []); 1014 ClassElement a = ElementFactory.classElement2("A");
1015 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 1015 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1016 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe; 1016 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
1017 expect(t.isSubtypeOf(s), isTrue); 1017 expect(t.isSubtypeOf(s), isTrue);
1018 expect(s.isSubtypeOf(t), isFalse); 1018 expect(s.isSubtypeOf(t), isFalse);
1019 // assignable iff subtype 1019 // assignable iff subtype
1020 expect(t.isAssignableTo(s), isTrue); 1020 expect(t.isAssignableTo(s), isTrue);
1021 expect(s.isAssignableTo(t), isFalse); 1021 expect(s.isAssignableTo(t), isFalse);
1022 } 1022 }
1023 1023
1024 void test_isSubtypeOf_baseCase_classFunction() { 1024 void test_isSubtypeOf_baseCase_classFunction() {
1025 // () -> void <: Function 1025 // () -> void <: Function
1026 ClassElementImpl functionElement = ElementFactory.classElement2("Function", []); 1026 ClassElementImpl functionElement = ElementFactory.classElement2("Function");
1027 InterfaceTypeImpl functionType = new InterfaceTypeImpl_FunctionTypeImplTest_ test_isSubtypeOf_baseCase_classFunction(functionElement); 1027 InterfaceTypeImpl functionType = new InterfaceTypeImpl_FunctionTypeImplTest_ test_isSubtypeOf_baseCase_classFunction(functionElement);
1028 FunctionType f = ElementFactory.functionElement("f").type; 1028 FunctionType f = ElementFactory.functionElement("f").type;
1029 expect(f.isSubtypeOf(functionType), isTrue); 1029 expect(f.isSubtypeOf(functionType), isTrue);
1030 } 1030 }
1031 1031
1032 void test_isSubtypeOf_baseCase_notFunctionType() { 1032 void test_isSubtypeOf_baseCase_notFunctionType() {
1033 // class C 1033 // class C
1034 // ! () -> void <: C 1034 // ! () -> void <: C
1035 FunctionType f = ElementFactory.functionElement("f").type; 1035 FunctionType f = ElementFactory.functionElement("f").type;
1036 InterfaceType t = ElementFactory.classElement2("C", []).type; 1036 InterfaceType t = ElementFactory.classElement2("C").type;
1037 expect(f.isSubtypeOf(t), isFalse); 1037 expect(f.isSubtypeOf(t), isFalse);
1038 } 1038 }
1039 1039
1040 void test_isSubtypeOf_baseCase_null() { 1040 void test_isSubtypeOf_baseCase_null() {
1041 // ! () -> void <: null 1041 // ! () -> void <: null
1042 FunctionType f = ElementFactory.functionElement("f").type; 1042 FunctionType f = ElementFactory.functionElement("f").type;
1043 expect(f.isSubtypeOf(null), isFalse); 1043 expect(f.isSubtypeOf(null), isFalse);
1044 } 1044 }
1045 1045
1046 void test_isSubtypeOf_baseCase_self() { 1046 void test_isSubtypeOf_baseCase_self() {
1047 // () -> void <: () -> void 1047 // () -> void <: () -> void
1048 FunctionType f = ElementFactory.functionElement("f").type; 1048 FunctionType f = ElementFactory.functionElement("f").type;
1049 expect(f.isSubtypeOf(f), isTrue); 1049 expect(f.isSubtypeOf(f), isTrue);
1050 } 1050 }
1051 1051
1052 void test_isSubtypeOf_namedParameters_isAssignable() { 1052 void test_isSubtypeOf_namedParameters_isAssignable() {
1053 // B extends A 1053 // B extends A
1054 // ({name: A}) -> void <: ({name: B}) -> void 1054 // ({name: A}) -> void <: ({name: B}) -> void
1055 // ({name: B}) -> void <: ({name: A}) -> void 1055 // ({name: B}) -> void <: ({name: A}) -> void
1056 ClassElement a = ElementFactory.classElement2("A", []); 1056 ClassElement a = ElementFactory.classElement2("A");
1057 ClassElement b = ElementFactory.classElement("B", a.type, []); 1057 ClassElement b = ElementFactory.classElement("B", a.type);
1058 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type; 1058 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1059 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type; 1059 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
1060 expect(t.isSubtypeOf(s), isTrue); 1060 expect(t.isSubtypeOf(s), isTrue);
1061 expect(s.isSubtypeOf(t), isTrue); 1061 expect(s.isSubtypeOf(t), isTrue);
1062 } 1062 }
1063 1063
1064 void test_isSubtypeOf_namedParameters_isNotAssignable() { 1064 void test_isSubtypeOf_namedParameters_isNotAssignable() {
1065 // ! ({name: A}) -> void <: ({name: B}) -> void 1065 // ! ({name: A}) -> void <: ({name: B}) -> void
1066 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type; 1066 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("A")]).type;
1067 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type; 1067 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("B")]).type;
1068 expect(t.isSubtypeOf(s), isFalse); 1068 expect(t.isSubtypeOf(s), isFalse);
1069 } 1069 }
1070 1070
1071 void test_isSubtypeOf_namedParameters_namesDifferent() { 1071 void test_isSubtypeOf_namedParameters_namesDifferent() {
1072 // B extends A 1072 // B extends A
1073 // void t({A name}) {} 1073 // void t({A name}) {}
1074 // void s({A diff}) {} 1074 // void s({A diff}) {}
1075 // ! t <: s 1075 // ! t <: s
1076 // ! s <: t 1076 // ! s <: t
1077 ClassElement a = ElementFactory.classElement2("A", []); 1077 ClassElement a = ElementFactory.classElement2("A");
1078 ClassElement b = ElementFactory.classElement("B", a.type, []); 1078 ClassElement b = ElementFactory.classElement("B", a.type);
1079 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type; 1079 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1080 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "diff"], <ClassElement> [b]).type; 1080 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "diff"], <ClassElement> [b]).type;
1081 expect(t.isSubtypeOf(s), isFalse); 1081 expect(t.isSubtypeOf(s), isFalse);
1082 expect(s.isSubtypeOf(t), isFalse); 1082 expect(s.isSubtypeOf(t), isFalse);
1083 } 1083 }
1084 1084
1085 void test_isSubtypeOf_namedParameters_orderOfParams() { 1085 void test_isSubtypeOf_namedParameters_orderOfParams() {
1086 // B extends A 1086 // B extends A
1087 // ({A: A, B: B}) -> void <: ({B: B, A: A}) -> void 1087 // ({A: A, B: B}) -> void <: ({B: B, A: A}) -> void
1088 ClassElement a = ElementFactory.classElement2("A", []); 1088 ClassElement a = ElementFactory.classElement2("A");
1089 ClassElement b = ElementFactory.classElement("B", a.type, []); 1089 ClassElement b = ElementFactory.classElement("B", a.type);
1090 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type; 1090 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
1091 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type; 1091 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
1092 expect(t.isSubtypeOf(s), isTrue); 1092 expect(t.isSubtypeOf(s), isTrue);
1093 } 1093 }
1094 1094
1095 void test_isSubtypeOf_namedParameters_orderOfParams2() { 1095 void test_isSubtypeOf_namedParameters_orderOfParams2() {
1096 // B extends A 1096 // B extends A
1097 // ! ({B: B}) -> void <: ({B: B, A: A}) -> void 1097 // ! ({B: B}) -> void <: ({B: B, A: A}) -> void
1098 ClassElement a = ElementFactory.classElement2("A", []); 1098 ClassElement a = ElementFactory.classElement2("A");
1099 ClassElement b = ElementFactory.classElement("B", a.type, []); 1099 ClassElement b = ElementFactory.classElement("B", a.type);
1100 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "B"], <ClassElement> [b]).type; 1100 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "B"], <ClassElement> [b]).type;
1101 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type; 1101 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
1102 expect(t.isSubtypeOf(s), isFalse); 1102 expect(t.isSubtypeOf(s), isFalse);
1103 } 1103 }
1104 1104
1105 void test_isSubtypeOf_namedParameters_orderOfParams3() { 1105 void test_isSubtypeOf_namedParameters_orderOfParams3() {
1106 // B extends A 1106 // B extends A
1107 // ({A: A, B: B}) -> void <: ({A: A}) -> void 1107 // ({A: A, B: B}) -> void <: ({A: A}) -> void
1108 ClassElement a = ElementFactory.classElement2("A", []); 1108 ClassElement a = ElementFactory.classElement2("A");
1109 ClassElement b = ElementFactory.classElement("B", a.type, []); 1109 ClassElement b = ElementFactory.classElement("B", a.type);
1110 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type; 1110 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
1111 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B"], <ClassElement> [b]).type; 1111 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B"], <ClassElement> [b]).type;
1112 expect(t.isSubtypeOf(s), isTrue); 1112 expect(t.isSubtypeOf(s), isTrue);
1113 } 1113 }
1114 1114
1115 void test_isSubtypeOf_namedParameters_sHasMoreParams() { 1115 void test_isSubtypeOf_namedParameters_sHasMoreParams() {
1116 // B extends A 1116 // B extends A
1117 // ! ({name: A}) -> void <: ({name: B, name2: B}) -> void 1117 // ! ({name: A}) -> void <: ({name: B, name2: B}) -> void
1118 ClassElement a = ElementFactory.classElement2("A", []); 1118 ClassElement a = ElementFactory.classElement2("A");
1119 ClassElement b = ElementFactory.classElement("B", a.type, []); 1119 ClassElement b = ElementFactory.classElement("B", a.type);
1120 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type; 1120 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1121 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name", "name2"], <ClassElement> [b, b]).type; 1121 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name", "name2"], <ClassElement> [b, b]).type;
1122 expect(t.isSubtypeOf(s), isFalse); 1122 expect(t.isSubtypeOf(s), isFalse);
1123 } 1123 }
1124 1124
1125 void test_isSubtypeOf_namedParameters_tHasMoreParams() { 1125 void test_isSubtypeOf_namedParameters_tHasMoreParams() {
1126 // B extends A 1126 // B extends A
1127 // ({name: A, name2: A}) -> void <: ({name: B}) -> void 1127 // ({name: A, name2: A}) -> void <: ({name: B}) -> void
1128 ClassElement a = ElementFactory.classElement2("A", []); 1128 ClassElement a = ElementFactory.classElement2("A");
1129 ClassElement b = ElementFactory.classElement("B", a.type, []); 1129 ClassElement b = ElementFactory.classElement("B", a.type);
1130 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name", "name2"], <ClassElement> [a, a]).type; 1130 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name", "name2"], <ClassElement> [a, a]).type;
1131 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type; 1131 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
1132 expect(t.isSubtypeOf(s), isTrue); 1132 expect(t.isSubtypeOf(s), isTrue);
1133 } 1133 }
1134 1134
1135 void test_isSubtypeOf_normalAndPositionalArgs_1() { 1135 void test_isSubtypeOf_normalAndPositionalArgs_1() {
1136 // ([a]) -> void <: (a) -> void 1136 // ([a]) -> void <: (a) -> void
1137 ClassElement a = ElementFactory.classElement2("A", []); 1137 ClassElement a = ElementFactory.classElement2("A");
1138 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 1138 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1139 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe; 1139 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
1140 expect(t.isSubtypeOf(s), isTrue); 1140 expect(t.isSubtypeOf(s), isTrue);
1141 expect(s.isSubtypeOf(t), isFalse); 1141 expect(s.isSubtypeOf(t), isFalse);
1142 } 1142 }
1143 1143
1144 void test_isSubtypeOf_normalAndPositionalArgs_2() { 1144 void test_isSubtypeOf_normalAndPositionalArgs_2() {
1145 // (a, [a]) -> void <: (a) -> void 1145 // (a, [a]) -> void <: (a) -> void
1146 ClassElement a = ElementFactory.classElement2("A", []); 1146 ClassElement a = ElementFactory.classElement2("A");
1147 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a], <C lassElement> [a]).type; 1147 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a], <C lassElement> [a]).type;
1148 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe; 1148 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
1149 expect(t.isSubtypeOf(s), isTrue); 1149 expect(t.isSubtypeOf(s), isTrue);
1150 expect(s.isSubtypeOf(t), isFalse); 1150 expect(s.isSubtypeOf(t), isFalse);
1151 } 1151 }
1152 1152
1153 void test_isSubtypeOf_normalAndPositionalArgs_3() { 1153 void test_isSubtypeOf_normalAndPositionalArgs_3() {
1154 // ([a]) -> void <: () -> void 1154 // ([a]) -> void <: () -> void
1155 ClassElement a = ElementFactory.classElement2("A", []); 1155 ClassElement a = ElementFactory.classElement2("A");
1156 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 1156 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1157 FunctionType s = ElementFactory.functionElement("s").type; 1157 FunctionType s = ElementFactory.functionElement("s").type;
1158 expect(t.isSubtypeOf(s), isTrue); 1158 expect(t.isSubtypeOf(s), isTrue);
1159 expect(s.isSubtypeOf(t), isFalse); 1159 expect(s.isSubtypeOf(t), isFalse);
1160 } 1160 }
1161 1161
1162 void test_isSubtypeOf_normalAndPositionalArgs_4() { 1162 void test_isSubtypeOf_normalAndPositionalArgs_4() {
1163 // (a, b, [c, d, e]) -> void <: (a, b, c, [d]) -> void 1163 // (a, b, [c, d, e]) -> void <: (a, b, c, [d]) -> void
1164 ClassElement a = ElementFactory.classElement2("A", []); 1164 ClassElement a = ElementFactory.classElement2("A");
1165 ClassElement b = ElementFactory.classElement2("B", []); 1165 ClassElement b = ElementFactory.classElement2("B");
1166 ClassElement c = ElementFactory.classElement2("C", []); 1166 ClassElement c = ElementFactory.classElement2("C");
1167 ClassElement d = ElementFactory.classElement2("D", []); 1167 ClassElement d = ElementFactory.classElement2("D");
1168 ClassElement e = ElementFactory.classElement2("E", []); 1168 ClassElement e = ElementFactory.classElement2("E");
1169 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a, b], <ClassElement> [c, d, e]).type; 1169 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a, b], <ClassElement> [c, d, e]).type;
1170 FunctionType s = ElementFactory.functionElement6("s", <ClassElement> [a, b, c], <ClassElement> [d]).type; 1170 FunctionType s = ElementFactory.functionElement6("s", <ClassElement> [a, b, c], <ClassElement> [d]).type;
1171 expect(t.isSubtypeOf(s), isTrue); 1171 expect(t.isSubtypeOf(s), isTrue);
1172 expect(s.isSubtypeOf(t), isFalse); 1172 expect(s.isSubtypeOf(t), isFalse);
1173 } 1173 }
1174 1174
1175 void test_isSubtypeOf_normalParameters_isAssignable() { 1175 void test_isSubtypeOf_normalParameters_isAssignable() {
1176 // B extends A 1176 // B extends A
1177 // (a) -> void <: (b) -> void 1177 // (a) -> void <: (b) -> void
1178 // (b) -> void <: (a) -> void 1178 // (b) -> void <: (a) -> void
1179 ClassElement a = ElementFactory.classElement2("A", []); 1179 ClassElement a = ElementFactory.classElement2("A");
1180 ClassElement b = ElementFactory.classElement("B", a.type, []); 1180 ClassElement b = ElementFactory.classElement("B", a.type);
1181 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe; 1181 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1182 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe; 1182 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
1183 expect(t.isSubtypeOf(s), isTrue); 1183 expect(t.isSubtypeOf(s), isTrue);
1184 expect(s.isSubtypeOf(t), isTrue); 1184 expect(s.isSubtypeOf(t), isTrue);
1185 } 1185 }
1186 1186
1187 void test_isSubtypeOf_normalParameters_isNotAssignable() { 1187 void test_isSubtypeOf_normalParameters_isNotAssignable() {
1188 // ! (a) -> void <: (b) -> void 1188 // ! (a) -> void <: (b) -> void
1189 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen tFactory.classElement2("A", [])]).type; 1189 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen tFactory.classElement2("A")]).type;
1190 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen tFactory.classElement2("B", [])]).type; 1190 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen tFactory.classElement2("B")]).type;
1191 expect(t.isSubtypeOf(s), isFalse); 1191 expect(t.isSubtypeOf(s), isFalse);
1192 } 1192 }
1193 1193
1194 void test_isSubtypeOf_normalParameters_sHasMoreParams() { 1194 void test_isSubtypeOf_normalParameters_sHasMoreParams() {
1195 // B extends A 1195 // B extends A
1196 // ! (a) -> void <: (b, b) -> void 1196 // ! (a) -> void <: (b, b) -> void
1197 ClassElement a = ElementFactory.classElement2("A", []); 1197 ClassElement a = ElementFactory.classElement2("A");
1198 ClassElement b = ElementFactory.classElement("B", a.type, []); 1198 ClassElement b = ElementFactory.classElement("B", a.type);
1199 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe; 1199 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1200 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b]) .type; 1200 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b]) .type;
1201 expect(t.isSubtypeOf(s), isFalse); 1201 expect(t.isSubtypeOf(s), isFalse);
1202 } 1202 }
1203 1203
1204 void test_isSubtypeOf_normalParameters_tHasMoreParams() { 1204 void test_isSubtypeOf_normalParameters_tHasMoreParams() {
1205 // B extends A 1205 // B extends A
1206 // ! (a, a) -> void <: (a) -> void 1206 // ! (a, a) -> void <: (a) -> void
1207 ClassElement a = ElementFactory.classElement2("A", []); 1207 ClassElement a = ElementFactory.classElement2("A");
1208 ClassElement b = ElementFactory.classElement("B", a.type, []); 1208 ClassElement b = ElementFactory.classElement("B", a.type);
1209 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a]) .type; 1209 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a]) .type;
1210 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe; 1210 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
1211 // note, this is a different assertion from the other "tHasMoreParams" tests , this is 1211 // note, this is a different assertion from the other "tHasMoreParams" tests , this is
1212 // intentional as it is a difference of the "normal parameters" 1212 // intentional as it is a difference of the "normal parameters"
1213 expect(t.isSubtypeOf(s), isFalse); 1213 expect(t.isSubtypeOf(s), isFalse);
1214 } 1214 }
1215 1215
1216 void test_isSubtypeOf_Object() { 1216 void test_isSubtypeOf_Object() {
1217 // () -> void <: Object 1217 // () -> void <: Object
1218 FunctionType f = ElementFactory.functionElement("f").type; 1218 FunctionType f = ElementFactory.functionElement("f").type;
1219 InterfaceType t = ElementFactory.object.type; 1219 InterfaceType t = ElementFactory.object.type;
1220 expect(f.isSubtypeOf(t), isTrue); 1220 expect(f.isSubtypeOf(t), isTrue);
1221 } 1221 }
1222 1222
1223 void test_isSubtypeOf_positionalParameters_isAssignable() { 1223 void test_isSubtypeOf_positionalParameters_isAssignable() {
1224 // B extends A 1224 // B extends A
1225 // ([a]) -> void <: ([b]) -> void 1225 // ([a]) -> void <: ([b]) -> void
1226 // ([b]) -> void <: ([a]) -> void 1226 // ([b]) -> void <: ([a]) -> void
1227 ClassElement a = ElementFactory.classElement2("A", []); 1227 ClassElement a = ElementFactory.classElement2("A");
1228 ClassElement b = ElementFactory.classElement("B", a.type, []); 1228 ClassElement b = ElementFactory.classElement("B", a.type);
1229 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 1229 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1230 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type; 1230 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
1231 expect(t.isSubtypeOf(s), isTrue); 1231 expect(t.isSubtypeOf(s), isTrue);
1232 expect(s.isSubtypeOf(t), isTrue); 1232 expect(s.isSubtypeOf(t), isTrue);
1233 } 1233 }
1234 1234
1235 void test_isSubtypeOf_positionalParameters_isNotAssignable() { 1235 void test_isSubtypeOf_positionalParameters_isNotAssignable() {
1236 // ! ([a]) -> void <: ([b]) -> void 1236 // ! ([a]) -> void <: ([b]) -> void
1237 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ ElementFactory.classElement2("A", [])]).type; 1237 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ ElementFactory.classElement2("A")]).type;
1238 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ ElementFactory.classElement2("B", [])]).type; 1238 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ ElementFactory.classElement2("B")]).type;
1239 expect(t.isSubtypeOf(s), isFalse); 1239 expect(t.isSubtypeOf(s), isFalse);
1240 } 1240 }
1241 1241
1242 void test_isSubtypeOf_positionalParameters_sHasMoreParams() { 1242 void test_isSubtypeOf_positionalParameters_sHasMoreParams() {
1243 // B extends A 1243 // B extends A
1244 // ! ([a]) -> void <: ([b, b]) -> void 1244 // ! ([a]) -> void <: ([b, b]) -> void
1245 ClassElement a = ElementFactory.classElement2("A", []); 1245 ClassElement a = ElementFactory.classElement2("A");
1246 ClassElement b = ElementFactory.classElement("B", a.type, []); 1246 ClassElement b = ElementFactory.classElement("B", a.type);
1247 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 1247 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1248 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b, b]).type; 1248 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b, b]).type;
1249 expect(t.isSubtypeOf(s), isFalse); 1249 expect(t.isSubtypeOf(s), isFalse);
1250 } 1250 }
1251 1251
1252 void test_isSubtypeOf_positionalParameters_tHasMoreParams() { 1252 void test_isSubtypeOf_positionalParameters_tHasMoreParams() {
1253 // B extends A 1253 // B extends A
1254 // ([a, a]) -> void <: ([b]) -> void 1254 // ([a, a]) -> void <: ([b]) -> void
1255 ClassElement a = ElementFactory.classElement2("A", []); 1255 ClassElement a = ElementFactory.classElement2("A");
1256 ClassElement b = ElementFactory.classElement("B", a.type, []); 1256 ClassElement b = ElementFactory.classElement("B", a.type);
1257 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a, a]).type; 1257 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a, a]).type;
1258 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type; 1258 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
1259 expect(t.isSubtypeOf(s), isTrue); 1259 expect(t.isSubtypeOf(s), isTrue);
1260 } 1260 }
1261 1261
1262 void test_isSubtypeOf_returnType_sIsVoid() { 1262 void test_isSubtypeOf_returnType_sIsVoid() {
1263 // () -> void <: void 1263 // () -> void <: void
1264 FunctionType t = ElementFactory.functionElement("t").type; 1264 FunctionType t = ElementFactory.functionElement("t").type;
1265 FunctionType s = ElementFactory.functionElement("s").type; 1265 FunctionType s = ElementFactory.functionElement("s").type;
1266 // function s has the implicit return type of void, we assert it here 1266 // function s has the implicit return type of void, we assert it here
1267 expect(VoidTypeImpl.instance == s.returnType, isTrue); 1267 expect(VoidTypeImpl.instance == s.returnType, isTrue);
1268 expect(t.isSubtypeOf(s), isTrue); 1268 expect(t.isSubtypeOf(s), isTrue);
1269 } 1269 }
1270 1270
1271 void test_isSubtypeOf_returnType_tAssignableToS() { 1271 void test_isSubtypeOf_returnType_tAssignableToS() {
1272 // B extends A 1272 // B extends A
1273 // () -> A <: () -> B 1273 // () -> A <: () -> B
1274 // () -> B <: () -> A 1274 // () -> B <: () -> A
1275 ClassElement a = ElementFactory.classElement2("A", []); 1275 ClassElement a = ElementFactory.classElement2("A");
1276 ClassElement b = ElementFactory.classElement("B", a.type, []); 1276 ClassElement b = ElementFactory.classElement("B", a.type);
1277 FunctionType t = ElementFactory.functionElement2("t", a).type; 1277 FunctionType t = ElementFactory.functionElement2("t", a).type;
1278 FunctionType s = ElementFactory.functionElement2("s", b).type; 1278 FunctionType s = ElementFactory.functionElement2("s", b).type;
1279 expect(t.isSubtypeOf(s), isTrue); 1279 expect(t.isSubtypeOf(s), isTrue);
1280 expect(s.isSubtypeOf(t), isTrue); 1280 expect(s.isSubtypeOf(t), isTrue);
1281 } 1281 }
1282 1282
1283 void test_isSubtypeOf_returnType_tNotAssignableToS() { 1283 void test_isSubtypeOf_returnType_tNotAssignableToS() {
1284 // ! () -> A <: () -> B 1284 // ! () -> A <: () -> B
1285 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type; 1285 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A")).type;
1286 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl ement2("B", [])).type; 1286 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl ement2("B")).type;
1287 expect(t.isSubtypeOf(s), isFalse); 1287 expect(t.isSubtypeOf(s), isFalse);
1288 } 1288 }
1289 1289
1290 void test_isSubtypeOf_typeParameters_matchesBounds() { 1290 void test_isSubtypeOf_typeParameters_matchesBounds() {
1291 TestTypeProvider provider = new TestTypeProvider(); 1291 TestTypeProvider provider = new TestTypeProvider();
1292 InterfaceType boolType = provider.boolType; 1292 InterfaceType boolType = provider.boolType;
1293 InterfaceType stringType = provider.stringType; 1293 InterfaceType stringType = provider.stringType;
1294 TypeParameterElementImpl parameterB = new TypeParameterElementImpl.forNode(A stFactory.identifier3("B")); 1294 TypeParameterElementImpl parameterB = new TypeParameterElementImpl.forNode(A stFactory.identifier3("B"));
1295 parameterB.bound = boolType; 1295 parameterB.bound = boolType;
1296 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB); 1296 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB);
(...skipping 13 matching lines...) Expand all
1310 ElementFactory.positionalParameter2("d", stringType)]; 1310 ElementFactory.positionalParameter2("d", stringType)];
1311 functionElement.returnType = provider.dynamicType; 1311 functionElement.returnType = provider.dynamicType;
1312 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 1312 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1313 functionElement.type = functionType; 1313 functionElement.type = functionType;
1314 expect(functionType.isAssignableTo(functionAliasType), isTrue); 1314 expect(functionType.isAssignableTo(functionAliasType), isTrue);
1315 } 1315 }
1316 1316
1317 void test_isSubtypeOf_wrongFunctionType_normal_named() { 1317 void test_isSubtypeOf_wrongFunctionType_normal_named() {
1318 // ! (a) -> void <: ({name: A}) -> void 1318 // ! (a) -> void <: ({name: A}) -> void
1319 // ! ({name: A}) -> void <: (a) -> void 1319 // ! ({name: A}) -> void <: (a) -> void
1320 ClassElement a = ElementFactory.classElement2("A", []); 1320 ClassElement a = ElementFactory.classElement2("A");
1321 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe; 1321 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1322 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type; 1322 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
1323 expect(t.isSubtypeOf(s), isFalse); 1323 expect(t.isSubtypeOf(s), isFalse);
1324 expect(s.isSubtypeOf(t), isFalse); 1324 expect(s.isSubtypeOf(t), isFalse);
1325 } 1325 }
1326 1326
1327 void test_isSubtypeOf_wrongFunctionType_optional_named() { 1327 void test_isSubtypeOf_wrongFunctionType_optional_named() {
1328 // ! ([a]) -> void <: ({name: A}) -> void 1328 // ! ([a]) -> void <: ({name: A}) -> void
1329 // ! ({name: A}) -> void <: ([a]) -> void 1329 // ! ({name: A}) -> void <: ([a]) -> void
1330 ClassElement a = ElementFactory.classElement2("A", []); 1330 ClassElement a = ElementFactory.classElement2("A");
1331 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 1331 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1332 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type; 1332 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
1333 expect(t.isSubtypeOf(s), isFalse); 1333 expect(t.isSubtypeOf(s), isFalse);
1334 expect(s.isSubtypeOf(t), isFalse); 1334 expect(s.isSubtypeOf(t), isFalse);
1335 } 1335 }
1336 1336
1337 void test_setTypeArguments() { 1337 void test_setTypeArguments() {
1338 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); 1338 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]);
1339 MethodElementImpl methodElement = new MethodElementImpl.forNode(AstFactory.i dentifier3("m")); 1339 MethodElementImpl methodElement = new MethodElementImpl.forNode(AstFactory.i dentifier3("m"));
1340 enclosingClass.methods = <MethodElement> [methodElement]; 1340 enclosingClass.methods = <MethodElement> [methodElement];
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 // Object 1446 // Object
1447 // | 1447 // |
1448 // A 1448 // A
1449 // / \ 1449 // / \
1450 // B C 1450 // B C
1451 // | | 1451 // | |
1452 // | D 1452 // | D
1453 // \ / 1453 // \ /
1454 // E 1454 // E
1455 // 1455 //
1456 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1456 ClassElementImpl classA = ElementFactory.classElement2("A");
1457 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1457 ClassElementImpl classB = ElementFactory.classElement2("B");
1458 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1458 ClassElementImpl classC = ElementFactory.classElement2("C");
1459 ClassElementImpl classD = ElementFactory.classElement2("D", []); 1459 ClassElementImpl classD = ElementFactory.classElement2("D");
1460 ClassElementImpl classE = ElementFactory.classElement2("E", []); 1460 ClassElementImpl classE = ElementFactory.classElement2("E");
1461 classB.interfaces = <InterfaceType> [classA.type]; 1461 classB.interfaces = <InterfaceType> [classA.type];
1462 classC.interfaces = <InterfaceType> [classA.type]; 1462 classC.interfaces = <InterfaceType> [classA.type];
1463 classD.interfaces = <InterfaceType> [classC.type]; 1463 classD.interfaces = <InterfaceType> [classC.type];
1464 classE.interfaces = <InterfaceType> [classB.type, classD.type]; 1464 classE.interfaces = <InterfaceType> [classB.type, classD.type];
1465 // assertion: even though the longest path to Object for typeB is 2, and typ eE implements typeB, 1465 // assertion: even though the longest path to Object for typeB is 2, and typ eE implements typeB,
1466 // the longest path for typeE is 4 since it also implements typeD 1466 // the longest path for typeE is 4 since it also implements typeD
1467 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2); 1467 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2);
1468 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classE.type), 4); 1468 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classE.type), 4);
1469 } 1469 }
1470 1470
1471 void test_computeLongestInheritancePathToObject_multipleSuperclassPaths() { 1471 void test_computeLongestInheritancePathToObject_multipleSuperclassPaths() {
1472 // 1472 //
1473 // Object 1473 // Object
1474 // | 1474 // |
1475 // A 1475 // A
1476 // / \ 1476 // / \
1477 // B C 1477 // B C
1478 // | | 1478 // | |
1479 // | D 1479 // | D
1480 // \ / 1480 // \ /
1481 // E 1481 // E
1482 // 1482 //
1483 ClassElement classA = ElementFactory.classElement2("A", []); 1483 ClassElement classA = ElementFactory.classElement2("A");
1484 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 1484 ClassElement classB = ElementFactory.classElement("B", classA.type);
1485 ClassElement classC = ElementFactory.classElement("C", classA.type, []); 1485 ClassElement classC = ElementFactory.classElement("C", classA.type);
1486 ClassElement classD = ElementFactory.classElement("D", classC.type, []); 1486 ClassElement classD = ElementFactory.classElement("D", classC.type);
1487 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); 1487 ClassElementImpl classE = ElementFactory.classElement("E", classB.type);
1488 classE.interfaces = <InterfaceType> [classD.type]; 1488 classE.interfaces = <InterfaceType> [classD.type];
1489 // assertion: even though the longest path to Object for typeB is 2, and typ eE extends typeB, 1489 // assertion: even though the longest path to Object for typeB is 2, and typ eE extends typeB,
1490 // the longest path for typeE is 4 since it also implements typeD 1490 // the longest path for typeE is 4 since it also implements typeD
1491 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2); 1491 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2);
1492 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classE.type), 4); 1492 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classE.type), 4);
1493 } 1493 }
1494 1494
1495 void test_computeLongestInheritancePathToObject_object() { 1495 void test_computeLongestInheritancePathToObject_object() {
1496 // 1496 //
1497 // Object 1497 // Object
1498 // | 1498 // |
1499 // A 1499 // A
1500 // 1500 //
1501 ClassElement classA = ElementFactory.classElement2("A", []); 1501 ClassElement classA = ElementFactory.classElement2("A");
1502 InterfaceType object = classA.supertype; 1502 InterfaceType object = classA.supertype;
1503 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(object), 0); 1503 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(object), 0);
1504 } 1504 }
1505 1505
1506 void test_computeLongestInheritancePathToObject_recursion() { 1506 void test_computeLongestInheritancePathToObject_recursion() {
1507 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1507 ClassElementImpl classA = ElementFactory.classElement2("A");
1508 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1508 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
1509 classA.supertype = classB.type; 1509 classA.supertype = classB.type;
1510 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type), 2); 1510 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type), 2);
1511 } 1511 }
1512 1512
1513 void test_computeLongestInheritancePathToObject_singleInterfacePath() { 1513 void test_computeLongestInheritancePathToObject_singleInterfacePath() {
1514 // 1514 //
1515 // Object 1515 // Object
1516 // | 1516 // |
1517 // A 1517 // A
1518 // | 1518 // |
1519 // B 1519 // B
1520 // | 1520 // |
1521 // C 1521 // C
1522 // 1522 //
1523 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1523 ClassElementImpl classA = ElementFactory.classElement2("A");
1524 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1524 ClassElementImpl classB = ElementFactory.classElement2("B");
1525 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1525 ClassElementImpl classC = ElementFactory.classElement2("C");
1526 classB.interfaces = <InterfaceType> [classA.type]; 1526 classB.interfaces = <InterfaceType> [classA.type];
1527 classC.interfaces = <InterfaceType> [classB.type]; 1527 classC.interfaces = <InterfaceType> [classB.type];
1528 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type), 1); 1528 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type), 1);
1529 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2); 1529 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2);
1530 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classC.type), 3); 1530 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classC.type), 3);
1531 } 1531 }
1532 1532
1533 void test_computeLongestInheritancePathToObject_singleSuperclassPath() { 1533 void test_computeLongestInheritancePathToObject_singleSuperclassPath() {
1534 // 1534 //
1535 // Object 1535 // Object
1536 // | 1536 // |
1537 // A 1537 // A
1538 // | 1538 // |
1539 // B 1539 // B
1540 // | 1540 // |
1541 // C 1541 // C
1542 // 1542 //
1543 ClassElement classA = ElementFactory.classElement2("A", []); 1543 ClassElement classA = ElementFactory.classElement2("A");
1544 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 1544 ClassElement classB = ElementFactory.classElement("B", classA.type);
1545 ClassElement classC = ElementFactory.classElement("C", classB.type, []); 1545 ClassElement classC = ElementFactory.classElement("C", classB.type);
1546 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type), 1); 1546 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type), 1);
1547 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2); 1547 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type), 2);
1548 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classC.type), 3); 1548 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classC.type), 3);
1549 } 1549 }
1550 1550
1551 void test_computeSuperinterfaceSet_genericInterfacePath() { 1551 void test_computeSuperinterfaceSet_genericInterfacePath() {
1552 // 1552 //
1553 // A 1553 // A
1554 // | implements 1554 // | implements
1555 // B<T> 1555 // B<T>
1556 // | implements 1556 // | implements
1557 // C<T> 1557 // C<T>
1558 // 1558 //
1559 // D 1559 // D
1560 // 1560 //
1561 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1561 ClassElementImpl classA = ElementFactory.classElement2("A");
1562 ClassElementImpl classB = ElementFactory.classElement2("B", ["T"]); 1562 ClassElementImpl classB = ElementFactory.classElement2("B", ["T"]);
1563 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]); 1563 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]);
1564 ClassElement classD = ElementFactory.classElement2("D", []); 1564 ClassElement classD = ElementFactory.classElement2("D");
1565 InterfaceType typeA = classA.type; 1565 InterfaceType typeA = classA.type;
1566 classB.interfaces = <InterfaceType> [typeA]; 1566 classB.interfaces = <InterfaceType> [typeA];
1567 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB); 1567 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB);
1568 DartType typeT = classC.type.typeArguments[0]; 1568 DartType typeT = classC.type.typeArguments[0];
1569 typeBT.typeArguments = <DartType> [typeT]; 1569 typeBT.typeArguments = <DartType> [typeT];
1570 classC.interfaces = <InterfaceType> [typeBT]; 1570 classC.interfaces = <InterfaceType> [typeBT];
1571 // A 1571 // A
1572 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(typeA); 1572 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(typeA);
1573 expect(superinterfacesOfA, hasLength(1)); 1573 expect(superinterfacesOfA, hasLength(1));
1574 InterfaceType typeObject = ElementFactory.object.type; 1574 InterfaceType typeObject = ElementFactory.object.type;
(...skipping 18 matching lines...) Expand all
1593 void test_computeSuperinterfaceSet_genericSuperclassPath() { 1593 void test_computeSuperinterfaceSet_genericSuperclassPath() {
1594 // 1594 //
1595 // A 1595 // A
1596 // | 1596 // |
1597 // B<T> 1597 // B<T>
1598 // | 1598 // |
1599 // C<T> 1599 // C<T>
1600 // 1600 //
1601 // D 1601 // D
1602 // 1602 //
1603 ClassElement classA = ElementFactory.classElement2("A", []); 1603 ClassElement classA = ElementFactory.classElement2("A");
1604 InterfaceType typeA = classA.type; 1604 InterfaceType typeA = classA.type;
1605 ClassElement classB = ElementFactory.classElement("B", typeA, ["T"]); 1605 ClassElement classB = ElementFactory.classElement("B", typeA, ["T"]);
1606 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]); 1606 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]);
1607 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB); 1607 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB);
1608 DartType typeT = classC.type.typeArguments[0]; 1608 DartType typeT = classC.type.typeArguments[0];
1609 typeBT.typeArguments = <DartType> [typeT]; 1609 typeBT.typeArguments = <DartType> [typeT];
1610 classC.supertype = typeBT; 1610 classC.supertype = typeBT;
1611 ClassElement classD = ElementFactory.classElement2("D", []); 1611 ClassElement classD = ElementFactory.classElement2("D");
1612 // A 1612 // A
1613 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(typeA); 1613 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(typeA);
1614 expect(superinterfacesOfA, hasLength(1)); 1614 expect(superinterfacesOfA, hasLength(1));
1615 InterfaceType typeObject = ElementFactory.object.type; 1615 InterfaceType typeObject = ElementFactory.object.type;
1616 expect(superinterfacesOfA.contains(typeObject), isTrue); 1616 expect(superinterfacesOfA.contains(typeObject), isTrue);
1617 // B<D> 1617 // B<D>
1618 InterfaceTypeImpl typeBD = new InterfaceTypeImpl.con1(classB); 1618 InterfaceTypeImpl typeBD = new InterfaceTypeImpl.con1(classB);
1619 typeBD.typeArguments = <DartType> [classD.type]; 1619 typeBD.typeArguments = <DartType> [classD.type];
1620 Set<InterfaceType> superinterfacesOfBD = InterfaceTypeImpl.computeSuperinter faceSet(typeBD); 1620 Set<InterfaceType> superinterfacesOfBD = InterfaceTypeImpl.computeSuperinter faceSet(typeBD);
1621 expect(superinterfacesOfBD, hasLength(2)); 1621 expect(superinterfacesOfBD, hasLength(2));
1622 expect(superinterfacesOfBD.contains(typeObject), isTrue); 1622 expect(superinterfacesOfBD.contains(typeObject), isTrue);
1623 expect(superinterfacesOfBD.contains(typeA), isTrue); 1623 expect(superinterfacesOfBD.contains(typeA), isTrue);
1624 // C<D> 1624 // C<D>
1625 InterfaceTypeImpl typeCD = new InterfaceTypeImpl.con1(classC); 1625 InterfaceTypeImpl typeCD = new InterfaceTypeImpl.con1(classC);
1626 typeCD.typeArguments = <DartType> [classD.type]; 1626 typeCD.typeArguments = <DartType> [classD.type];
1627 Set<InterfaceType> superinterfacesOfCD = InterfaceTypeImpl.computeSuperinter faceSet(typeCD); 1627 Set<InterfaceType> superinterfacesOfCD = InterfaceTypeImpl.computeSuperinter faceSet(typeCD);
1628 expect(superinterfacesOfCD, hasLength(3)); 1628 expect(superinterfacesOfCD, hasLength(3));
1629 expect(superinterfacesOfCD.contains(typeObject), isTrue); 1629 expect(superinterfacesOfCD.contains(typeObject), isTrue);
1630 expect(superinterfacesOfCD.contains(typeA), isTrue); 1630 expect(superinterfacesOfCD.contains(typeA), isTrue);
1631 expect(superinterfacesOfCD.contains(typeBD), isTrue); 1631 expect(superinterfacesOfCD.contains(typeBD), isTrue);
1632 } 1632 }
1633 1633
1634 void test_computeSuperinterfaceSet_multipleInterfacePaths() { 1634 void test_computeSuperinterfaceSet_multipleInterfacePaths() {
1635 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1635 ClassElementImpl classA = ElementFactory.classElement2("A");
1636 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1636 ClassElementImpl classB = ElementFactory.classElement2("B");
1637 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1637 ClassElementImpl classC = ElementFactory.classElement2("C");
1638 ClassElementImpl classD = ElementFactory.classElement2("D", []); 1638 ClassElementImpl classD = ElementFactory.classElement2("D");
1639 ClassElementImpl classE = ElementFactory.classElement2("E", []); 1639 ClassElementImpl classE = ElementFactory.classElement2("E");
1640 classB.interfaces = <InterfaceType> [classA.type]; 1640 classB.interfaces = <InterfaceType> [classA.type];
1641 classC.interfaces = <InterfaceType> [classA.type]; 1641 classC.interfaces = <InterfaceType> [classA.type];
1642 classD.interfaces = <InterfaceType> [classC.type]; 1642 classD.interfaces = <InterfaceType> [classC.type];
1643 classE.interfaces = <InterfaceType> [classB.type, classD.type]; 1643 classE.interfaces = <InterfaceType> [classB.type, classD.type];
1644 // D 1644 // D
1645 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(classD.type); 1645 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(classD.type);
1646 expect(superinterfacesOfD, hasLength(3)); 1646 expect(superinterfacesOfD, hasLength(3));
1647 expect(superinterfacesOfD.contains(ElementFactory.object.type), isTrue); 1647 expect(superinterfacesOfD.contains(ElementFactory.object.type), isTrue);
1648 expect(superinterfacesOfD.contains(classA.type), isTrue); 1648 expect(superinterfacesOfD.contains(classA.type), isTrue);
1649 expect(superinterfacesOfD.contains(classC.type), isTrue); 1649 expect(superinterfacesOfD.contains(classC.type), isTrue);
1650 // E 1650 // E
1651 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(classE.type); 1651 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(classE.type);
1652 expect(superinterfacesOfE, hasLength(5)); 1652 expect(superinterfacesOfE, hasLength(5));
1653 expect(superinterfacesOfE.contains(ElementFactory.object.type), isTrue); 1653 expect(superinterfacesOfE.contains(ElementFactory.object.type), isTrue);
1654 expect(superinterfacesOfE.contains(classA.type), isTrue); 1654 expect(superinterfacesOfE.contains(classA.type), isTrue);
1655 expect(superinterfacesOfE.contains(classB.type), isTrue); 1655 expect(superinterfacesOfE.contains(classB.type), isTrue);
1656 expect(superinterfacesOfE.contains(classC.type), isTrue); 1656 expect(superinterfacesOfE.contains(classC.type), isTrue);
1657 expect(superinterfacesOfE.contains(classD.type), isTrue); 1657 expect(superinterfacesOfE.contains(classD.type), isTrue);
1658 } 1658 }
1659 1659
1660 void test_computeSuperinterfaceSet_multipleSuperclassPaths() { 1660 void test_computeSuperinterfaceSet_multipleSuperclassPaths() {
1661 ClassElement classA = ElementFactory.classElement2("A", []); 1661 ClassElement classA = ElementFactory.classElement2("A");
1662 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 1662 ClassElement classB = ElementFactory.classElement("B", classA.type);
1663 ClassElement classC = ElementFactory.classElement("C", classA.type, []); 1663 ClassElement classC = ElementFactory.classElement("C", classA.type);
1664 ClassElement classD = ElementFactory.classElement("D", classC.type, []); 1664 ClassElement classD = ElementFactory.classElement("D", classC.type);
1665 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); 1665 ClassElementImpl classE = ElementFactory.classElement("E", classB.type);
1666 classE.interfaces = <InterfaceType> [classD.type]; 1666 classE.interfaces = <InterfaceType> [classD.type];
1667 // D 1667 // D
1668 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(classD.type); 1668 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(classD.type);
1669 expect(superinterfacesOfD, hasLength(3)); 1669 expect(superinterfacesOfD, hasLength(3));
1670 expect(superinterfacesOfD.contains(ElementFactory.object.type), isTrue); 1670 expect(superinterfacesOfD.contains(ElementFactory.object.type), isTrue);
1671 expect(superinterfacesOfD.contains(classA.type), isTrue); 1671 expect(superinterfacesOfD.contains(classA.type), isTrue);
1672 expect(superinterfacesOfD.contains(classC.type), isTrue); 1672 expect(superinterfacesOfD.contains(classC.type), isTrue);
1673 // E 1673 // E
1674 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(classE.type); 1674 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(classE.type);
1675 expect(superinterfacesOfE, hasLength(5)); 1675 expect(superinterfacesOfE, hasLength(5));
1676 expect(superinterfacesOfE.contains(ElementFactory.object.type), isTrue); 1676 expect(superinterfacesOfE.contains(ElementFactory.object.type), isTrue);
1677 expect(superinterfacesOfE.contains(classA.type), isTrue); 1677 expect(superinterfacesOfE.contains(classA.type), isTrue);
1678 expect(superinterfacesOfE.contains(classB.type), isTrue); 1678 expect(superinterfacesOfE.contains(classB.type), isTrue);
1679 expect(superinterfacesOfE.contains(classC.type), isTrue); 1679 expect(superinterfacesOfE.contains(classC.type), isTrue);
1680 expect(superinterfacesOfE.contains(classD.type), isTrue); 1680 expect(superinterfacesOfE.contains(classD.type), isTrue);
1681 } 1681 }
1682 1682
1683 void test_computeSuperinterfaceSet_recursion() { 1683 void test_computeSuperinterfaceSet_recursion() {
1684 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1684 ClassElementImpl classA = ElementFactory.classElement2("A");
1685 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1685 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
1686 classA.supertype = classB.type; 1686 classA.supertype = classB.type;
1687 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type); 1687 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type);
1688 expect(superinterfacesOfB, hasLength(2)); 1688 expect(superinterfacesOfB, hasLength(2));
1689 } 1689 }
1690 1690
1691 void test_computeSuperinterfaceSet_singleInterfacePath() { 1691 void test_computeSuperinterfaceSet_singleInterfacePath() {
1692 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1692 ClassElementImpl classA = ElementFactory.classElement2("A");
1693 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1693 ClassElementImpl classB = ElementFactory.classElement2("B");
1694 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1694 ClassElementImpl classC = ElementFactory.classElement2("C");
1695 classB.interfaces = <InterfaceType> [classA.type]; 1695 classB.interfaces = <InterfaceType> [classA.type];
1696 classC.interfaces = <InterfaceType> [classB.type]; 1696 classC.interfaces = <InterfaceType> [classB.type];
1697 // A 1697 // A
1698 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(classA.type); 1698 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(classA.type);
1699 expect(superinterfacesOfA, hasLength(1)); 1699 expect(superinterfacesOfA, hasLength(1));
1700 expect(superinterfacesOfA.contains(ElementFactory.object.type), isTrue); 1700 expect(superinterfacesOfA.contains(ElementFactory.object.type), isTrue);
1701 // B 1701 // B
1702 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type); 1702 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type);
1703 expect(superinterfacesOfB, hasLength(2)); 1703 expect(superinterfacesOfB, hasLength(2));
1704 expect(superinterfacesOfB.contains(ElementFactory.object.type), isTrue); 1704 expect(superinterfacesOfB.contains(ElementFactory.object.type), isTrue);
1705 expect(superinterfacesOfB.contains(classA.type), isTrue); 1705 expect(superinterfacesOfB.contains(classA.type), isTrue);
1706 // C 1706 // C
1707 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(classC.type); 1707 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(classC.type);
1708 expect(superinterfacesOfC, hasLength(3)); 1708 expect(superinterfacesOfC, hasLength(3));
1709 expect(superinterfacesOfC.contains(ElementFactory.object.type), isTrue); 1709 expect(superinterfacesOfC.contains(ElementFactory.object.type), isTrue);
1710 expect(superinterfacesOfC.contains(classA.type), isTrue); 1710 expect(superinterfacesOfC.contains(classA.type), isTrue);
1711 expect(superinterfacesOfC.contains(classB.type), isTrue); 1711 expect(superinterfacesOfC.contains(classB.type), isTrue);
1712 } 1712 }
1713 1713
1714 void test_computeSuperinterfaceSet_singleSuperclassPath() { 1714 void test_computeSuperinterfaceSet_singleSuperclassPath() {
1715 // 1715 //
1716 // A 1716 // A
1717 // | 1717 // |
1718 // B 1718 // B
1719 // | 1719 // |
1720 // C 1720 // C
1721 // 1721 //
1722 ClassElement classA = ElementFactory.classElement2("A", []); 1722 ClassElement classA = ElementFactory.classElement2("A");
1723 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 1723 ClassElement classB = ElementFactory.classElement("B", classA.type);
1724 ClassElement classC = ElementFactory.classElement("C", classB.type, []); 1724 ClassElement classC = ElementFactory.classElement("C", classB.type);
1725 // A 1725 // A
1726 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(classA.type); 1726 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(classA.type);
1727 expect(superinterfacesOfA, hasLength(1)); 1727 expect(superinterfacesOfA, hasLength(1));
1728 expect(superinterfacesOfA.contains(ElementFactory.object.type), isTrue); 1728 expect(superinterfacesOfA.contains(ElementFactory.object.type), isTrue);
1729 // B 1729 // B
1730 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type); 1730 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type);
1731 expect(superinterfacesOfB, hasLength(2)); 1731 expect(superinterfacesOfB, hasLength(2));
1732 expect(superinterfacesOfB.contains(ElementFactory.object.type), isTrue); 1732 expect(superinterfacesOfB.contains(ElementFactory.object.type), isTrue);
1733 expect(superinterfacesOfB.contains(classA.type), isTrue); 1733 expect(superinterfacesOfB.contains(classA.type), isTrue);
1734 // C 1734 // C
1735 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(classC.type); 1735 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(classC.type);
1736 expect(superinterfacesOfC, hasLength(3)); 1736 expect(superinterfacesOfC, hasLength(3));
1737 expect(superinterfacesOfC.contains(ElementFactory.object.type), isTrue); 1737 expect(superinterfacesOfC.contains(ElementFactory.object.type), isTrue);
1738 expect(superinterfacesOfC.contains(classA.type), isTrue); 1738 expect(superinterfacesOfC.contains(classA.type), isTrue);
1739 expect(superinterfacesOfC.contains(classB.type), isTrue); 1739 expect(superinterfacesOfC.contains(classB.type), isTrue);
1740 } 1740 }
1741 1741
1742 void test_creation() { 1742 void test_creation() {
1743 expect(new InterfaceTypeImpl.con1(ElementFactory.classElement2("A", [])), is NotNull); 1743 expect(new InterfaceTypeImpl.con1(ElementFactory.classElement2("A")), isNotN ull);
1744 } 1744 }
1745 1745
1746 void test_getAccessors() { 1746 void test_getAccessors() {
1747 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); 1747 ClassElementImpl typeElement = ElementFactory.classElement2("A");
1748 PropertyAccessorElement getterG = ElementFactory.getterElement("g", false, n ull); 1748 PropertyAccessorElement getterG = ElementFactory.getterElement("g", false, n ull);
1749 PropertyAccessorElement getterH = ElementFactory.getterElement("h", false, n ull); 1749 PropertyAccessorElement getterH = ElementFactory.getterElement("h", false, n ull);
1750 typeElement.accessors = <PropertyAccessorElement> [getterG, getterH]; 1750 typeElement.accessors = <PropertyAccessorElement> [getterG, getterH];
1751 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); 1751 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
1752 expect(type.accessors.length, 2); 1752 expect(type.accessors.length, 2);
1753 } 1753 }
1754 1754
1755 void test_getAccessors_empty() { 1755 void test_getAccessors_empty() {
1756 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); 1756 ClassElementImpl typeElement = ElementFactory.classElement2("A");
1757 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); 1757 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
1758 expect(type.accessors.length, 0); 1758 expect(type.accessors.length, 0);
1759 } 1759 }
1760 1760
1761 void test_getElement() { 1761 void test_getElement() {
1762 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); 1762 ClassElementImpl typeElement = ElementFactory.classElement2("A");
1763 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); 1763 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
1764 expect(type.element, typeElement); 1764 expect(type.element, typeElement);
1765 } 1765 }
1766 1766
1767 void test_getGetter_implemented() { 1767 void test_getGetter_implemented() {
1768 // 1768 //
1769 // class A { g {} } 1769 // class A { g {} }
1770 // 1770 //
1771 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1771 ClassElementImpl classA = ElementFactory.classElement2("A");
1772 String getterName = "g"; 1772 String getterName = "g";
1773 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null); 1773 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null);
1774 classA.accessors = <PropertyAccessorElement> [getterG]; 1774 classA.accessors = <PropertyAccessorElement> [getterG];
1775 InterfaceType typeA = classA.type; 1775 InterfaceType typeA = classA.type;
1776 expect(typeA.getGetter(getterName), same(getterG)); 1776 expect(typeA.getGetter(getterName), same(getterG));
1777 } 1777 }
1778 1778
1779 void test_getGetter_parameterized() { 1779 void test_getGetter_parameterized() {
1780 // 1780 //
1781 // class A<E> { E get g {} } 1781 // class A<E> { E get g {} }
1782 // 1782 //
1783 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 1783 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
1784 DartType typeE = classA.type.typeArguments[0]; 1784 DartType typeE = classA.type.typeArguments[0];
1785 String getterName = "g"; 1785 String getterName = "g";
1786 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, typeE); 1786 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, typeE);
1787 classA.accessors = <PropertyAccessorElement> [getterG]; 1787 classA.accessors = <PropertyAccessorElement> [getterG];
1788 (getterG.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ; 1788 (getterG.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ;
1789 // 1789 //
1790 // A<I> 1790 // A<I>
1791 // 1791 //
1792 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 1792 InterfaceType typeI = ElementFactory.classElement2("I").type;
1793 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 1793 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
1794 typeAI.typeArguments = <DartType> [typeI]; 1794 typeAI.typeArguments = <DartType> [typeI];
1795 PropertyAccessorElement getter = typeAI.getGetter(getterName); 1795 PropertyAccessorElement getter = typeAI.getGetter(getterName);
1796 expect(getter, isNotNull); 1796 expect(getter, isNotNull);
1797 FunctionType getterType = getter.type; 1797 FunctionType getterType = getter.type;
1798 expect(getterType.returnType, same(typeI)); 1798 expect(getterType.returnType, same(typeI));
1799 } 1799 }
1800 1800
1801 void test_getGetter_unimplemented() { 1801 void test_getGetter_unimplemented() {
1802 // 1802 //
1803 // class A {} 1803 // class A {}
1804 // 1804 //
1805 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1805 ClassElementImpl classA = ElementFactory.classElement2("A");
1806 InterfaceType typeA = classA.type; 1806 InterfaceType typeA = classA.type;
1807 expect(typeA.getGetter("g"), isNull); 1807 expect(typeA.getGetter("g"), isNull);
1808 } 1808 }
1809 1809
1810 void test_getInterfaces_nonParameterized() { 1810 void test_getInterfaces_nonParameterized() {
1811 // 1811 //
1812 // class C implements A, B 1812 // class C implements A, B
1813 // 1813 //
1814 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1814 ClassElementImpl classA = ElementFactory.classElement2("A");
1815 InterfaceType typeA = classA.type; 1815 InterfaceType typeA = classA.type;
1816 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1816 ClassElementImpl classB = ElementFactory.classElement2("B");
1817 InterfaceType typeB = classB.type; 1817 InterfaceType typeB = classB.type;
1818 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1818 ClassElementImpl classC = ElementFactory.classElement2("C");
1819 classC.interfaces = <InterfaceType> [typeA, typeB]; 1819 classC.interfaces = <InterfaceType> [typeA, typeB];
1820 List<InterfaceType> interfaces = classC.type.interfaces; 1820 List<InterfaceType> interfaces = classC.type.interfaces;
1821 expect(interfaces, hasLength(2)); 1821 expect(interfaces, hasLength(2));
1822 if (identical(interfaces[0], typeA)) { 1822 if (identical(interfaces[0], typeA)) {
1823 expect(interfaces[1], same(typeB)); 1823 expect(interfaces[1], same(typeB));
1824 } else { 1824 } else {
1825 expect(interfaces[0], same(typeB)); 1825 expect(interfaces[0], same(typeB));
1826 expect(interfaces[1], same(typeA)); 1826 expect(interfaces[1], same(typeA));
1827 } 1827 }
1828 } 1828 }
1829 1829
1830 void test_getInterfaces_parameterized() { 1830 void test_getInterfaces_parameterized() {
1831 // 1831 //
1832 // class A<E> 1832 // class A<E>
1833 // class B<F> implements A<F> 1833 // class B<F> implements A<F>
1834 // 1834 //
1835 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 1835 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
1836 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); 1836 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
1837 InterfaceType typeB = classB.type; 1837 InterfaceType typeB = classB.type;
1838 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); 1838 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
1839 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; 1839 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]];
1840 classB.interfaces = <InterfaceType> [typeAF]; 1840 classB.interfaces = <InterfaceType> [typeAF];
1841 // 1841 //
1842 // B<I> 1842 // B<I>
1843 // 1843 //
1844 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 1844 InterfaceType typeI = ElementFactory.classElement2("I").type;
1845 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); 1845 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
1846 typeBI.typeArguments = <DartType> [typeI]; 1846 typeBI.typeArguments = <DartType> [typeI];
1847 List<InterfaceType> interfaces = typeBI.interfaces; 1847 List<InterfaceType> interfaces = typeBI.interfaces;
1848 expect(interfaces, hasLength(1)); 1848 expect(interfaces, hasLength(1));
1849 InterfaceType result = interfaces[0]; 1849 InterfaceType result = interfaces[0];
1850 expect(result.element, same(classA)); 1850 expect(result.element, same(classA));
1851 expect(result.typeArguments[0], same(typeI)); 1851 expect(result.typeArguments[0], same(typeI));
1852 } 1852 }
1853 1853
1854 void test_getLeastUpperBound_directInterfaceCase() { 1854 void test_getLeastUpperBound_directInterfaceCase() {
1855 // 1855 //
1856 // class A 1856 // class A
1857 // class B implements A 1857 // class B implements A
1858 // class C implements B 1858 // class C implements B
1859 // 1859 //
1860 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1860 ClassElementImpl classA = ElementFactory.classElement2("A");
1861 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1861 ClassElementImpl classB = ElementFactory.classElement2("B");
1862 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1862 ClassElementImpl classC = ElementFactory.classElement2("C");
1863 InterfaceType typeA = classA.type; 1863 InterfaceType typeA = classA.type;
1864 InterfaceType typeB = classB.type; 1864 InterfaceType typeB = classB.type;
1865 InterfaceType typeC = classC.type; 1865 InterfaceType typeC = classC.type;
1866 classB.interfaces = <InterfaceType> [typeA]; 1866 classB.interfaces = <InterfaceType> [typeA];
1867 classC.interfaces = <InterfaceType> [typeB]; 1867 classC.interfaces = <InterfaceType> [typeB];
1868 expect(typeB.getLeastUpperBound(typeC), typeB); 1868 expect(typeB.getLeastUpperBound(typeC), typeB);
1869 expect(typeC.getLeastUpperBound(typeB), typeB); 1869 expect(typeC.getLeastUpperBound(typeB), typeB);
1870 } 1870 }
1871 1871
1872 void test_getLeastUpperBound_directSubclassCase() { 1872 void test_getLeastUpperBound_directSubclassCase() {
1873 // 1873 //
1874 // class A 1874 // class A
1875 // class B extends A 1875 // class B extends A
1876 // class C extends B 1876 // class C extends B
1877 // 1877 //
1878 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1878 ClassElementImpl classA = ElementFactory.classElement2("A");
1879 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1879 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
1880 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); 1880 ClassElementImpl classC = ElementFactory.classElement("C", classB.type);
1881 InterfaceType typeB = classB.type; 1881 InterfaceType typeB = classB.type;
1882 InterfaceType typeC = classC.type; 1882 InterfaceType typeC = classC.type;
1883 expect(typeB.getLeastUpperBound(typeC), typeB); 1883 expect(typeB.getLeastUpperBound(typeC), typeB);
1884 expect(typeC.getLeastUpperBound(typeB), typeB); 1884 expect(typeC.getLeastUpperBound(typeB), typeB);
1885 } 1885 }
1886 1886
1887 void test_getLeastUpperBound_functionType() { 1887 void test_getLeastUpperBound_functionType() {
1888 DartType interfaceType = ElementFactory.classElement2("A", []).type; 1888 DartType interfaceType = ElementFactory.classElement2("A").type;
1889 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.forNode(AstFactory.identifier3("f"))); 1889 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.forNode(AstFactory.identifier3("f")));
1890 expect(interfaceType.getLeastUpperBound(functionType), isNull); 1890 expect(interfaceType.getLeastUpperBound(functionType), isNull);
1891 } 1891 }
1892 1892
1893 void test_getLeastUpperBound_mixinCase() { 1893 void test_getLeastUpperBound_mixinCase() {
1894 // 1894 //
1895 // class A 1895 // class A
1896 // class B extends A 1896 // class B extends A
1897 // class C extends A 1897 // class C extends A
1898 // class D extends B with M, N, O, P 1898 // class D extends B with M, N, O, P
1899 // 1899 //
1900 ClassElement classA = ElementFactory.classElement2("A", []); 1900 ClassElement classA = ElementFactory.classElement2("A");
1901 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 1901 ClassElement classB = ElementFactory.classElement("B", classA.type);
1902 ClassElement classC = ElementFactory.classElement("C", classA.type, []); 1902 ClassElement classC = ElementFactory.classElement("C", classA.type);
1903 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); 1903 ClassElementImpl classD = ElementFactory.classElement("D", classB.type);
1904 InterfaceType typeA = classA.type; 1904 InterfaceType typeA = classA.type;
1905 InterfaceType typeC = classC.type; 1905 InterfaceType typeC = classC.type;
1906 InterfaceType typeD = classD.type; 1906 InterfaceType typeD = classD.type;
1907 classD.mixins = <InterfaceType> [ 1907 classD.mixins = <InterfaceType> [
1908 ElementFactory.classElement2("M", []).type, 1908 ElementFactory.classElement2("M").type,
1909 ElementFactory.classElement2("N", []).type, 1909 ElementFactory.classElement2("N").type,
1910 ElementFactory.classElement2("O", []).type, 1910 ElementFactory.classElement2("O").type,
1911 ElementFactory.classElement2("P", []).type]; 1911 ElementFactory.classElement2("P").type];
1912 expect(typeD.getLeastUpperBound(typeC), typeA); 1912 expect(typeD.getLeastUpperBound(typeC), typeA);
1913 expect(typeC.getLeastUpperBound(typeD), typeA); 1913 expect(typeC.getLeastUpperBound(typeD), typeA);
1914 } 1914 }
1915 1915
1916 void test_getLeastUpperBound_null() { 1916 void test_getLeastUpperBound_null() {
1917 DartType interfaceType = ElementFactory.classElement2("A", []).type; 1917 DartType interfaceType = ElementFactory.classElement2("A").type;
1918 expect(interfaceType.getLeastUpperBound(null), isNull); 1918 expect(interfaceType.getLeastUpperBound(null), isNull);
1919 } 1919 }
1920 1920
1921 void test_getLeastUpperBound_object() { 1921 void test_getLeastUpperBound_object() {
1922 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1922 ClassElementImpl classA = ElementFactory.classElement2("A");
1923 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1923 ClassElementImpl classB = ElementFactory.classElement2("B");
1924 InterfaceType typeA = classA.type; 1924 InterfaceType typeA = classA.type;
1925 InterfaceType typeB = classB.type; 1925 InterfaceType typeB = classB.type;
1926 DartType typeObject = typeA.element.supertype; 1926 DartType typeObject = typeA.element.supertype;
1927 // assert that object does not have a super type 1927 // assert that object does not have a super type
1928 expect((typeObject.element as ClassElement).supertype, isNull); 1928 expect((typeObject.element as ClassElement).supertype, isNull);
1929 // assert that both A and B have the same super type of Object 1929 // assert that both A and B have the same super type of Object
1930 expect(typeB.element.supertype, typeObject); 1930 expect(typeB.element.supertype, typeObject);
1931 // finally, assert that the only least upper bound of A and B is Object 1931 // finally, assert that the only least upper bound of A and B is Object
1932 expect(typeA.getLeastUpperBound(typeB), typeObject); 1932 expect(typeA.getLeastUpperBound(typeB), typeObject);
1933 } 1933 }
1934 1934
1935 void test_getLeastUpperBound_self() { 1935 void test_getLeastUpperBound_self() {
1936 ClassElement classA = ElementFactory.classElement2("A", []); 1936 ClassElement classA = ElementFactory.classElement2("A");
1937 InterfaceType typeA = classA.type; 1937 InterfaceType typeA = classA.type;
1938 expect(typeA.getLeastUpperBound(typeA), typeA); 1938 expect(typeA.getLeastUpperBound(typeA), typeA);
1939 } 1939 }
1940 1940
1941 void test_getLeastUpperBound_sharedSuperclass1() { 1941 void test_getLeastUpperBound_sharedSuperclass1() {
1942 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1942 ClassElementImpl classA = ElementFactory.classElement2("A");
1943 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1943 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
1944 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); 1944 ClassElementImpl classC = ElementFactory.classElement("C", classA.type);
1945 InterfaceType typeA = classA.type; 1945 InterfaceType typeA = classA.type;
1946 InterfaceType typeB = classB.type; 1946 InterfaceType typeB = classB.type;
1947 InterfaceType typeC = classC.type; 1947 InterfaceType typeC = classC.type;
1948 expect(typeB.getLeastUpperBound(typeC), typeA); 1948 expect(typeB.getLeastUpperBound(typeC), typeA);
1949 expect(typeC.getLeastUpperBound(typeB), typeA); 1949 expect(typeC.getLeastUpperBound(typeB), typeA);
1950 } 1950 }
1951 1951
1952 void test_getLeastUpperBound_sharedSuperclass2() { 1952 void test_getLeastUpperBound_sharedSuperclass2() {
1953 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1953 ClassElementImpl classA = ElementFactory.classElement2("A");
1954 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1954 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
1955 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); 1955 ClassElementImpl classC = ElementFactory.classElement("C", classA.type);
1956 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []); 1956 ClassElementImpl classD = ElementFactory.classElement("D", classC.type);
1957 InterfaceType typeA = classA.type; 1957 InterfaceType typeA = classA.type;
1958 InterfaceType typeB = classB.type; 1958 InterfaceType typeB = classB.type;
1959 InterfaceType typeD = classD.type; 1959 InterfaceType typeD = classD.type;
1960 expect(typeB.getLeastUpperBound(typeD), typeA); 1960 expect(typeB.getLeastUpperBound(typeD), typeA);
1961 expect(typeD.getLeastUpperBound(typeB), typeA); 1961 expect(typeD.getLeastUpperBound(typeB), typeA);
1962 } 1962 }
1963 1963
1964 void test_getLeastUpperBound_sharedSuperclass3() { 1964 void test_getLeastUpperBound_sharedSuperclass3() {
1965 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1965 ClassElementImpl classA = ElementFactory.classElement2("A");
1966 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1966 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
1967 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); 1967 ClassElementImpl classC = ElementFactory.classElement("C", classB.type);
1968 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); 1968 ClassElementImpl classD = ElementFactory.classElement("D", classB.type);
1969 InterfaceType typeB = classB.type; 1969 InterfaceType typeB = classB.type;
1970 InterfaceType typeC = classC.type; 1970 InterfaceType typeC = classC.type;
1971 InterfaceType typeD = classD.type; 1971 InterfaceType typeD = classD.type;
1972 expect(typeC.getLeastUpperBound(typeD), typeB); 1972 expect(typeC.getLeastUpperBound(typeD), typeB);
1973 expect(typeD.getLeastUpperBound(typeC), typeB); 1973 expect(typeD.getLeastUpperBound(typeC), typeB);
1974 } 1974 }
1975 1975
1976 void test_getLeastUpperBound_sharedSuperclass4() { 1976 void test_getLeastUpperBound_sharedSuperclass4() {
1977 ClassElement classA = ElementFactory.classElement2("A", []); 1977 ClassElement classA = ElementFactory.classElement2("A");
1978 ClassElement classA2 = ElementFactory.classElement2("A2", []); 1978 ClassElement classA2 = ElementFactory.classElement2("A2");
1979 ClassElement classA3 = ElementFactory.classElement2("A3", []); 1979 ClassElement classA3 = ElementFactory.classElement2("A3");
1980 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1980 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
1981 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); 1981 ClassElementImpl classC = ElementFactory.classElement("C", classA.type);
1982 InterfaceType typeA = classA.type; 1982 InterfaceType typeA = classA.type;
1983 InterfaceType typeA2 = classA2.type; 1983 InterfaceType typeA2 = classA2.type;
1984 InterfaceType typeA3 = classA3.type; 1984 InterfaceType typeA3 = classA3.type;
1985 InterfaceType typeB = classB.type; 1985 InterfaceType typeB = classB.type;
1986 InterfaceType typeC = classC.type; 1986 InterfaceType typeC = classC.type;
1987 classB.interfaces = <InterfaceType> [typeA2]; 1987 classB.interfaces = <InterfaceType> [typeA2];
1988 classC.interfaces = <InterfaceType> [typeA3]; 1988 classC.interfaces = <InterfaceType> [typeA3];
1989 expect(typeB.getLeastUpperBound(typeC), typeA); 1989 expect(typeB.getLeastUpperBound(typeC), typeA);
1990 expect(typeC.getLeastUpperBound(typeB), typeA); 1990 expect(typeC.getLeastUpperBound(typeB), typeA);
1991 } 1991 }
1992 1992
1993 void test_getLeastUpperBound_sharedSuperinterface1() { 1993 void test_getLeastUpperBound_sharedSuperinterface1() {
1994 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1994 ClassElementImpl classA = ElementFactory.classElement2("A");
1995 ClassElementImpl classB = ElementFactory.classElement2("B", []); 1995 ClassElementImpl classB = ElementFactory.classElement2("B");
1996 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1996 ClassElementImpl classC = ElementFactory.classElement2("C");
1997 InterfaceType typeA = classA.type; 1997 InterfaceType typeA = classA.type;
1998 InterfaceType typeB = classB.type; 1998 InterfaceType typeB = classB.type;
1999 InterfaceType typeC = classC.type; 1999 InterfaceType typeC = classC.type;
2000 classB.interfaces = <InterfaceType> [typeA]; 2000 classB.interfaces = <InterfaceType> [typeA];
2001 classC.interfaces = <InterfaceType> [typeA]; 2001 classC.interfaces = <InterfaceType> [typeA];
2002 expect(typeB.getLeastUpperBound(typeC), typeA); 2002 expect(typeB.getLeastUpperBound(typeC), typeA);
2003 expect(typeC.getLeastUpperBound(typeB), typeA); 2003 expect(typeC.getLeastUpperBound(typeB), typeA);
2004 } 2004 }
2005 2005
2006 void test_getLeastUpperBound_sharedSuperinterface2() { 2006 void test_getLeastUpperBound_sharedSuperinterface2() {
2007 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2007 ClassElementImpl classA = ElementFactory.classElement2("A");
2008 ClassElementImpl classB = ElementFactory.classElement2("B", []); 2008 ClassElementImpl classB = ElementFactory.classElement2("B");
2009 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2009 ClassElementImpl classC = ElementFactory.classElement2("C");
2010 ClassElementImpl classD = ElementFactory.classElement2("D", []); 2010 ClassElementImpl classD = ElementFactory.classElement2("D");
2011 InterfaceType typeA = classA.type; 2011 InterfaceType typeA = classA.type;
2012 InterfaceType typeB = classB.type; 2012 InterfaceType typeB = classB.type;
2013 InterfaceType typeC = classC.type; 2013 InterfaceType typeC = classC.type;
2014 InterfaceType typeD = classD.type; 2014 InterfaceType typeD = classD.type;
2015 classB.interfaces = <InterfaceType> [typeA]; 2015 classB.interfaces = <InterfaceType> [typeA];
2016 classC.interfaces = <InterfaceType> [typeA]; 2016 classC.interfaces = <InterfaceType> [typeA];
2017 classD.interfaces = <InterfaceType> [typeC]; 2017 classD.interfaces = <InterfaceType> [typeC];
2018 expect(typeB.getLeastUpperBound(typeD), typeA); 2018 expect(typeB.getLeastUpperBound(typeD), typeA);
2019 expect(typeD.getLeastUpperBound(typeB), typeA); 2019 expect(typeD.getLeastUpperBound(typeB), typeA);
2020 } 2020 }
2021 2021
2022 void test_getLeastUpperBound_sharedSuperinterface3() { 2022 void test_getLeastUpperBound_sharedSuperinterface3() {
2023 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2023 ClassElementImpl classA = ElementFactory.classElement2("A");
2024 ClassElementImpl classB = ElementFactory.classElement2("B", []); 2024 ClassElementImpl classB = ElementFactory.classElement2("B");
2025 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2025 ClassElementImpl classC = ElementFactory.classElement2("C");
2026 ClassElementImpl classD = ElementFactory.classElement2("D", []); 2026 ClassElementImpl classD = ElementFactory.classElement2("D");
2027 InterfaceType typeA = classA.type; 2027 InterfaceType typeA = classA.type;
2028 InterfaceType typeB = classB.type; 2028 InterfaceType typeB = classB.type;
2029 InterfaceType typeC = classC.type; 2029 InterfaceType typeC = classC.type;
2030 InterfaceType typeD = classD.type; 2030 InterfaceType typeD = classD.type;
2031 classB.interfaces = <InterfaceType> [typeA]; 2031 classB.interfaces = <InterfaceType> [typeA];
2032 classC.interfaces = <InterfaceType> [typeB]; 2032 classC.interfaces = <InterfaceType> [typeB];
2033 classD.interfaces = <InterfaceType> [typeB]; 2033 classD.interfaces = <InterfaceType> [typeB];
2034 expect(typeC.getLeastUpperBound(typeD), typeB); 2034 expect(typeC.getLeastUpperBound(typeD), typeB);
2035 expect(typeD.getLeastUpperBound(typeC), typeB); 2035 expect(typeD.getLeastUpperBound(typeC), typeB);
2036 } 2036 }
2037 2037
2038 void test_getLeastUpperBound_sharedSuperinterface4() { 2038 void test_getLeastUpperBound_sharedSuperinterface4() {
2039 ClassElement classA = ElementFactory.classElement2("A", []); 2039 ClassElement classA = ElementFactory.classElement2("A");
2040 ClassElement classA2 = ElementFactory.classElement2("A2", []); 2040 ClassElement classA2 = ElementFactory.classElement2("A2");
2041 ClassElement classA3 = ElementFactory.classElement2("A3", []); 2041 ClassElement classA3 = ElementFactory.classElement2("A3");
2042 ClassElementImpl classB = ElementFactory.classElement2("B", []); 2042 ClassElementImpl classB = ElementFactory.classElement2("B");
2043 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2043 ClassElementImpl classC = ElementFactory.classElement2("C");
2044 InterfaceType typeA = classA.type; 2044 InterfaceType typeA = classA.type;
2045 InterfaceType typeA2 = classA2.type; 2045 InterfaceType typeA2 = classA2.type;
2046 InterfaceType typeA3 = classA3.type; 2046 InterfaceType typeA3 = classA3.type;
2047 InterfaceType typeB = classB.type; 2047 InterfaceType typeB = classB.type;
2048 InterfaceType typeC = classC.type; 2048 InterfaceType typeC = classC.type;
2049 classB.interfaces = <InterfaceType> [typeA, typeA2]; 2049 classB.interfaces = <InterfaceType> [typeA, typeA2];
2050 classC.interfaces = <InterfaceType> [typeA, typeA3]; 2050 classC.interfaces = <InterfaceType> [typeA, typeA3];
2051 expect(typeB.getLeastUpperBound(typeC), typeA); 2051 expect(typeB.getLeastUpperBound(typeC), typeA);
2052 expect(typeC.getLeastUpperBound(typeB), typeA); 2052 expect(typeC.getLeastUpperBound(typeB), typeA);
2053 } 2053 }
(...skipping 25 matching lines...) Expand all
2079 InterfaceType listType = _typeProvider.listType; 2079 InterfaceType listType = _typeProvider.listType;
2080 InterfaceType intType = _typeProvider.intType; 2080 InterfaceType intType = _typeProvider.intType;
2081 InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]); 2081 InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]);
2082 expect(listOfIntType.getLeastUpperBound(listOfIntType), listOfIntType); 2082 expect(listOfIntType.getLeastUpperBound(listOfIntType), listOfIntType);
2083 } 2083 }
2084 2084
2085 void test_getMethod_implemented() { 2085 void test_getMethod_implemented() {
2086 // 2086 //
2087 // class A { m() {} } 2087 // class A { m() {} }
2088 // 2088 //
2089 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2089 ClassElementImpl classA = ElementFactory.classElement2("A");
2090 String methodName = "m"; 2090 String methodName = "m";
2091 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [ ]); 2091 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null);
2092 classA.methods = <MethodElement> [methodM]; 2092 classA.methods = <MethodElement> [methodM];
2093 InterfaceType typeA = classA.type; 2093 InterfaceType typeA = classA.type;
2094 expect(typeA.getMethod(methodName), same(methodM)); 2094 expect(typeA.getMethod(methodName), same(methodM));
2095 } 2095 }
2096 2096
2097 void test_getMethod_parameterized() { 2097 void test_getMethod_parameterized() {
2098 // 2098 //
2099 // class A<E> { E m(E p) {} } 2099 // class A<E> { E m(E p) {} }
2100 // 2100 //
2101 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 2101 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
2102 DartType typeE = classA.type.typeArguments[0]; 2102 DartType typeE = classA.type.typeArguments[0];
2103 String methodName = "m"; 2103 String methodName = "m";
2104 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]); 2104 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]);
2105 classA.methods = <MethodElement> [methodM]; 2105 classA.methods = <MethodElement> [methodM];
2106 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ; 2106 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ;
2107 // 2107 //
2108 // A<I> 2108 // A<I>
2109 // 2109 //
2110 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 2110 InterfaceType typeI = ElementFactory.classElement2("I").type;
2111 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 2111 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
2112 typeAI.typeArguments = <DartType> [typeI]; 2112 typeAI.typeArguments = <DartType> [typeI];
2113 MethodElement method = typeAI.getMethod(methodName); 2113 MethodElement method = typeAI.getMethod(methodName);
2114 expect(method, isNotNull); 2114 expect(method, isNotNull);
2115 FunctionType methodType = method.type; 2115 FunctionType methodType = method.type;
2116 expect(methodType.returnType, same(typeI)); 2116 expect(methodType.returnType, same(typeI));
2117 List<DartType> parameterTypes = methodType.normalParameterTypes; 2117 List<DartType> parameterTypes = methodType.normalParameterTypes;
2118 expect(parameterTypes, hasLength(1)); 2118 expect(parameterTypes, hasLength(1));
2119 expect(parameterTypes[0], same(typeI)); 2119 expect(parameterTypes[0], same(typeI));
2120 } 2120 }
2121 2121
2122 void test_getMethod_unimplemented() { 2122 void test_getMethod_unimplemented() {
2123 // 2123 //
2124 // class A {} 2124 // class A {}
2125 // 2125 //
2126 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2126 ClassElementImpl classA = ElementFactory.classElement2("A");
2127 InterfaceType typeA = classA.type; 2127 InterfaceType typeA = classA.type;
2128 expect(typeA.getMethod("m"), isNull); 2128 expect(typeA.getMethod("m"), isNull);
2129 } 2129 }
2130 2130
2131 void test_getMethods() { 2131 void test_getMethods() {
2132 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); 2132 ClassElementImpl typeElement = ElementFactory.classElement2("A");
2133 MethodElementImpl methodOne = ElementFactory.methodElement("one", null, []); 2133 MethodElementImpl methodOne = ElementFactory.methodElement("one", null);
2134 MethodElementImpl methodTwo = ElementFactory.methodElement("two", null, []); 2134 MethodElementImpl methodTwo = ElementFactory.methodElement("two", null);
2135 typeElement.methods = <MethodElement> [methodOne, methodTwo]; 2135 typeElement.methods = <MethodElement> [methodOne, methodTwo];
2136 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); 2136 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
2137 expect(type.methods.length, 2); 2137 expect(type.methods.length, 2);
2138 } 2138 }
2139 2139
2140 void test_getMethods_empty() { 2140 void test_getMethods_empty() {
2141 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); 2141 ClassElementImpl typeElement = ElementFactory.classElement2("A");
2142 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); 2142 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
2143 expect(type.methods.length, 0); 2143 expect(type.methods.length, 0);
2144 } 2144 }
2145 2145
2146 void test_getMixins_nonParameterized() { 2146 void test_getMixins_nonParameterized() {
2147 // 2147 //
2148 // class C extends Object with A, B 2148 // class C extends Object with A, B
2149 // 2149 //
2150 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2150 ClassElementImpl classA = ElementFactory.classElement2("A");
2151 InterfaceType typeA = classA.type; 2151 InterfaceType typeA = classA.type;
2152 ClassElementImpl classB = ElementFactory.classElement2("B", []); 2152 ClassElementImpl classB = ElementFactory.classElement2("B");
2153 InterfaceType typeB = classB.type; 2153 InterfaceType typeB = classB.type;
2154 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2154 ClassElementImpl classC = ElementFactory.classElement2("C");
2155 classC.mixins = <InterfaceType> [typeA, typeB]; 2155 classC.mixins = <InterfaceType> [typeA, typeB];
2156 List<InterfaceType> interfaces = classC.type.mixins; 2156 List<InterfaceType> interfaces = classC.type.mixins;
2157 expect(interfaces, hasLength(2)); 2157 expect(interfaces, hasLength(2));
2158 if (identical(interfaces[0], typeA)) { 2158 if (identical(interfaces[0], typeA)) {
2159 expect(interfaces[1], same(typeB)); 2159 expect(interfaces[1], same(typeB));
2160 } else { 2160 } else {
2161 expect(interfaces[0], same(typeB)); 2161 expect(interfaces[0], same(typeB));
2162 expect(interfaces[1], same(typeA)); 2162 expect(interfaces[1], same(typeA));
2163 } 2163 }
2164 } 2164 }
2165 2165
2166 void test_getMixins_parameterized() { 2166 void test_getMixins_parameterized() {
2167 // 2167 //
2168 // class A<E> 2168 // class A<E>
2169 // class B<F> extends Object with A<F> 2169 // class B<F> extends Object with A<F>
2170 // 2170 //
2171 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 2171 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
2172 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); 2172 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
2173 InterfaceType typeB = classB.type; 2173 InterfaceType typeB = classB.type;
2174 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); 2174 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
2175 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; 2175 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]];
2176 classB.mixins = <InterfaceType> [typeAF]; 2176 classB.mixins = <InterfaceType> [typeAF];
2177 // 2177 //
2178 // B<I> 2178 // B<I>
2179 // 2179 //
2180 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 2180 InterfaceType typeI = ElementFactory.classElement2("I").type;
2181 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); 2181 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
2182 typeBI.typeArguments = <DartType> [typeI]; 2182 typeBI.typeArguments = <DartType> [typeI];
2183 List<InterfaceType> interfaces = typeBI.mixins; 2183 List<InterfaceType> interfaces = typeBI.mixins;
2184 expect(interfaces, hasLength(1)); 2184 expect(interfaces, hasLength(1));
2185 InterfaceType result = interfaces[0]; 2185 InterfaceType result = interfaces[0];
2186 expect(result.element, same(classA)); 2186 expect(result.element, same(classA));
2187 expect(result.typeArguments[0], same(typeI)); 2187 expect(result.typeArguments[0], same(typeI));
2188 } 2188 }
2189 2189
2190 void test_getSetter_implemented() { 2190 void test_getSetter_implemented() {
2191 // 2191 //
2192 // class A { s() {} } 2192 // class A { s() {} }
2193 // 2193 //
2194 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2194 ClassElementImpl classA = ElementFactory.classElement2("A");
2195 String setterName = "s"; 2195 String setterName = "s";
2196 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null); 2196 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null);
2197 classA.accessors = <PropertyAccessorElement> [setterS]; 2197 classA.accessors = <PropertyAccessorElement> [setterS];
2198 InterfaceType typeA = classA.type; 2198 InterfaceType typeA = classA.type;
2199 expect(typeA.getSetter(setterName), same(setterS)); 2199 expect(typeA.getSetter(setterName), same(setterS));
2200 } 2200 }
2201 2201
2202 void test_getSetter_parameterized() { 2202 void test_getSetter_parameterized() {
2203 // 2203 //
2204 // class A<E> { set s(E p) {} } 2204 // class A<E> { set s(E p) {} }
2205 // 2205 //
2206 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 2206 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
2207 DartType typeE = classA.type.typeArguments[0]; 2207 DartType typeE = classA.type.typeArguments[0];
2208 String setterName = "s"; 2208 String setterName = "s";
2209 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, typeE); 2209 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, typeE);
2210 classA.accessors = <PropertyAccessorElement> [setterS]; 2210 classA.accessors = <PropertyAccessorElement> [setterS];
2211 (setterS.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ; 2211 (setterS.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ;
2212 // 2212 //
2213 // A<I> 2213 // A<I>
2214 // 2214 //
2215 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 2215 InterfaceType typeI = ElementFactory.classElement2("I").type;
2216 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 2216 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
2217 typeAI.typeArguments = <DartType> [typeI]; 2217 typeAI.typeArguments = <DartType> [typeI];
2218 PropertyAccessorElement setter = typeAI.getSetter(setterName); 2218 PropertyAccessorElement setter = typeAI.getSetter(setterName);
2219 expect(setter, isNotNull); 2219 expect(setter, isNotNull);
2220 FunctionType setterType = setter.type; 2220 FunctionType setterType = setter.type;
2221 List<DartType> parameterTypes = setterType.normalParameterTypes; 2221 List<DartType> parameterTypes = setterType.normalParameterTypes;
2222 expect(parameterTypes, hasLength(1)); 2222 expect(parameterTypes, hasLength(1));
2223 expect(parameterTypes[0], same(typeI)); 2223 expect(parameterTypes[0], same(typeI));
2224 } 2224 }
2225 2225
2226 void test_getSetter_unimplemented() { 2226 void test_getSetter_unimplemented() {
2227 // 2227 //
2228 // class A {} 2228 // class A {}
2229 // 2229 //
2230 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2230 ClassElementImpl classA = ElementFactory.classElement2("A");
2231 InterfaceType typeA = classA.type; 2231 InterfaceType typeA = classA.type;
2232 expect(typeA.getSetter("s"), isNull); 2232 expect(typeA.getSetter("s"), isNull);
2233 } 2233 }
2234 2234
2235 void test_getSuperclass_nonParameterized() { 2235 void test_getSuperclass_nonParameterized() {
2236 // 2236 //
2237 // class B extends A 2237 // class B extends A
2238 // 2238 //
2239 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2239 ClassElementImpl classA = ElementFactory.classElement2("A");
2240 InterfaceType typeA = classA.type; 2240 InterfaceType typeA = classA.type;
2241 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); 2241 ClassElementImpl classB = ElementFactory.classElement("B", typeA);
2242 InterfaceType typeB = classB.type; 2242 InterfaceType typeB = classB.type;
2243 expect(typeB.superclass, same(typeA)); 2243 expect(typeB.superclass, same(typeA));
2244 } 2244 }
2245 2245
2246 void test_getSuperclass_parameterized() { 2246 void test_getSuperclass_parameterized() {
2247 // 2247 //
2248 // class A<E> 2248 // class A<E>
2249 // class B<F> extends A<F> 2249 // class B<F> extends A<F>
2250 // 2250 //
2251 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 2251 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
2252 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); 2252 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
2253 InterfaceType typeB = classB.type; 2253 InterfaceType typeB = classB.type;
2254 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); 2254 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
2255 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; 2255 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]];
2256 classB.supertype = typeAF; 2256 classB.supertype = typeAF;
2257 // 2257 //
2258 // B<I> 2258 // B<I>
2259 // 2259 //
2260 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 2260 InterfaceType typeI = ElementFactory.classElement2("I").type;
2261 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); 2261 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
2262 typeBI.typeArguments = <DartType> [typeI]; 2262 typeBI.typeArguments = <DartType> [typeI];
2263 InterfaceType superclass = typeBI.superclass; 2263 InterfaceType superclass = typeBI.superclass;
2264 expect(superclass.element, same(classA)); 2264 expect(superclass.element, same(classA));
2265 expect(superclass.typeArguments[0], same(typeI)); 2265 expect(superclass.typeArguments[0], same(typeI));
2266 } 2266 }
2267 2267
2268 void test_getTypeArguments_empty() { 2268 void test_getTypeArguments_empty() {
2269 InterfaceType type = ElementFactory.classElement2("A", []).type; 2269 InterfaceType type = ElementFactory.classElement2("A").type;
2270 expect(type.typeArguments, hasLength(0)); 2270 expect(type.typeArguments, hasLength(0));
2271 } 2271 }
2272 2272
2273 void test_hashCode() { 2273 void test_hashCode() {
2274 ClassElement classA = ElementFactory.classElement2("A", []); 2274 ClassElement classA = ElementFactory.classElement2("A");
2275 InterfaceType typeA = classA.type; 2275 InterfaceType typeA = classA.type;
2276 expect(0 == typeA.hashCode, isFalse); 2276 expect(0 == typeA.hashCode, isFalse);
2277 } 2277 }
2278 2278
2279 void test_isAssignableTo_typeVariables() { 2279 void test_isAssignableTo_typeVariables() {
2280 // 2280 //
2281 // class A<E> {} 2281 // class A<E> {}
2282 // class B<F, G> { 2282 // class B<F, G> {
2283 // A<F> af; 2283 // A<F> af;
2284 // f (A<G> ag) { 2284 // f (A<G> ag) {
2285 // af = ag; 2285 // af = ag;
2286 // } 2286 // }
2287 // } 2287 // }
2288 // 2288 //
2289 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 2289 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
2290 ClassElement classB = ElementFactory.classElement2("B", ["F", "G"]); 2290 ClassElement classB = ElementFactory.classElement2("B", ["F", "G"]);
2291 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); 2291 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
2292 typeAF.typeArguments = <DartType> [classB.typeParameters[0].type]; 2292 typeAF.typeArguments = <DartType> [classB.typeParameters[0].type];
2293 InterfaceTypeImpl typeAG = new InterfaceTypeImpl.con1(classA); 2293 InterfaceTypeImpl typeAG = new InterfaceTypeImpl.con1(classA);
2294 typeAG.typeArguments = <DartType> [classB.typeParameters[1].type]; 2294 typeAG.typeArguments = <DartType> [classB.typeParameters[1].type];
2295 expect(typeAG.isAssignableTo(typeAF), isFalse); 2295 expect(typeAG.isAssignableTo(typeAF), isFalse);
2296 } 2296 }
2297 2297
2298 void test_isAssignableTo_void() { 2298 void test_isAssignableTo_void() {
2299 expect(VoidTypeImpl.instance.isAssignableTo(_typeProvider.intType), isFalse) ; 2299 expect(VoidTypeImpl.instance.isAssignableTo(_typeProvider.intType), isFalse) ;
2300 } 2300 }
2301 2301
2302 void test_isDirectSupertypeOf_extends() { 2302 void test_isDirectSupertypeOf_extends() {
2303 ClassElement classA = ElementFactory.classElement2("A", []); 2303 ClassElement classA = ElementFactory.classElement2("A");
2304 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2304 ClassElement classB = ElementFactory.classElement("B", classA.type);
2305 InterfaceType typeA = classA.type; 2305 InterfaceType typeA = classA.type;
2306 InterfaceType typeB = classB.type; 2306 InterfaceType typeB = classB.type;
2307 expect(typeA.isDirectSupertypeOf(typeB), isTrue); 2307 expect(typeA.isDirectSupertypeOf(typeB), isTrue);
2308 } 2308 }
2309 2309
2310 void test_isDirectSupertypeOf_false() { 2310 void test_isDirectSupertypeOf_false() {
2311 ClassElement classA = ElementFactory.classElement2("A", []); 2311 ClassElement classA = ElementFactory.classElement2("A");
2312 ClassElement classB = ElementFactory.classElement2("B", []); 2312 ClassElement classB = ElementFactory.classElement2("B");
2313 ClassElement classC = ElementFactory.classElement("C", classB.type, []); 2313 ClassElement classC = ElementFactory.classElement("C", classB.type);
2314 InterfaceType typeA = classA.type; 2314 InterfaceType typeA = classA.type;
2315 InterfaceType typeC = classC.type; 2315 InterfaceType typeC = classC.type;
2316 expect(typeA.isDirectSupertypeOf(typeC), isFalse); 2316 expect(typeA.isDirectSupertypeOf(typeC), isFalse);
2317 } 2317 }
2318 2318
2319 void test_isDirectSupertypeOf_implements() { 2319 void test_isDirectSupertypeOf_implements() {
2320 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2320 ClassElementImpl classA = ElementFactory.classElement2("A");
2321 ClassElementImpl classB = ElementFactory.classElement2("B", []); 2321 ClassElementImpl classB = ElementFactory.classElement2("B");
2322 InterfaceType typeA = classA.type; 2322 InterfaceType typeA = classA.type;
2323 InterfaceType typeB = classB.type; 2323 InterfaceType typeB = classB.type;
2324 classB.interfaces = <InterfaceType> [typeA]; 2324 classB.interfaces = <InterfaceType> [typeA];
2325 expect(typeA.isDirectSupertypeOf(typeB), isTrue); 2325 expect(typeA.isDirectSupertypeOf(typeB), isTrue);
2326 } 2326 }
2327 2327
2328 void test_isDirectSupertypeOf_with() { 2328 void test_isDirectSupertypeOf_with() {
2329 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2329 ClassElementImpl classA = ElementFactory.classElement2("A");
2330 ClassElementImpl classB = ElementFactory.classElement2("B", []); 2330 ClassElementImpl classB = ElementFactory.classElement2("B");
2331 InterfaceType typeA = classA.type; 2331 InterfaceType typeA = classA.type;
2332 InterfaceType typeB = classB.type; 2332 InterfaceType typeB = classB.type;
2333 classB.mixins = <InterfaceType> [typeA]; 2333 classB.mixins = <InterfaceType> [typeA];
2334 expect(typeA.isDirectSupertypeOf(typeB), isTrue); 2334 expect(typeA.isDirectSupertypeOf(typeB), isTrue);
2335 } 2335 }
2336 2336
2337 void test_isMoreSpecificThan_bottom() { 2337 void test_isMoreSpecificThan_bottom() {
2338 DartType type = ElementFactory.classElement2("A", []).type; 2338 DartType type = ElementFactory.classElement2("A").type;
2339 expect(BottomTypeImpl.instance.isMoreSpecificThan(type), isTrue); 2339 expect(BottomTypeImpl.instance.isMoreSpecificThan(type), isTrue);
2340 } 2340 }
2341 2341
2342 void test_isMoreSpecificThan_covariance() { 2342 void test_isMoreSpecificThan_covariance() {
2343 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 2343 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
2344 ClassElement classI = ElementFactory.classElement2("I", []); 2344 ClassElement classI = ElementFactory.classElement2("I");
2345 ClassElement classJ = ElementFactory.classElement("J", classI.type, []); 2345 ClassElement classJ = ElementFactory.classElement("J", classI.type);
2346 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 2346 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
2347 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA); 2347 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA);
2348 typeAI.typeArguments = <DartType> [classI.type]; 2348 typeAI.typeArguments = <DartType> [classI.type];
2349 typeAJ.typeArguments = <DartType> [classJ.type]; 2349 typeAJ.typeArguments = <DartType> [classJ.type];
2350 expect(typeAJ.isMoreSpecificThan(typeAI), isTrue); 2350 expect(typeAJ.isMoreSpecificThan(typeAI), isTrue);
2351 expect(typeAI.isMoreSpecificThan(typeAJ), isFalse); 2351 expect(typeAI.isMoreSpecificThan(typeAJ), isFalse);
2352 } 2352 }
2353 2353
2354 void test_isMoreSpecificThan_directSupertype() { 2354 void test_isMoreSpecificThan_directSupertype() {
2355 ClassElement classA = ElementFactory.classElement2("A", []); 2355 ClassElement classA = ElementFactory.classElement2("A");
2356 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2356 ClassElement classB = ElementFactory.classElement("B", classA.type);
2357 InterfaceType typeA = classA.type; 2357 InterfaceType typeA = classA.type;
2358 InterfaceType typeB = classB.type; 2358 InterfaceType typeB = classB.type;
2359 expect(typeB.isMoreSpecificThan(typeA), isTrue); 2359 expect(typeB.isMoreSpecificThan(typeA), isTrue);
2360 // the opposite test tests a different branch in isMoreSpecificThan() 2360 // the opposite test tests a different branch in isMoreSpecificThan()
2361 expect(typeA.isMoreSpecificThan(typeB), isFalse); 2361 expect(typeA.isMoreSpecificThan(typeB), isFalse);
2362 } 2362 }
2363 2363
2364 void test_isMoreSpecificThan_dynamic() { 2364 void test_isMoreSpecificThan_dynamic() {
2365 InterfaceType type = ElementFactory.classElement2("A", []).type; 2365 InterfaceType type = ElementFactory.classElement2("A").type;
2366 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); 2366 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue);
2367 } 2367 }
2368 2368
2369 void test_isMoreSpecificThan_generic() { 2369 void test_isMoreSpecificThan_generic() {
2370 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 2370 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
2371 ClassElement classB = ElementFactory.classElement2("B", []); 2371 ClassElement classB = ElementFactory.classElement2("B");
2372 DartType dynamicType = DynamicTypeImpl.instance; 2372 DartType dynamicType = DynamicTypeImpl.instance;
2373 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy pe]); 2373 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy pe]);
2374 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]); 2374 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]);
2375 expect(typeAOfDynamic.isMoreSpecificThan(typeAOfB), isFalse); 2375 expect(typeAOfDynamic.isMoreSpecificThan(typeAOfB), isFalse);
2376 expect(typeAOfB.isMoreSpecificThan(typeAOfDynamic), isTrue); 2376 expect(typeAOfB.isMoreSpecificThan(typeAOfDynamic), isTrue);
2377 } 2377 }
2378 2378
2379 void test_isMoreSpecificThan_self() { 2379 void test_isMoreSpecificThan_self() {
2380 InterfaceType type = ElementFactory.classElement2("A", []).type; 2380 InterfaceType type = ElementFactory.classElement2("A").type;
2381 expect(type.isMoreSpecificThan(type), isTrue); 2381 expect(type.isMoreSpecificThan(type), isTrue);
2382 } 2382 }
2383 2383
2384 void test_isMoreSpecificThan_transitive_interface() { 2384 void test_isMoreSpecificThan_transitive_interface() {
2385 // 2385 //
2386 // class A {} 2386 // class A {}
2387 // class B extends A {} 2387 // class B extends A {}
2388 // class C implements B {} 2388 // class C implements B {}
2389 // 2389 //
2390 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2390 ClassElementImpl classA = ElementFactory.classElement2("A");
2391 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 2391 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
2392 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2392 ClassElementImpl classC = ElementFactory.classElement2("C");
2393 classC.interfaces = <InterfaceType> [classB.type]; 2393 classC.interfaces = <InterfaceType> [classB.type];
2394 InterfaceType typeA = classA.type; 2394 InterfaceType typeA = classA.type;
2395 InterfaceType typeC = classC.type; 2395 InterfaceType typeC = classC.type;
2396 expect(typeC.isMoreSpecificThan(typeA), isTrue); 2396 expect(typeC.isMoreSpecificThan(typeA), isTrue);
2397 } 2397 }
2398 2398
2399 void test_isMoreSpecificThan_transitive_mixin() { 2399 void test_isMoreSpecificThan_transitive_mixin() {
2400 // 2400 //
2401 // class A {} 2401 // class A {}
2402 // class B extends A {} 2402 // class B extends A {}
2403 // class C with B {} 2403 // class C with B {}
2404 // 2404 //
2405 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2405 ClassElementImpl classA = ElementFactory.classElement2("A");
2406 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 2406 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
2407 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2407 ClassElementImpl classC = ElementFactory.classElement2("C");
2408 classC.mixins = <InterfaceType> [classB.type]; 2408 classC.mixins = <InterfaceType> [classB.type];
2409 InterfaceType typeA = classA.type; 2409 InterfaceType typeA = classA.type;
2410 InterfaceType typeC = classC.type; 2410 InterfaceType typeC = classC.type;
2411 expect(typeC.isMoreSpecificThan(typeA), isTrue); 2411 expect(typeC.isMoreSpecificThan(typeA), isTrue);
2412 } 2412 }
2413 2413
2414 void test_isMoreSpecificThan_transitive_recursive() { 2414 void test_isMoreSpecificThan_transitive_recursive() {
2415 // 2415 //
2416 // class A extends B {} 2416 // class A extends B {}
2417 // class B extends A {} 2417 // class B extends A {}
2418 // class C {} 2418 // class C {}
2419 // 2419 //
2420 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2420 ClassElementImpl classA = ElementFactory.classElement2("A");
2421 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 2421 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
2422 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2422 ClassElementImpl classC = ElementFactory.classElement2("C");
2423 InterfaceType typeA = classA.type; 2423 InterfaceType typeA = classA.type;
2424 InterfaceType typeC = classC.type; 2424 InterfaceType typeC = classC.type;
2425 classA.supertype = classB.type; 2425 classA.supertype = classB.type;
2426 expect(typeA.isMoreSpecificThan(typeC), isFalse); 2426 expect(typeA.isMoreSpecificThan(typeC), isFalse);
2427 } 2427 }
2428 2428
2429 void test_isMoreSpecificThan_transitive_superclass() { 2429 void test_isMoreSpecificThan_transitive_superclass() {
2430 // 2430 //
2431 // class A {} 2431 // class A {}
2432 // class B extends A {} 2432 // class B extends A {}
2433 // class C extends B {} 2433 // class C extends B {}
2434 // 2434 //
2435 ClassElement classA = ElementFactory.classElement2("A", []); 2435 ClassElement classA = ElementFactory.classElement2("A");
2436 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2436 ClassElement classB = ElementFactory.classElement("B", classA.type);
2437 ClassElement classC = ElementFactory.classElement("C", classB.type, []); 2437 ClassElement classC = ElementFactory.classElement("C", classB.type);
2438 InterfaceType typeA = classA.type; 2438 InterfaceType typeA = classA.type;
2439 InterfaceType typeC = classC.type; 2439 InterfaceType typeC = classC.type;
2440 expect(typeC.isMoreSpecificThan(typeA), isTrue); 2440 expect(typeC.isMoreSpecificThan(typeA), isTrue);
2441 } 2441 }
2442 2442
2443 void test_isMoreSpecificThan_typeParameterType() { 2443 void test_isMoreSpecificThan_typeParameterType() {
2444 // 2444 //
2445 // class A<E> {} 2445 // class A<E> {}
2446 // 2446 //
2447 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 2447 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
2448 InterfaceType typeA = classA.type; 2448 InterfaceType typeA = classA.type;
2449 TypeParameterType parameterType = classA.typeParameters[0].type; 2449 TypeParameterType parameterType = classA.typeParameters[0].type;
2450 DartType objectType = _typeProvider.objectType; 2450 DartType objectType = _typeProvider.objectType;
2451 expect(parameterType.isMoreSpecificThan(objectType), isTrue); 2451 expect(parameterType.isMoreSpecificThan(objectType), isTrue);
2452 expect(parameterType.isMoreSpecificThan(typeA), isFalse); 2452 expect(parameterType.isMoreSpecificThan(typeA), isFalse);
2453 } 2453 }
2454 2454
2455 void test_isMoreSpecificThan_typeParameterType_withBound() { 2455 void test_isMoreSpecificThan_typeParameterType_withBound() {
2456 // 2456 //
2457 // class A {} 2457 // class A {}
2458 // class B<E extends A> {} 2458 // class B<E extends A> {}
2459 // 2459 //
2460 ClassElement classA = ElementFactory.classElement2("A", []); 2460 ClassElement classA = ElementFactory.classElement2("A");
2461 InterfaceType typeA = classA.type; 2461 InterfaceType typeA = classA.type;
2462 ClassElementImpl classB = ElementFactory.classElement2("B", []); 2462 ClassElementImpl classB = ElementFactory.classElement2("B");
2463 TypeParameterElementImpl parameterEA = new TypeParameterElementImpl.forNode( AstFactory.identifier3("E")); 2463 TypeParameterElementImpl parameterEA = new TypeParameterElementImpl.forNode( AstFactory.identifier3("E"));
2464 TypeParameterType parameterAEType = new TypeParameterTypeImpl(parameterEA); 2464 TypeParameterType parameterAEType = new TypeParameterTypeImpl(parameterEA);
2465 parameterEA.bound = typeA; 2465 parameterEA.bound = typeA;
2466 parameterEA.type = parameterAEType; 2466 parameterEA.type = parameterAEType;
2467 classB.typeParameters = <TypeParameterElementImpl> [parameterEA]; 2467 classB.typeParameters = <TypeParameterElementImpl> [parameterEA];
2468 expect(parameterAEType.isMoreSpecificThan(typeA), isTrue); 2468 expect(parameterAEType.isMoreSpecificThan(typeA), isTrue);
2469 } 2469 }
2470 2470
2471 void test_isSubtypeOf_directSubtype() { 2471 void test_isSubtypeOf_directSubtype() {
2472 ClassElement classA = ElementFactory.classElement2("A", []); 2472 ClassElement classA = ElementFactory.classElement2("A");
2473 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2473 ClassElement classB = ElementFactory.classElement("B", classA.type);
2474 InterfaceType typeA = classA.type; 2474 InterfaceType typeA = classA.type;
2475 InterfaceType typeB = classB.type; 2475 InterfaceType typeB = classB.type;
2476 expect(typeB.isSubtypeOf(typeA), isTrue); 2476 expect(typeB.isSubtypeOf(typeA), isTrue);
2477 expect(typeA.isSubtypeOf(typeB), isFalse); 2477 expect(typeA.isSubtypeOf(typeB), isFalse);
2478 } 2478 }
2479 2479
2480 void test_isSubtypeOf_dynamic() { 2480 void test_isSubtypeOf_dynamic() {
2481 ClassElement classA = ElementFactory.classElement2("A", []); 2481 ClassElement classA = ElementFactory.classElement2("A");
2482 InterfaceType typeA = classA.type; 2482 InterfaceType typeA = classA.type;
2483 DartType dynamicType = DynamicTypeImpl.instance; 2483 DartType dynamicType = DynamicTypeImpl.instance;
2484 expect(dynamicType.isSubtypeOf(typeA), isTrue); 2484 expect(dynamicType.isSubtypeOf(typeA), isTrue);
2485 expect(typeA.isSubtypeOf(dynamicType), isTrue); 2485 expect(typeA.isSubtypeOf(dynamicType), isTrue);
2486 } 2486 }
2487 2487
2488 void test_isSubtypeOf_function() { 2488 void test_isSubtypeOf_function() {
2489 // 2489 //
2490 // void f(String s) {} 2490 // void f(String s) {}
2491 // class A { 2491 // class A {
2492 // void call(String s) {} 2492 // void call(String s) {}
2493 // } 2493 // }
2494 // 2494 //
2495 InterfaceType stringType = _typeProvider.stringType; 2495 InterfaceType stringType = _typeProvider.stringType;
2496 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2496 ClassElementImpl classA = ElementFactory.classElement2("A");
2497 classA.methods = <MethodElement> [ElementFactory.methodElement("call", VoidT ypeImpl.instance, [stringType])]; 2497 classA.methods = <MethodElement> [ElementFactory.methodElement("call", VoidT ypeImpl.instance, [stringType])];
2498 FunctionType functionType = ElementFactory.functionElement5("f", <ClassEleme nt> [stringType.element]).type; 2498 FunctionType functionType = ElementFactory.functionElement5("f", <ClassEleme nt> [stringType.element]).type;
2499 expect(classA.type.isSubtypeOf(functionType), isTrue); 2499 expect(classA.type.isSubtypeOf(functionType), isTrue);
2500 } 2500 }
2501 2501
2502 void test_isSubtypeOf_generic() { 2502 void test_isSubtypeOf_generic() {
2503 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 2503 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
2504 ClassElement classB = ElementFactory.classElement2("B", []); 2504 ClassElement classB = ElementFactory.classElement2("B");
2505 DartType dynamicType = DynamicTypeImpl.instance; 2505 DartType dynamicType = DynamicTypeImpl.instance;
2506 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy pe]); 2506 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy pe]);
2507 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]); 2507 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]);
2508 expect(typeAOfDynamic.isSubtypeOf(typeAOfB), isTrue); 2508 expect(typeAOfDynamic.isSubtypeOf(typeAOfB), isTrue);
2509 expect(typeAOfB.isSubtypeOf(typeAOfDynamic), isTrue); 2509 expect(typeAOfB.isSubtypeOf(typeAOfDynamic), isTrue);
2510 } 2510 }
2511 2511
2512 void test_isSubtypeOf_interface() { 2512 void test_isSubtypeOf_interface() {
2513 ClassElement classA = ElementFactory.classElement2("A", []); 2513 ClassElement classA = ElementFactory.classElement2("A");
2514 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2514 ClassElement classB = ElementFactory.classElement("B", classA.type);
2515 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2515 ClassElementImpl classC = ElementFactory.classElement2("C");
2516 InterfaceType typeObject = classA.supertype; 2516 InterfaceType typeObject = classA.supertype;
2517 InterfaceType typeA = classA.type; 2517 InterfaceType typeA = classA.type;
2518 InterfaceType typeB = classB.type; 2518 InterfaceType typeB = classB.type;
2519 InterfaceType typeC = classC.type; 2519 InterfaceType typeC = classC.type;
2520 classC.interfaces = <InterfaceType> [typeB]; 2520 classC.interfaces = <InterfaceType> [typeB];
2521 expect(typeC.isSubtypeOf(typeB), isTrue); 2521 expect(typeC.isSubtypeOf(typeB), isTrue);
2522 expect(typeC.isSubtypeOf(typeObject), isTrue); 2522 expect(typeC.isSubtypeOf(typeObject), isTrue);
2523 expect(typeC.isSubtypeOf(typeA), isTrue); 2523 expect(typeC.isSubtypeOf(typeA), isTrue);
2524 expect(typeA.isSubtypeOf(typeC), isFalse); 2524 expect(typeA.isSubtypeOf(typeC), isFalse);
2525 } 2525 }
2526 2526
2527 void test_isSubtypeOf_mixins() { 2527 void test_isSubtypeOf_mixins() {
2528 // 2528 //
2529 // class A {} 2529 // class A {}
2530 // class B extends A {} 2530 // class B extends A {}
2531 // class C with B {} 2531 // class C with B {}
2532 // 2532 //
2533 ClassElement classA = ElementFactory.classElement2("A", []); 2533 ClassElement classA = ElementFactory.classElement2("A");
2534 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2534 ClassElement classB = ElementFactory.classElement("B", classA.type);
2535 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2535 ClassElementImpl classC = ElementFactory.classElement2("C");
2536 InterfaceType typeObject = classA.supertype; 2536 InterfaceType typeObject = classA.supertype;
2537 InterfaceType typeA = classA.type; 2537 InterfaceType typeA = classA.type;
2538 InterfaceType typeB = classB.type; 2538 InterfaceType typeB = classB.type;
2539 InterfaceType typeC = classC.type; 2539 InterfaceType typeC = classC.type;
2540 classC.mixins = <InterfaceType> [typeB]; 2540 classC.mixins = <InterfaceType> [typeB];
2541 expect(typeC.isSubtypeOf(typeB), isTrue); 2541 expect(typeC.isSubtypeOf(typeB), isTrue);
2542 expect(typeC.isSubtypeOf(typeObject), isTrue); 2542 expect(typeC.isSubtypeOf(typeObject), isTrue);
2543 expect(typeC.isSubtypeOf(typeA), isTrue); 2543 expect(typeC.isSubtypeOf(typeA), isTrue);
2544 expect(typeA.isSubtypeOf(typeC), isFalse); 2544 expect(typeA.isSubtypeOf(typeC), isFalse);
2545 } 2545 }
2546 2546
2547 void test_isSubtypeOf_object() { 2547 void test_isSubtypeOf_object() {
2548 ClassElement classA = ElementFactory.classElement2("A", []); 2548 ClassElement classA = ElementFactory.classElement2("A");
2549 InterfaceType typeA = classA.type; 2549 InterfaceType typeA = classA.type;
2550 InterfaceType typeObject = classA.supertype; 2550 InterfaceType typeObject = classA.supertype;
2551 expect(typeA.isSubtypeOf(typeObject), isTrue); 2551 expect(typeA.isSubtypeOf(typeObject), isTrue);
2552 expect(typeObject.isSubtypeOf(typeA), isFalse); 2552 expect(typeObject.isSubtypeOf(typeA), isFalse);
2553 } 2553 }
2554 2554
2555 void test_isSubtypeOf_self() { 2555 void test_isSubtypeOf_self() {
2556 ClassElement classA = ElementFactory.classElement2("A", []); 2556 ClassElement classA = ElementFactory.classElement2("A");
2557 InterfaceType typeA = classA.type; 2557 InterfaceType typeA = classA.type;
2558 expect(typeA.isSubtypeOf(typeA), isTrue); 2558 expect(typeA.isSubtypeOf(typeA), isTrue);
2559 } 2559 }
2560 2560
2561 void test_isSubtypeOf_transitive_recursive() { 2561 void test_isSubtypeOf_transitive_recursive() {
2562 // 2562 //
2563 // class A extends B {} 2563 // class A extends B {}
2564 // class B extends A {} 2564 // class B extends A {}
2565 // class C {} 2565 // class C {}
2566 // 2566 //
2567 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2567 ClassElementImpl classA = ElementFactory.classElement2("A");
2568 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 2568 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
2569 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2569 ClassElementImpl classC = ElementFactory.classElement2("C");
2570 InterfaceType typeA = classA.type; 2570 InterfaceType typeA = classA.type;
2571 InterfaceType typeC = classC.type; 2571 InterfaceType typeC = classC.type;
2572 classA.supertype = classB.type; 2572 classA.supertype = classB.type;
2573 expect(typeA.isSubtypeOf(typeC), isFalse); 2573 expect(typeA.isSubtypeOf(typeC), isFalse);
2574 } 2574 }
2575 2575
2576 void test_isSubtypeOf_transitive_superclass() { 2576 void test_isSubtypeOf_transitive_superclass() {
2577 ClassElement classA = ElementFactory.classElement2("A", []); 2577 ClassElement classA = ElementFactory.classElement2("A");
2578 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2578 ClassElement classB = ElementFactory.classElement("B", classA.type);
2579 ClassElement classC = ElementFactory.classElement("C", classB.type, []); 2579 ClassElement classC = ElementFactory.classElement("C", classB.type);
2580 InterfaceType typeA = classA.type; 2580 InterfaceType typeA = classA.type;
2581 InterfaceType typeC = classC.type; 2581 InterfaceType typeC = classC.type;
2582 expect(typeC.isSubtypeOf(typeA), isTrue); 2582 expect(typeC.isSubtypeOf(typeA), isTrue);
2583 expect(typeA.isSubtypeOf(typeC), isFalse); 2583 expect(typeA.isSubtypeOf(typeC), isFalse);
2584 } 2584 }
2585 2585
2586 void test_isSubtypeOf_typeArguments() { 2586 void test_isSubtypeOf_typeArguments() {
2587 DartType dynamicType = DynamicTypeImpl.instance; 2587 DartType dynamicType = DynamicTypeImpl.instance;
2588 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 2588 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
2589 ClassElement classI = ElementFactory.classElement2("I", []); 2589 ClassElement classI = ElementFactory.classElement2("I");
2590 ClassElement classJ = ElementFactory.classElement("J", classI.type, []); 2590 ClassElement classJ = ElementFactory.classElement("J", classI.type);
2591 ClassElement classK = ElementFactory.classElement2("K", []); 2591 ClassElement classK = ElementFactory.classElement2("K");
2592 InterfaceType typeA = classA.type; 2592 InterfaceType typeA = classA.type;
2593 InterfaceType typeA_dynamic = typeA.substitute4(<DartType> [dynamicType]); 2593 InterfaceType typeA_dynamic = typeA.substitute4(<DartType> [dynamicType]);
2594 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 2594 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
2595 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA); 2595 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA);
2596 InterfaceTypeImpl typeAK = new InterfaceTypeImpl.con1(classA); 2596 InterfaceTypeImpl typeAK = new InterfaceTypeImpl.con1(classA);
2597 typeAI.typeArguments = <DartType> [classI.type]; 2597 typeAI.typeArguments = <DartType> [classI.type];
2598 typeAJ.typeArguments = <DartType> [classJ.type]; 2598 typeAJ.typeArguments = <DartType> [classJ.type];
2599 typeAK.typeArguments = <DartType> [classK.type]; 2599 typeAK.typeArguments = <DartType> [classK.type];
2600 // A<J> <: A<I> since J <: I 2600 // A<J> <: A<I> since J <: I
2601 expect(typeAJ.isSubtypeOf(typeAI), isTrue); 2601 expect(typeAJ.isSubtypeOf(typeAI), isTrue);
(...skipping 15 matching lines...) Expand all
2617 // 2617 //
2618 // class A<E> {} 2618 // class A<E> {}
2619 // 2619 //
2620 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 2620 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
2621 InterfaceType typeA = classA.type; 2621 InterfaceType typeA = classA.type;
2622 TypeParameterType parameterType = classA.typeParameters[0].type; 2622 TypeParameterType parameterType = classA.typeParameters[0].type;
2623 expect(typeA.isSubtypeOf(parameterType), isFalse); 2623 expect(typeA.isSubtypeOf(parameterType), isFalse);
2624 } 2624 }
2625 2625
2626 void test_isSupertypeOf_directSupertype() { 2626 void test_isSupertypeOf_directSupertype() {
2627 ClassElement classA = ElementFactory.classElement2("A", []); 2627 ClassElement classA = ElementFactory.classElement2("A");
2628 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2628 ClassElement classB = ElementFactory.classElement("B", classA.type);
2629 InterfaceType typeA = classA.type; 2629 InterfaceType typeA = classA.type;
2630 InterfaceType typeB = classB.type; 2630 InterfaceType typeB = classB.type;
2631 expect(typeB.isSupertypeOf(typeA), isFalse); 2631 expect(typeB.isSupertypeOf(typeA), isFalse);
2632 expect(typeA.isSupertypeOf(typeB), isTrue); 2632 expect(typeA.isSupertypeOf(typeB), isTrue);
2633 } 2633 }
2634 2634
2635 void test_isSupertypeOf_dynamic() { 2635 void test_isSupertypeOf_dynamic() {
2636 ClassElement classA = ElementFactory.classElement2("A", []); 2636 ClassElement classA = ElementFactory.classElement2("A");
2637 InterfaceType typeA = classA.type; 2637 InterfaceType typeA = classA.type;
2638 DartType dynamicType = DynamicTypeImpl.instance; 2638 DartType dynamicType = DynamicTypeImpl.instance;
2639 expect(dynamicType.isSupertypeOf(typeA), isTrue); 2639 expect(dynamicType.isSupertypeOf(typeA), isTrue);
2640 expect(typeA.isSupertypeOf(dynamicType), isTrue); 2640 expect(typeA.isSupertypeOf(dynamicType), isTrue);
2641 } 2641 }
2642 2642
2643 void test_isSupertypeOf_indirectSupertype() { 2643 void test_isSupertypeOf_indirectSupertype() {
2644 ClassElement classA = ElementFactory.classElement2("A", []); 2644 ClassElement classA = ElementFactory.classElement2("A");
2645 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2645 ClassElement classB = ElementFactory.classElement("B", classA.type);
2646 ClassElement classC = ElementFactory.classElement("C", classB.type, []); 2646 ClassElement classC = ElementFactory.classElement("C", classB.type);
2647 InterfaceType typeA = classA.type; 2647 InterfaceType typeA = classA.type;
2648 InterfaceType typeC = classC.type; 2648 InterfaceType typeC = classC.type;
2649 expect(typeC.isSupertypeOf(typeA), isFalse); 2649 expect(typeC.isSupertypeOf(typeA), isFalse);
2650 expect(typeA.isSupertypeOf(typeC), isTrue); 2650 expect(typeA.isSupertypeOf(typeC), isTrue);
2651 } 2651 }
2652 2652
2653 void test_isSupertypeOf_interface() { 2653 void test_isSupertypeOf_interface() {
2654 ClassElement classA = ElementFactory.classElement2("A", []); 2654 ClassElement classA = ElementFactory.classElement2("A");
2655 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2655 ClassElement classB = ElementFactory.classElement("B", classA.type);
2656 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2656 ClassElementImpl classC = ElementFactory.classElement2("C");
2657 InterfaceType typeObject = classA.supertype; 2657 InterfaceType typeObject = classA.supertype;
2658 InterfaceType typeA = classA.type; 2658 InterfaceType typeA = classA.type;
2659 InterfaceType typeB = classB.type; 2659 InterfaceType typeB = classB.type;
2660 InterfaceType typeC = classC.type; 2660 InterfaceType typeC = classC.type;
2661 classC.interfaces = <InterfaceType> [typeB]; 2661 classC.interfaces = <InterfaceType> [typeB];
2662 expect(typeB.isSupertypeOf(typeC), isTrue); 2662 expect(typeB.isSupertypeOf(typeC), isTrue);
2663 expect(typeObject.isSupertypeOf(typeC), isTrue); 2663 expect(typeObject.isSupertypeOf(typeC), isTrue);
2664 expect(typeA.isSupertypeOf(typeC), isTrue); 2664 expect(typeA.isSupertypeOf(typeC), isTrue);
2665 expect(typeC.isSupertypeOf(typeA), isFalse); 2665 expect(typeC.isSupertypeOf(typeA), isFalse);
2666 } 2666 }
2667 2667
2668 void test_isSupertypeOf_mixins() { 2668 void test_isSupertypeOf_mixins() {
2669 // 2669 //
2670 // class A {} 2670 // class A {}
2671 // class B extends A {} 2671 // class B extends A {}
2672 // class C with B {} 2672 // class C with B {}
2673 // 2673 //
2674 ClassElement classA = ElementFactory.classElement2("A", []); 2674 ClassElement classA = ElementFactory.classElement2("A");
2675 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 2675 ClassElement classB = ElementFactory.classElement("B", classA.type);
2676 ClassElementImpl classC = ElementFactory.classElement2("C", []); 2676 ClassElementImpl classC = ElementFactory.classElement2("C");
2677 InterfaceType typeObject = classA.supertype; 2677 InterfaceType typeObject = classA.supertype;
2678 InterfaceType typeA = classA.type; 2678 InterfaceType typeA = classA.type;
2679 InterfaceType typeB = classB.type; 2679 InterfaceType typeB = classB.type;
2680 InterfaceType typeC = classC.type; 2680 InterfaceType typeC = classC.type;
2681 classC.mixins = <InterfaceType> [typeB]; 2681 classC.mixins = <InterfaceType> [typeB];
2682 expect(typeB.isSupertypeOf(typeC), isTrue); 2682 expect(typeB.isSupertypeOf(typeC), isTrue);
2683 expect(typeObject.isSupertypeOf(typeC), isTrue); 2683 expect(typeObject.isSupertypeOf(typeC), isTrue);
2684 expect(typeA.isSupertypeOf(typeC), isTrue); 2684 expect(typeA.isSupertypeOf(typeC), isTrue);
2685 expect(typeC.isSupertypeOf(typeA), isFalse); 2685 expect(typeC.isSupertypeOf(typeA), isFalse);
2686 } 2686 }
2687 2687
2688 void test_isSupertypeOf_object() { 2688 void test_isSupertypeOf_object() {
2689 ClassElement classA = ElementFactory.classElement2("A", []); 2689 ClassElement classA = ElementFactory.classElement2("A");
2690 InterfaceType typeA = classA.type; 2690 InterfaceType typeA = classA.type;
2691 InterfaceType typeObject = classA.supertype; 2691 InterfaceType typeObject = classA.supertype;
2692 expect(typeA.isSupertypeOf(typeObject), isFalse); 2692 expect(typeA.isSupertypeOf(typeObject), isFalse);
2693 expect(typeObject.isSupertypeOf(typeA), isTrue); 2693 expect(typeObject.isSupertypeOf(typeA), isTrue);
2694 } 2694 }
2695 2695
2696 void test_isSupertypeOf_self() { 2696 void test_isSupertypeOf_self() {
2697 ClassElement classA = ElementFactory.classElement2("A", []); 2697 ClassElement classA = ElementFactory.classElement2("A");
2698 InterfaceType typeA = classA.type; 2698 InterfaceType typeA = classA.type;
2699 expect(typeA.isSupertypeOf(typeA), isTrue); 2699 expect(typeA.isSupertypeOf(typeA), isTrue);
2700 } 2700 }
2701 2701
2702 void test_lookUpGetter_implemented() { 2702 void test_lookUpGetter_implemented() {
2703 // 2703 //
2704 // class A { g {} } 2704 // class A { g {} }
2705 // 2705 //
2706 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2706 ClassElementImpl classA = ElementFactory.classElement2("A");
2707 String getterName = "g"; 2707 String getterName = "g";
2708 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null); 2708 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null);
2709 classA.accessors = <PropertyAccessorElement> [getterG]; 2709 classA.accessors = <PropertyAccessorElement> [getterG];
2710 InterfaceType typeA = classA.type; 2710 InterfaceType typeA = classA.type;
2711 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2711 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2712 CompilationUnitElement unit = library.definingCompilationUnit; 2712 CompilationUnitElement unit = library.definingCompilationUnit;
2713 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; 2713 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA];
2714 expect(typeA.lookUpGetter(getterName, library), same(getterG)); 2714 expect(typeA.lookUpGetter(getterName, library), same(getterG));
2715 } 2715 }
2716 2716
2717 void test_lookUpGetter_inherited() { 2717 void test_lookUpGetter_inherited() {
2718 // 2718 //
2719 // class A { g {} } 2719 // class A { g {} }
2720 // class B extends A {} 2720 // class B extends A {}
2721 // 2721 //
2722 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2722 ClassElementImpl classA = ElementFactory.classElement2("A");
2723 String getterName = "g"; 2723 String getterName = "g";
2724 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null); 2724 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null);
2725 classA.accessors = <PropertyAccessorElement> [getterG]; 2725 classA.accessors = <PropertyAccessorElement> [getterG];
2726 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 2726 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
2727 InterfaceType typeB = classB.type; 2727 InterfaceType typeB = classB.type;
2728 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2728 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2729 CompilationUnitElement unit = library.definingCompilationUnit; 2729 CompilationUnitElement unit = library.definingCompilationUnit;
2730 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ; 2730 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ;
2731 expect(typeB.lookUpGetter(getterName, library), same(getterG)); 2731 expect(typeB.lookUpGetter(getterName, library), same(getterG));
2732 } 2732 }
2733 2733
2734 void test_lookUpGetter_recursive() { 2734 void test_lookUpGetter_recursive() {
2735 // 2735 //
2736 // class A extends B {} 2736 // class A extends B {}
2737 // class B extends A {} 2737 // class B extends A {}
2738 // 2738 //
2739 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2739 ClassElementImpl classA = ElementFactory.classElement2("A");
2740 InterfaceType typeA = classA.type; 2740 InterfaceType typeA = classA.type;
2741 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); 2741 ClassElementImpl classB = ElementFactory.classElement("B", typeA);
2742 classA.supertype = classB.type; 2742 classA.supertype = classB.type;
2743 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2743 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2744 CompilationUnitElement unit = library.definingCompilationUnit; 2744 CompilationUnitElement unit = library.definingCompilationUnit;
2745 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ; 2745 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ;
2746 expect(typeA.lookUpGetter("g", library), isNull); 2746 expect(typeA.lookUpGetter("g", library), isNull);
2747 } 2747 }
2748 2748
2749 void test_lookUpGetter_unimplemented() { 2749 void test_lookUpGetter_unimplemented() {
2750 // 2750 //
2751 // class A {} 2751 // class A {}
2752 // 2752 //
2753 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2753 ClassElementImpl classA = ElementFactory.classElement2("A");
2754 InterfaceType typeA = classA.type; 2754 InterfaceType typeA = classA.type;
2755 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2755 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2756 CompilationUnitElement unit = library.definingCompilationUnit; 2756 CompilationUnitElement unit = library.definingCompilationUnit;
2757 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; 2757 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA];
2758 expect(typeA.lookUpGetter("g", library), isNull); 2758 expect(typeA.lookUpGetter("g", library), isNull);
2759 } 2759 }
2760 2760
2761 void test_lookUpMethod_implemented() { 2761 void test_lookUpMethod_implemented() {
2762 // 2762 //
2763 // class A { m() {} } 2763 // class A { m() {} }
2764 // 2764 //
2765 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2765 ClassElementImpl classA = ElementFactory.classElement2("A");
2766 String methodName = "m"; 2766 String methodName = "m";
2767 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [ ]); 2767 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null);
2768 classA.methods = <MethodElement> [methodM]; 2768 classA.methods = <MethodElement> [methodM];
2769 InterfaceType typeA = classA.type; 2769 InterfaceType typeA = classA.type;
2770 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2770 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2771 CompilationUnitElement unit = library.definingCompilationUnit; 2771 CompilationUnitElement unit = library.definingCompilationUnit;
2772 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; 2772 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA];
2773 expect(typeA.lookUpMethod(methodName, library), same(methodM)); 2773 expect(typeA.lookUpMethod(methodName, library), same(methodM));
2774 } 2774 }
2775 2775
2776 void test_lookUpMethod_inherited() { 2776 void test_lookUpMethod_inherited() {
2777 // 2777 //
2778 // class A { m() {} } 2778 // class A { m() {} }
2779 // class B extends A {} 2779 // class B extends A {}
2780 // 2780 //
2781 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2781 ClassElementImpl classA = ElementFactory.classElement2("A");
2782 String methodName = "m"; 2782 String methodName = "m";
2783 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [ ]); 2783 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null);
2784 classA.methods = <MethodElement> [methodM]; 2784 classA.methods = <MethodElement> [methodM];
2785 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 2785 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
2786 InterfaceType typeB = classB.type; 2786 InterfaceType typeB = classB.type;
2787 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2787 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2788 CompilationUnitElement unit = library.definingCompilationUnit; 2788 CompilationUnitElement unit = library.definingCompilationUnit;
2789 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ; 2789 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ;
2790 expect(typeB.lookUpMethod(methodName, library), same(methodM)); 2790 expect(typeB.lookUpMethod(methodName, library), same(methodM));
2791 } 2791 }
2792 2792
2793 void test_lookUpMethod_parameterized() { 2793 void test_lookUpMethod_parameterized() {
2794 // 2794 //
2795 // class A<E> { E m(E p) {} } 2795 // class A<E> { E m(E p) {} }
2796 // class B<F> extends A<F> {} 2796 // class B<F> extends A<F> {}
2797 // 2797 //
2798 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 2798 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
2799 DartType typeE = classA.type.typeArguments[0]; 2799 DartType typeE = classA.type.typeArguments[0];
2800 String methodName = "m"; 2800 String methodName = "m";
2801 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]); 2801 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]);
2802 classA.methods = <MethodElement> [methodM]; 2802 classA.methods = <MethodElement> [methodM];
2803 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ; 2803 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments ;
2804 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); 2804 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
2805 InterfaceType typeB = classB.type; 2805 InterfaceType typeB = classB.type;
2806 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); 2806 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
2807 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; 2807 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]];
2808 classB.supertype = typeAF; 2808 classB.supertype = typeAF;
2809 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2809 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2810 CompilationUnitElement unit = library.definingCompilationUnit; 2810 CompilationUnitElement unit = library.definingCompilationUnit;
2811 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; 2811 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA];
2812 // 2812 //
2813 // B<I> 2813 // B<I>
2814 // 2814 //
2815 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 2815 InterfaceType typeI = ElementFactory.classElement2("I").type;
2816 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); 2816 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
2817 typeBI.typeArguments = <DartType> [typeI]; 2817 typeBI.typeArguments = <DartType> [typeI];
2818 MethodElement method = typeBI.lookUpMethod(methodName, library); 2818 MethodElement method = typeBI.lookUpMethod(methodName, library);
2819 expect(method, isNotNull); 2819 expect(method, isNotNull);
2820 FunctionType methodType = method.type; 2820 FunctionType methodType = method.type;
2821 expect(methodType.returnType, same(typeI)); 2821 expect(methodType.returnType, same(typeI));
2822 List<DartType> parameterTypes = methodType.normalParameterTypes; 2822 List<DartType> parameterTypes = methodType.normalParameterTypes;
2823 expect(parameterTypes, hasLength(1)); 2823 expect(parameterTypes, hasLength(1));
2824 expect(parameterTypes[0], same(typeI)); 2824 expect(parameterTypes[0], same(typeI));
2825 } 2825 }
2826 2826
2827 void test_lookUpMethod_recursive() { 2827 void test_lookUpMethod_recursive() {
2828 // 2828 //
2829 // class A extends B {} 2829 // class A extends B {}
2830 // class B extends A {} 2830 // class B extends A {}
2831 // 2831 //
2832 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2832 ClassElementImpl classA = ElementFactory.classElement2("A");
2833 InterfaceType typeA = classA.type; 2833 InterfaceType typeA = classA.type;
2834 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); 2834 ClassElementImpl classB = ElementFactory.classElement("B", typeA);
2835 classA.supertype = classB.type; 2835 classA.supertype = classB.type;
2836 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2836 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2837 CompilationUnitElement unit = library.definingCompilationUnit; 2837 CompilationUnitElement unit = library.definingCompilationUnit;
2838 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ; 2838 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ;
2839 expect(typeA.lookUpMethod("m", library), isNull); 2839 expect(typeA.lookUpMethod("m", library), isNull);
2840 } 2840 }
2841 2841
2842 void test_lookUpMethod_unimplemented() { 2842 void test_lookUpMethod_unimplemented() {
2843 // 2843 //
2844 // class A {} 2844 // class A {}
2845 // 2845 //
2846 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2846 ClassElementImpl classA = ElementFactory.classElement2("A");
2847 InterfaceType typeA = classA.type; 2847 InterfaceType typeA = classA.type;
2848 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2848 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2849 CompilationUnitElement unit = library.definingCompilationUnit; 2849 CompilationUnitElement unit = library.definingCompilationUnit;
2850 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; 2850 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA];
2851 expect(typeA.lookUpMethod("m", library), isNull); 2851 expect(typeA.lookUpMethod("m", library), isNull);
2852 } 2852 }
2853 2853
2854 void test_lookUpSetter_implemented() { 2854 void test_lookUpSetter_implemented() {
2855 // 2855 //
2856 // class A { s(x) {} } 2856 // class A { s(x) {} }
2857 // 2857 //
2858 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2858 ClassElementImpl classA = ElementFactory.classElement2("A");
2859 String setterName = "s"; 2859 String setterName = "s";
2860 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null); 2860 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null);
2861 classA.accessors = <PropertyAccessorElement> [setterS]; 2861 classA.accessors = <PropertyAccessorElement> [setterS];
2862 InterfaceType typeA = classA.type; 2862 InterfaceType typeA = classA.type;
2863 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2863 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2864 CompilationUnitElement unit = library.definingCompilationUnit; 2864 CompilationUnitElement unit = library.definingCompilationUnit;
2865 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; 2865 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA];
2866 expect(typeA.lookUpSetter(setterName, library), same(setterS)); 2866 expect(typeA.lookUpSetter(setterName, library), same(setterS));
2867 } 2867 }
2868 2868
2869 void test_lookUpSetter_inherited() { 2869 void test_lookUpSetter_inherited() {
2870 // 2870 //
2871 // class A { s(x) {} } 2871 // class A { s(x) {} }
2872 // class B extends A {} 2872 // class B extends A {}
2873 // 2873 //
2874 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2874 ClassElementImpl classA = ElementFactory.classElement2("A");
2875 String setterName = "g"; 2875 String setterName = "g";
2876 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null); 2876 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null);
2877 classA.accessors = <PropertyAccessorElement> [setterS]; 2877 classA.accessors = <PropertyAccessorElement> [setterS];
2878 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 2878 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
2879 InterfaceType typeB = classB.type; 2879 InterfaceType typeB = classB.type;
2880 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2880 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2881 CompilationUnitElement unit = library.definingCompilationUnit; 2881 CompilationUnitElement unit = library.definingCompilationUnit;
2882 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ; 2882 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ;
2883 expect(typeB.lookUpSetter(setterName, library), same(setterS)); 2883 expect(typeB.lookUpSetter(setterName, library), same(setterS));
2884 } 2884 }
2885 2885
2886 void test_lookUpSetter_recursive() { 2886 void test_lookUpSetter_recursive() {
2887 // 2887 //
2888 // class A extends B {} 2888 // class A extends B {}
2889 // class B extends A {} 2889 // class B extends A {}
2890 // 2890 //
2891 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2891 ClassElementImpl classA = ElementFactory.classElement2("A");
2892 InterfaceType typeA = classA.type; 2892 InterfaceType typeA = classA.type;
2893 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); 2893 ClassElementImpl classB = ElementFactory.classElement("B", typeA);
2894 classA.supertype = classB.type; 2894 classA.supertype = classB.type;
2895 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2895 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2896 CompilationUnitElement unit = library.definingCompilationUnit; 2896 CompilationUnitElement unit = library.definingCompilationUnit;
2897 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ; 2897 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB] ;
2898 expect(typeA.lookUpSetter("s", library), isNull); 2898 expect(typeA.lookUpSetter("s", library), isNull);
2899 } 2899 }
2900 2900
2901 void test_lookUpSetter_unimplemented() { 2901 void test_lookUpSetter_unimplemented() {
2902 // 2902 //
2903 // class A {} 2903 // class A {}
2904 // 2904 //
2905 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2905 ClassElementImpl classA = ElementFactory.classElement2("A");
2906 InterfaceType typeA = classA.type; 2906 InterfaceType typeA = classA.type;
2907 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 2907 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2908 CompilationUnitElement unit = library.definingCompilationUnit; 2908 CompilationUnitElement unit = library.definingCompilationUnit;
2909 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; 2909 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA];
2910 expect(typeA.lookUpSetter("s", library), isNull); 2910 expect(typeA.lookUpSetter("s", library), isNull);
2911 } 2911 }
2912 2912
2913 void test_setTypeArguments() { 2913 void test_setTypeArguments() {
2914 InterfaceTypeImpl type = ElementFactory.classElement2("A", []).type as Inter faceTypeImpl; 2914 InterfaceTypeImpl type = ElementFactory.classElement2("A").type as Interface TypeImpl;
2915 List<DartType> typeArguments = <DartType> [ 2915 List<DartType> typeArguments = <DartType> [
2916 ElementFactory.classElement2("B", []).type, 2916 ElementFactory.classElement2("B").type,
2917 ElementFactory.classElement2("C", []).type]; 2917 ElementFactory.classElement2("C").type];
2918 type.typeArguments = typeArguments; 2918 type.typeArguments = typeArguments;
2919 expect(type.typeArguments, typeArguments); 2919 expect(type.typeArguments, typeArguments);
2920 } 2920 }
2921 2921
2922 void test_substitute_equal() { 2922 void test_substitute_equal() {
2923 ClassElement classAE = ElementFactory.classElement2("A", ["E"]); 2923 ClassElement classAE = ElementFactory.classElement2("A", ["E"]);
2924 InterfaceType typeAE = classAE.type; 2924 InterfaceType typeAE = classAE.type;
2925 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; 2925 InterfaceType argumentType = ElementFactory.classElement2("B").type;
2926 List<DartType> args = [argumentType]; 2926 List<DartType> args = [argumentType];
2927 List<DartType> params = [classAE.typeParameters[0].type]; 2927 List<DartType> params = [classAE.typeParameters[0].type];
2928 InterfaceType typeAESubbed = typeAE.substitute2(args, params); 2928 InterfaceType typeAESubbed = typeAE.substitute2(args, params);
2929 expect(typeAESubbed.element, classAE); 2929 expect(typeAESubbed.element, classAE);
2930 List<DartType> resultArguments = typeAESubbed.typeArguments; 2930 List<DartType> resultArguments = typeAESubbed.typeArguments;
2931 expect(resultArguments, hasLength(1)); 2931 expect(resultArguments, hasLength(1));
2932 expect(resultArguments[0], argumentType); 2932 expect(resultArguments[0], argumentType);
2933 } 2933 }
2934 2934
2935 void test_substitute_exception() { 2935 void test_substitute_exception() {
2936 try { 2936 try {
2937 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2937 ClassElementImpl classA = ElementFactory.classElement2("A");
2938 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); 2938 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA);
2939 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; 2939 InterfaceType argumentType = ElementFactory.classElement2("B").type;
2940 type.substitute2(<DartType> [argumentType], <DartType> []); 2940 type.substitute2(<DartType> [argumentType], <DartType>[]);
2941 fail("Expected to encounter exception, argument and parameter type array l engths not equal."); 2941 fail("Expected to encounter exception, argument and parameter type array l engths not equal.");
2942 } catch (e) { 2942 } catch (e) {
2943 // Expected result 2943 // Expected result
2944 } 2944 }
2945 } 2945 }
2946 2946
2947 void test_substitute_notEqual() { 2947 void test_substitute_notEqual() {
2948 // The [test_substitute_equals] above has a slightly higher level implementa tion. 2948 // The [test_substitute_equals] above has a slightly higher level implementa tion.
2949 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2949 ClassElementImpl classA = ElementFactory.classElement2("A");
2950 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl.for Node(AstFactory.identifier3("E")); 2950 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl.for Node(AstFactory.identifier3("E"));
2951 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); 2951 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA);
2952 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement ); 2952 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement );
2953 type.typeArguments = <DartType> [parameter]; 2953 type.typeArguments = <DartType> [parameter];
2954 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; 2954 InterfaceType argumentType = ElementFactory.classElement2("B").type;
2955 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl.forNode(AstFactory.identifier3("F"))); 2955 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl.forNode(AstFactory.identifier3("F")));
2956 InterfaceType result = type.substitute2(<DartType> [argumentType], <DartType > [parameterType]); 2956 InterfaceType result = type.substitute2(<DartType> [argumentType], <DartType > [parameterType]);
2957 expect(result.element, classA); 2957 expect(result.element, classA);
2958 List<DartType> resultArguments = result.typeArguments; 2958 List<DartType> resultArguments = result.typeArguments;
2959 expect(resultArguments, hasLength(1)); 2959 expect(resultArguments, hasLength(1));
2960 expect(resultArguments[0], parameter); 2960 expect(resultArguments[0], parameter);
2961 } 2961 }
2962 } 2962 }
2963 2963
2964 class InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunc tion extends InterfaceTypeImpl { 2964 class InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunc tion extends InterfaceTypeImpl {
(...skipping 10 matching lines...) Expand all
2975 2975
2976 void test_getImportedLibraries() { 2976 void test_getImportedLibraries() {
2977 AnalysisContext context = createAnalysisContext(); 2977 AnalysisContext context = createAnalysisContext();
2978 LibraryElementImpl library1 = ElementFactory.library(context, "l1"); 2978 LibraryElementImpl library1 = ElementFactory.library(context, "l1");
2979 LibraryElementImpl library2 = ElementFactory.library(context, "l2"); 2979 LibraryElementImpl library2 = ElementFactory.library(context, "l2");
2980 LibraryElementImpl library3 = ElementFactory.library(context, "l3"); 2980 LibraryElementImpl library3 = ElementFactory.library(context, "l3");
2981 LibraryElementImpl library4 = ElementFactory.library(context, "l4"); 2981 LibraryElementImpl library4 = ElementFactory.library(context, "l4");
2982 PrefixElement prefixA = new PrefixElementImpl.forNode(AstFactory.identifier3 ("a")); 2982 PrefixElement prefixA = new PrefixElementImpl.forNode(AstFactory.identifier3 ("a"));
2983 PrefixElement prefixB = new PrefixElementImpl.forNode(AstFactory.identifier3 ("b")); 2983 PrefixElement prefixB = new PrefixElementImpl.forNode(AstFactory.identifier3 ("b"));
2984 List<ImportElementImpl> imports = [ 2984 List<ImportElementImpl> imports = [
2985 ElementFactory.importFor(library2, null, []), 2985 ElementFactory.importFor(library2, null),
2986 ElementFactory.importFor(library2, prefixB, []), 2986 ElementFactory.importFor(library2, prefixB),
2987 ElementFactory.importFor(library3, null, []), 2987 ElementFactory.importFor(library3, null),
2988 ElementFactory.importFor(library3, prefixA, []), 2988 ElementFactory.importFor(library3, prefixA),
2989 ElementFactory.importFor(library3, prefixB, []), 2989 ElementFactory.importFor(library3, prefixB),
2990 ElementFactory.importFor(library4, prefixA, [])]; 2990 ElementFactory.importFor(library4, prefixA)];
2991 library1.imports = imports; 2991 library1.imports = imports;
2992 List<LibraryElement> libraries = library1.importedLibraries; 2992 List<LibraryElement> libraries = library1.importedLibraries;
2993 expect(libraries, unorderedEquals(<LibraryElement> [library2, library3, libr ary4])); 2993 expect(libraries, unorderedEquals(<LibraryElement> [library2, library3, libr ary4]));
2994 } 2994 }
2995 2995
2996 void test_getPrefixes() { 2996 void test_getPrefixes() {
2997 AnalysisContext context = createAnalysisContext(); 2997 AnalysisContext context = createAnalysisContext();
2998 LibraryElementImpl library = ElementFactory.library(context, "l1"); 2998 LibraryElementImpl library = ElementFactory.library(context, "l1");
2999 PrefixElement prefixA = new PrefixElementImpl.forNode(AstFactory.identifier3 ("a")); 2999 PrefixElement prefixA = new PrefixElementImpl.forNode(AstFactory.identifier3 ("a"));
3000 PrefixElement prefixB = new PrefixElementImpl.forNode(AstFactory.identifier3 ("b")); 3000 PrefixElement prefixB = new PrefixElementImpl.forNode(AstFactory.identifier3 ("b"));
3001 List<ImportElementImpl> imports = [ 3001 List<ImportElementImpl> imports = [
3002 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ), 3002 ElementFactory.importFor(ElementFactory.library(context, "l2"), null),
3003 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] ), 3003 ElementFactory.importFor(ElementFactory.library(context, "l3"), null),
3004 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA, []), 3004 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA) ,
3005 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA, []), 3005 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA) ,
3006 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB, [])]; 3006 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB) ];
3007 library.imports = imports; 3007 library.imports = imports;
3008 List<PrefixElement> prefixes = library.prefixes; 3008 List<PrefixElement> prefixes = library.prefixes;
3009 expect(prefixes, hasLength(2)); 3009 expect(prefixes, hasLength(2));
3010 if (identical(prefixA, prefixes[0])) { 3010 if (identical(prefixA, prefixes[0])) {
3011 expect(prefixes[1], same(prefixB)); 3011 expect(prefixes[1], same(prefixB));
3012 } else { 3012 } else {
3013 expect(prefixes[0], same(prefixB)); 3013 expect(prefixes[0], same(prefixB));
3014 expect(prefixes[1], same(prefixA)); 3014 expect(prefixes[1], same(prefixA));
3015 } 3015 }
3016 } 3016 }
3017 3017
3018 void test_getUnits() { 3018 void test_getUnits() {
3019 AnalysisContext context = createAnalysisContext(); 3019 AnalysisContext context = createAnalysisContext();
3020 LibraryElementImpl library = ElementFactory.library(context, "test"); 3020 LibraryElementImpl library = ElementFactory.library(context, "test");
3021 CompilationUnitElement unitLib = library.definingCompilationUnit; 3021 CompilationUnitElement unitLib = library.definingCompilationUnit;
3022 CompilationUnitElementImpl unitA = ElementFactory.compilationUnit("unit_a.da rt"); 3022 CompilationUnitElementImpl unitA = ElementFactory.compilationUnit("unit_a.da rt");
3023 CompilationUnitElementImpl unitB = ElementFactory.compilationUnit("unit_b.da rt"); 3023 CompilationUnitElementImpl unitB = ElementFactory.compilationUnit("unit_b.da rt");
3024 library.parts = <CompilationUnitElement> [unitA, unitB]; 3024 library.parts = <CompilationUnitElement> [unitA, unitB];
3025 expect(library.units, unorderedEquals(<CompilationUnitElement> [unitLib, uni tA, unitB])); 3025 expect(library.units, unorderedEquals(<CompilationUnitElement> [unitLib, uni tA, unitB]));
3026 } 3026 }
3027 3027
3028 void test_getVisibleLibraries_cycle() { 3028 void test_getVisibleLibraries_cycle() {
3029 AnalysisContext context = createAnalysisContext(); 3029 AnalysisContext context = createAnalysisContext();
3030 LibraryElementImpl library = ElementFactory.library(context, "app"); 3030 LibraryElementImpl library = ElementFactory.library(context, "app");
3031 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); 3031 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3032 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(library, nu ll, [])]; 3032 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(library, nu ll)];
3033 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])]; 3033 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll)];
3034 List<LibraryElement> libraries = library.visibleLibraries; 3034 List<LibraryElement> libraries = library.visibleLibraries;
3035 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA])); 3035 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA]));
3036 } 3036 }
3037 3037
3038 void test_getVisibleLibraries_directExports() { 3038 void test_getVisibleLibraries_directExports() {
3039 AnalysisContext context = createAnalysisContext(); 3039 AnalysisContext context = createAnalysisContext();
3040 LibraryElementImpl library = ElementFactory.library(context, "app"); 3040 LibraryElementImpl library = ElementFactory.library(context, "app");
3041 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); 3041 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3042 library.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryA, [] )]; 3042 library.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryA)];
3043 List<LibraryElement> libraries = library.visibleLibraries; 3043 List<LibraryElement> libraries = library.visibleLibraries;
3044 expect(libraries, unorderedEquals(<LibraryElement> [library])); 3044 expect(libraries, unorderedEquals(<LibraryElement> [library]));
3045 } 3045 }
3046 3046
3047 void test_getVisibleLibraries_directImports() { 3047 void test_getVisibleLibraries_directImports() {
3048 AnalysisContext context = createAnalysisContext(); 3048 AnalysisContext context = createAnalysisContext();
3049 LibraryElementImpl library = ElementFactory.library(context, "app"); 3049 LibraryElementImpl library = ElementFactory.library(context, "app");
3050 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); 3050 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3051 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])]; 3051 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll)];
3052 List<LibraryElement> libraries = library.visibleLibraries; 3052 List<LibraryElement> libraries = library.visibleLibraries;
3053 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA])); 3053 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA]));
3054 } 3054 }
3055 3055
3056 void test_getVisibleLibraries_indirectExports() { 3056 void test_getVisibleLibraries_indirectExports() {
3057 AnalysisContext context = createAnalysisContext(); 3057 AnalysisContext context = createAnalysisContext();
3058 LibraryElementImpl library = ElementFactory.library(context, "app"); 3058 LibraryElementImpl library = ElementFactory.library(context, "app");
3059 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); 3059 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3060 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA"); 3060 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
3061 libraryA.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryAA, [])]; 3061 libraryA.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryAA)] ;
3062 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])]; 3062 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll)];
3063 List<LibraryElement> libraries = library.visibleLibraries; 3063 List<LibraryElement> libraries = library.visibleLibraries;
3064 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA, libra ryAA])); 3064 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA, libra ryAA]));
3065 } 3065 }
3066 3066
3067 void test_getVisibleLibraries_indirectImports() { 3067 void test_getVisibleLibraries_indirectImports() {
3068 AnalysisContext context = createAnalysisContext(); 3068 AnalysisContext context = createAnalysisContext();
3069 LibraryElementImpl library = ElementFactory.library(context, "app"); 3069 LibraryElementImpl library = ElementFactory.library(context, "app");
3070 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); 3070 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3071 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA"); 3071 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
3072 LibraryElementImpl libraryB = ElementFactory.library(context, "B"); 3072 LibraryElementImpl libraryB = ElementFactory.library(context, "B");
3073 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(libraryAA, null, [])]; 3073 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(libraryAA, null)];
3074 library.imports = <ImportElementImpl> [ 3074 library.imports = <ImportElementImpl> [
3075 ElementFactory.importFor(libraryA, null, []), 3075 ElementFactory.importFor(libraryA, null),
3076 ElementFactory.importFor(libraryB, null, [])]; 3076 ElementFactory.importFor(libraryB, null)];
3077 List<LibraryElement> libraries = library.visibleLibraries; 3077 List<LibraryElement> libraries = library.visibleLibraries;
3078 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA, libra ryAA, libraryB])); 3078 expect(libraries, unorderedEquals(<LibraryElement> [library, libraryA, libra ryAA, libraryB]));
3079 } 3079 }
3080 3080
3081 void test_getVisibleLibraries_noImports() { 3081 void test_getVisibleLibraries_noImports() {
3082 AnalysisContext context = createAnalysisContext(); 3082 AnalysisContext context = createAnalysisContext();
3083 LibraryElementImpl library = ElementFactory.library(context, "app"); 3083 LibraryElementImpl library = ElementFactory.library(context, "app");
3084 expect(library.visibleLibraries, unorderedEquals(<LibraryElement> [library]) ); 3084 expect(library.visibleLibraries, unorderedEquals(<LibraryElement> [library]) );
3085 } 3085 }
3086 3086
3087 void test_isUpToDate() { 3087 void test_isUpToDate() {
3088 AnalysisContext context = createAnalysisContext(); 3088 AnalysisContext context = createAnalysisContext();
3089 context.sourceFactory = new SourceFactory([]); 3089 context.sourceFactory = new SourceFactory([]);
3090 LibraryElement library = ElementFactory.library(context, "foo"); 3090 LibraryElement library = ElementFactory.library(context, "foo");
3091 context.setContents(library.definingCompilationUnit.source, "sdfsdff"); 3091 context.setContents(library.definingCompilationUnit.source, "sdfsdff");
3092 // Assert that we are not up to date if the target has an old time stamp. 3092 // Assert that we are not up to date if the target has an old time stamp.
3093 expect(library.isUpToDate(0), isFalse); 3093 expect(library.isUpToDate(0), isFalse);
3094 // Assert that we are up to date with a target modification time in the futu re. 3094 // Assert that we are up to date with a target modification time in the futu re.
3095 expect(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000), isTrue); 3095 expect(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000), isTrue);
3096 } 3096 }
3097 3097
3098 void test_setImports() { 3098 void test_setImports() {
3099 AnalysisContext context = createAnalysisContext(); 3099 AnalysisContext context = createAnalysisContext();
3100 LibraryElementImpl library = new LibraryElementImpl.forNode(context, AstFact ory.libraryIdentifier2(["l1"])); 3100 LibraryElementImpl library = new LibraryElementImpl.forNode(context, AstFact ory.libraryIdentifier2(["l1"]));
3101 List<ImportElementImpl> expectedImports = [ 3101 List<ImportElementImpl> expectedImports = [
3102 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ), 3102 ElementFactory.importFor(ElementFactory.library(context, "l2"), null),
3103 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] )]; 3103 ElementFactory.importFor(ElementFactory.library(context, "l3"), null)];
3104 library.imports = expectedImports; 3104 library.imports = expectedImports;
3105 List<ImportElement> actualImports = library.imports; 3105 List<ImportElement> actualImports = library.imports;
3106 expect(actualImports, hasLength(expectedImports.length)); 3106 expect(actualImports, hasLength(expectedImports.length));
3107 for (int i = 0; i < actualImports.length; i++) { 3107 for (int i = 0; i < actualImports.length; i++) {
3108 expect(actualImports[i], same(expectedImports[i])); 3108 expect(actualImports[i], same(expectedImports[i]));
3109 } 3109 }
3110 } 3110 }
3111 } 3111 }
3112 3112
3113 class MultiplyDefinedElementImplTest extends EngineTestCase { 3113 class MultiplyDefinedElementImplTest extends EngineTestCase {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 } 3161 }
3162 3162
3163 void test_isMoreSpecificThan_typeArguments_object() { 3163 void test_isMoreSpecificThan_typeArguments_object() {
3164 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF actory.identifier3("E")); 3164 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF actory.identifier3("E"));
3165 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 3165 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
3166 // E << Object 3166 // E << Object
3167 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue); 3167 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue);
3168 } 3168 }
3169 3169
3170 void test_isMoreSpecificThan_typeArguments_resursive() { 3170 void test_isMoreSpecificThan_typeArguments_resursive() {
3171 ClassElementImpl classS = ElementFactory.classElement2("A", []); 3171 ClassElementImpl classS = ElementFactory.classElement2("A");
3172 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("U")); 3172 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("U"));
3173 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU); 3173 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
3174 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T")); 3174 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T"));
3175 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT); 3175 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
3176 typeParameterT.bound = typeParameterTypeU; 3176 typeParameterT.bound = typeParameterTypeU;
3177 typeParameterU.bound = typeParameterTypeU; 3177 typeParameterU.bound = typeParameterTypeU;
3178 // <T extends U> and <U extends T> 3178 // <T extends U> and <U extends T>
3179 // T << S 3179 // T << S
3180 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isFalse); 3180 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isFalse);
3181 } 3181 }
3182 3182
3183 void test_isMoreSpecificThan_typeArguments_self() { 3183 void test_isMoreSpecificThan_typeArguments_self() {
3184 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF actory.identifier3("E")); 3184 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF actory.identifier3("E"));
3185 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 3185 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
3186 // E << E 3186 // E << E
3187 expect(type.isMoreSpecificThan(type), isTrue); 3187 expect(type.isMoreSpecificThan(type), isTrue);
3188 } 3188 }
3189 3189
3190 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() { 3190 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() {
3191 // class A {} 3191 // class A {}
3192 // class B extends A {} 3192 // class B extends A {}
3193 // 3193 //
3194 ClassElement classA = ElementFactory.classElement2("A", []); 3194 ClassElement classA = ElementFactory.classElement2("A");
3195 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 3195 ClassElement classB = ElementFactory.classElement("B", classA.type);
3196 InterfaceType typeA = classA.type; 3196 InterfaceType typeA = classA.type;
3197 InterfaceType typeB = classB.type; 3197 InterfaceType typeB = classB.type;
3198 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T")); 3198 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T"));
3199 typeParameterT.bound = typeB; 3199 typeParameterT.bound = typeB;
3200 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT); 3200 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
3201 // <T extends B> 3201 // <T extends B>
3202 // T << A 3202 // T << A
3203 expect(typeParameterTypeT.isMoreSpecificThan(typeA), isTrue); 3203 expect(typeParameterTypeT.isMoreSpecificThan(typeA), isTrue);
3204 } 3204 }
3205 3205
3206 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() { 3206 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() {
3207 ClassElementImpl classS = ElementFactory.classElement2("A", []); 3207 ClassElementImpl classS = ElementFactory.classElement2("A");
3208 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("U")); 3208 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("U"));
3209 typeParameterU.bound = classS.type; 3209 typeParameterU.bound = classS.type;
3210 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU); 3210 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
3211 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T")); 3211 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T"));
3212 typeParameterT.bound = typeParameterTypeU; 3212 typeParameterT.bound = typeParameterTypeU;
3213 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT); 3213 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
3214 // <T extends U> and <U extends S> 3214 // <T extends U> and <U extends S>
3215 // T << S 3215 // T << S
3216 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); 3216 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue);
3217 } 3217 }
3218 3218
3219 void test_isMoreSpecificThan_typeArguments_upperBound() { 3219 void test_isMoreSpecificThan_typeArguments_upperBound() {
3220 ClassElementImpl classS = ElementFactory.classElement2("A", []); 3220 ClassElementImpl classS = ElementFactory.classElement2("A");
3221 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T")); 3221 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo de(AstFactory.identifier3("T"));
3222 typeParameterT.bound = classS.type; 3222 typeParameterT.bound = classS.type;
3223 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT); 3223 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
3224 // <T extends S> 3224 // <T extends S>
3225 // T << S 3225 // T << S
3226 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); 3226 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue);
3227 } 3227 }
3228 3228
3229 void test_substitute_equal() { 3229 void test_substitute_equal() {
3230 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF actory.identifier3("E")); 3230 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF actory.identifier3("E"));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3394 expect(_uAB.displayName, s); 3394 expect(_uAB.displayName, s);
3395 } 3395 }
3396 3396
3397 void test_toString_singleton() { 3397 void test_toString_singleton() {
3398 // Singleton unions collapse to the the single type. 3398 // Singleton unions collapse to the the single type.
3399 expect(_uA.toString(), "A"); 3399 expect(_uA.toString(), "A");
3400 } 3400 }
3401 3401
3402 void test_unionTypeIsLessSpecificThan_function() { 3402 void test_unionTypeIsLessSpecificThan_function() {
3403 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg s]. 3403 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg s].
3404 ClassElement a = ElementFactory.classElement2("A", []); 3404 ClassElement a = ElementFactory.classElement2("A");
3405 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 3405 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
3406 DartType uAT = UnionTypeImpl.union([_uA, t]); 3406 DartType uAT = UnionTypeImpl.union([_uA, t]);
3407 expect(t.isMoreSpecificThan(uAT), isTrue); 3407 expect(t.isMoreSpecificThan(uAT), isTrue);
3408 expect(t.isMoreSpecificThan(_uAB), isFalse); 3408 expect(t.isMoreSpecificThan(_uAB), isFalse);
3409 } 3409 }
3410 3410
3411 void test_unionTypeIsSuperTypeOf_function() { 3411 void test_unionTypeIsSuperTypeOf_function() {
3412 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg s]. 3412 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg s].
3413 ClassElement a = ElementFactory.classElement2("A", []); 3413 ClassElement a = ElementFactory.classElement2("A");
3414 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 3414 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
3415 DartType uAT = UnionTypeImpl.union([_uA, t]); 3415 DartType uAT = UnionTypeImpl.union([_uA, t]);
3416 expect(t.isSubtypeOf(uAT), isTrue); 3416 expect(t.isSubtypeOf(uAT), isTrue);
3417 expect(t.isSubtypeOf(_uAB), isFalse); 3417 expect(t.isSubtypeOf(_uAB), isFalse);
3418 } 3418 }
3419 3419
3420 @override 3420 @override
3421 void setUp() { 3421 void setUp() {
3422 super.setUp(); 3422 super.setUp();
3423 _classA = ElementFactory.classElement2("A", []); 3423 _classA = ElementFactory.classElement2("A");
3424 _typeA = _classA.type; 3424 _typeA = _classA.type;
3425 _classB = ElementFactory.classElement("B", _typeA, []); 3425 _classB = ElementFactory.classElement("B", _typeA);
3426 _typeB = _classB.type; 3426 _typeB = _classB.type;
3427 _uA = UnionTypeImpl.union([_typeA]); 3427 _uA = UnionTypeImpl.union([_typeA]);
3428 _uB = UnionTypeImpl.union([_typeB]); 3428 _uB = UnionTypeImpl.union([_typeB]);
3429 _uAB = UnionTypeImpl.union([_typeA, _typeB]); 3429 _uAB = UnionTypeImpl.union([_typeA, _typeB]);
3430 _uBA = UnionTypeImpl.union([_typeB, _typeA]); 3430 _uBA = UnionTypeImpl.union([_typeB, _typeA]);
3431 _us = <DartType> [_uA, _uB, _uAB, _uBA]; 3431 _us = <DartType> [_uA, _uB, _uAB, _uBA];
3432 } 3432 }
3433 } 3433 }
3434 3434
3435 class VoidTypeImplTest extends EngineTestCase { 3435 class VoidTypeImplTest extends EngineTestCase {
3436 /** 3436 /**
3437 * Reference {code VoidTypeImpl.getInstance()}. 3437 * Reference {code VoidTypeImpl.getInstance()}.
3438 */ 3438 */
3439 DartType _voidType = VoidTypeImpl.instance; 3439 DartType _voidType = VoidTypeImpl.instance;
3440 3440
3441 void test_isMoreSpecificThan_void_A() { 3441 void test_isMoreSpecificThan_void_A() {
3442 ClassElement classA = ElementFactory.classElement2("A", []); 3442 ClassElement classA = ElementFactory.classElement2("A");
3443 expect(_voidType.isMoreSpecificThan(classA.type), isFalse); 3443 expect(_voidType.isMoreSpecificThan(classA.type), isFalse);
3444 } 3444 }
3445 3445
3446 void test_isMoreSpecificThan_void_dynamic() { 3446 void test_isMoreSpecificThan_void_dynamic() {
3447 expect(_voidType.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); 3447 expect(_voidType.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue);
3448 } 3448 }
3449 3449
3450 void test_isMoreSpecificThan_void_void() { 3450 void test_isMoreSpecificThan_void_void() {
3451 expect(_voidType.isMoreSpecificThan(_voidType), isTrue); 3451 expect(_voidType.isMoreSpecificThan(_voidType), isTrue);
3452 } 3452 }
3453 3453
3454 void test_isSubtypeOf_void_A() { 3454 void test_isSubtypeOf_void_A() {
3455 ClassElement classA = ElementFactory.classElement2("A", []); 3455 ClassElement classA = ElementFactory.classElement2("A");
3456 expect(_voidType.isSubtypeOf(classA.type), isFalse); 3456 expect(_voidType.isSubtypeOf(classA.type), isFalse);
3457 } 3457 }
3458 3458
3459 void test_isSubtypeOf_void_dynamic() { 3459 void test_isSubtypeOf_void_dynamic() {
3460 expect(_voidType.isSubtypeOf(DynamicTypeImpl.instance), isTrue); 3460 expect(_voidType.isSubtypeOf(DynamicTypeImpl.instance), isTrue);
3461 } 3461 }
3462 3462
3463 void test_isSubtypeOf_void_void() { 3463 void test_isSubtypeOf_void_void() {
3464 expect(_voidType.isSubtypeOf(_voidType), isTrue); 3464 expect(_voidType.isSubtypeOf(_voidType), isTrue);
3465 } 3465 }
(...skipping 13 matching lines...) Expand all
3479 runReflectiveTests(UnionTypeImplTest); 3479 runReflectiveTests(UnionTypeImplTest);
3480 runReflectiveTests(VoidTypeImplTest); 3480 runReflectiveTests(VoidTypeImplTest);
3481 runReflectiveTests(ClassElementImplTest); 3481 runReflectiveTests(ClassElementImplTest);
3482 runReflectiveTests(CompilationUnitElementImplTest); 3482 runReflectiveTests(CompilationUnitElementImplTest);
3483 runReflectiveTests(ElementLocationImplTest); 3483 runReflectiveTests(ElementLocationImplTest);
3484 runReflectiveTests(ElementImplTest); 3484 runReflectiveTests(ElementImplTest);
3485 runReflectiveTests(HtmlElementImplTest); 3485 runReflectiveTests(HtmlElementImplTest);
3486 runReflectiveTests(LibraryElementImplTest); 3486 runReflectiveTests(LibraryElementImplTest);
3487 runReflectiveTests(MultiplyDefinedElementImplTest); 3487 runReflectiveTests(MultiplyDefinedElementImplTest);
3488 } 3488 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/ast_test.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698