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

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

Issue 2625783002: Explicitly compute analysis results for sources to check errors. (Closed)
Patch Set: Rollback await(ing) of assertErrors(). Format. Created 3 years, 11 months 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
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 library analyzer.test.generated.non_error_resolver_test; 5 library analyzer.test.generated.non_error_resolver_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 28
29 @reflectiveTest 29 @reflectiveTest
30 class NonErrorResolverTest extends ResolverTestCase { 30 class NonErrorResolverTest extends ResolverTestCase {
31 fail_undefinedEnumConstant() async { 31 fail_undefinedEnumConstant() async {
32 Source source = addSource(r''' 32 Source source = addSource(r'''
33 enum E { ONE } 33 enum E { ONE }
34 E e() { 34 E e() {
35 return E.TWO; 35 return E.TWO;
36 }'''); 36 }''');
37 await assertNoErrors(source); 37 await computeAnalysisResult(source);
38 assertNoErrors(source);
38 verify([source]); 39 verify([source]);
39 } 40 }
40 41
41 test_abstractSuperMemberReference_superHasConcrete_mixinHasAbstract_method() a sync { 42 test_abstractSuperMemberReference_superHasConcrete_mixinHasAbstract_method() a sync {
42 Source source = addSource(''' 43 Source source = addSource('''
43 class A { 44 class A {
44 void method() {} 45 void method() {}
45 } 46 }
46 47
47 abstract class B { 48 abstract class B {
48 void method(); 49 void method();
49 } 50 }
50 51
51 class C extends A with B { 52 class C extends A with B {
52 void method() { 53 void method() {
53 super.method(); 54 super.method();
54 } 55 }
55 } 56 }
56 '''); 57 ''');
57 await assertNoErrors(source); 58 await computeAnalysisResult(source);
59 assertNoErrors(source);
58 verify([source]); 60 verify([source]);
59 } 61 }
60 62
61 test_abstractSuperMemberReference_superHasNoSuchMethod() async { 63 test_abstractSuperMemberReference_superHasNoSuchMethod() async {
62 Source source = addSource(''' 64 Source source = addSource('''
63 abstract class A { 65 abstract class A {
64 int m(); 66 int m();
65 noSuchMethod(_) => 42; 67 noSuchMethod(_) => 42;
66 } 68 }
67 69
68 class B extends A { 70 class B extends A {
69 int m() => super.m(); 71 int m() => super.m();
70 } 72 }
71 '''); 73 ''');
72 await assertNoErrors(source); 74 await computeAnalysisResult(source);
75 assertNoErrors(source);
73 verify([source]); 76 verify([source]);
74 } 77 }
75 78
76 test_abstractSuperMemberReference_superSuperHasConcrete_getter() async { 79 test_abstractSuperMemberReference_superSuperHasConcrete_getter() async {
77 Source source = addSource(''' 80 Source source = addSource('''
78 abstract class A { 81 abstract class A {
79 int get m => 0; 82 int get m => 0;
80 } 83 }
81 84
82 abstract class B extends A { 85 abstract class B extends A {
83 int get m; 86 int get m;
84 } 87 }
85 88
86 class C extends B { 89 class C extends B {
87 int get m => super.m; 90 int get m => super.m;
88 } 91 }
89 '''); 92 ''');
90 await assertNoErrors(source); 93 await computeAnalysisResult(source);
94 assertNoErrors(source);
91 verify([source]); 95 verify([source]);
92 } 96 }
93 97
94 test_abstractSuperMemberReference_superSuperHasConcrete_method() async { 98 test_abstractSuperMemberReference_superSuperHasConcrete_method() async {
95 Source source = addSource(''' 99 Source source = addSource('''
96 void main() { 100 void main() {
97 print(new C().m()); 101 print(new C().m());
98 } 102 }
99 103
100 abstract class A { 104 abstract class A {
101 int m() => 0; 105 int m() => 0;
102 } 106 }
103 107
104 abstract class B extends A { 108 abstract class B extends A {
105 int m(); 109 int m();
106 } 110 }
107 111
108 class C extends B { 112 class C extends B {
109 int m() => super.m(); 113 int m() => super.m();
110 } 114 }
111 '''); 115 ''');
112 await assertNoErrors(source); 116 await computeAnalysisResult(source);
117 assertNoErrors(source);
113 verify([source]); 118 verify([source]);
114 } 119 }
115 120
116 test_abstractSuperMemberReference_superSuperHasConcrete_setter() async { 121 test_abstractSuperMemberReference_superSuperHasConcrete_setter() async {
117 Source source = addSource(''' 122 Source source = addSource('''
118 abstract class A { 123 abstract class A {
119 void set m(int v) {} 124 void set m(int v) {}
120 } 125 }
121 126
122 abstract class B extends A { 127 abstract class B extends A {
123 void set m(int v); 128 void set m(int v);
124 } 129 }
125 130
126 class C extends B { 131 class C extends B {
127 void set m(int v) { 132 void set m(int v) {
128 super.m = 0; 133 super.m = 0;
129 } 134 }
130 } 135 }
131 '''); 136 ''');
132 await assertNoErrors(source); 137 await computeAnalysisResult(source);
138 assertNoErrors(source);
133 verify([source]); 139 verify([source]);
134 } 140 }
135 141
136 test_ambiguousExport() async { 142 test_ambiguousExport() async {
137 Source source = addSource(r''' 143 Source source = addSource(r'''
138 library L; 144 library L;
139 export 'lib1.dart'; 145 export 'lib1.dart';
140 export 'lib2.dart';'''); 146 export 'lib2.dart';''');
141 addNamedSource( 147 addNamedSource(
142 "/lib1.dart", 148 "/lib1.dart",
143 r''' 149 r'''
144 library lib1; 150 library lib1;
145 class M {}'''); 151 class M {}''');
146 addNamedSource( 152 addNamedSource(
147 "/lib2.dart", 153 "/lib2.dart",
148 r''' 154 r'''
149 library lib2; 155 library lib2;
150 class N {}'''); 156 class N {}''');
151 await assertNoErrors(source); 157 await computeAnalysisResult(source);
158 assertNoErrors(source);
152 verify([source]); 159 verify([source]);
153 } 160 }
154 161
155 test_ambiguousExport_combinators_hide() async { 162 test_ambiguousExport_combinators_hide() async {
156 Source source = addSource(r''' 163 Source source = addSource(r'''
157 library L; 164 library L;
158 export 'lib1.dart'; 165 export 'lib1.dart';
159 export 'lib2.dart' hide B;'''); 166 export 'lib2.dart' hide B;''');
160 addNamedSource( 167 addNamedSource(
161 "/lib1.dart", 168 "/lib1.dart",
162 r''' 169 r'''
163 library L1; 170 library L1;
164 class A {} 171 class A {}
165 class B {}'''); 172 class B {}''');
166 addNamedSource( 173 addNamedSource(
167 "/lib2.dart", 174 "/lib2.dart",
168 r''' 175 r'''
169 library L2; 176 library L2;
170 class B {} 177 class B {}
171 class C {}'''); 178 class C {}''');
172 await assertNoErrors(source); 179 await computeAnalysisResult(source);
180 assertNoErrors(source);
173 verify([source]); 181 verify([source]);
174 } 182 }
175 183
176 test_ambiguousExport_combinators_show() async { 184 test_ambiguousExport_combinators_show() async {
177 Source source = addSource(r''' 185 Source source = addSource(r'''
178 library L; 186 library L;
179 export 'lib1.dart'; 187 export 'lib1.dart';
180 export 'lib2.dart' show C;'''); 188 export 'lib2.dart' show C;''');
181 addNamedSource( 189 addNamedSource(
182 "/lib1.dart", 190 "/lib1.dart",
183 r''' 191 r'''
184 library L1; 192 library L1;
185 class A {} 193 class A {}
186 class B {}'''); 194 class B {}''');
187 addNamedSource( 195 addNamedSource(
188 "/lib2.dart", 196 "/lib2.dart",
189 r''' 197 r'''
190 library L2; 198 library L2;
191 class B {} 199 class B {}
192 class C {}'''); 200 class C {}''');
193 await assertNoErrors(source); 201 await computeAnalysisResult(source);
202 assertNoErrors(source);
194 verify([source]); 203 verify([source]);
195 } 204 }
196 205
197 test_ambiguousExport_sameDeclaration() async { 206 test_ambiguousExport_sameDeclaration() async {
198 Source source = addSource(r''' 207 Source source = addSource(r'''
199 library L; 208 library L;
200 export 'lib.dart'; 209 export 'lib.dart';
201 export 'lib.dart';'''); 210 export 'lib.dart';''');
202 addNamedSource( 211 addNamedSource(
203 "/lib.dart", 212 "/lib.dart",
204 r''' 213 r'''
205 library lib; 214 library lib;
206 class N {}'''); 215 class N {}''');
207 await assertNoErrors(source); 216 await computeAnalysisResult(source);
217 assertNoErrors(source);
208 verify([source]); 218 verify([source]);
209 } 219 }
210 220
211 test_ambiguousImport_hideCombinator() async { 221 test_ambiguousImport_hideCombinator() async {
212 Source source = addSource(r''' 222 Source source = addSource(r'''
213 import 'lib1.dart'; 223 import 'lib1.dart';
214 import 'lib2.dart'; 224 import 'lib2.dart';
215 import 'lib3.dart' hide N; 225 import 'lib3.dart' hide N;
216 main() { 226 main() {
217 new N1(); 227 new N1();
(...skipping 11 matching lines...) Expand all
229 r''' 239 r'''
230 library lib2; 240 library lib2;
231 class N {} 241 class N {}
232 class N2 {}'''); 242 class N2 {}''');
233 addNamedSource( 243 addNamedSource(
234 "/lib3.dart", 244 "/lib3.dart",
235 r''' 245 r'''
236 library lib3; 246 library lib3;
237 class N {} 247 class N {}
238 class N3 {}'''); 248 class N3 {}''');
239 await assertNoErrors(source); 249 await computeAnalysisResult(source);
250 assertNoErrors(source);
240 } 251 }
241 252
242 test_ambiguousImport_showCombinator() async { 253 test_ambiguousImport_showCombinator() async {
243 Source source = addSource(r''' 254 Source source = addSource(r'''
244 import 'lib1.dart'; 255 import 'lib1.dart';
245 import 'lib2.dart' show N, N2; 256 import 'lib2.dart' show N, N2;
246 main() { 257 main() {
247 new N1(); 258 new N1();
248 new N2(); 259 new N2();
249 }'''); 260 }''');
250 addNamedSource( 261 addNamedSource(
251 "/lib1.dart", 262 "/lib1.dart",
252 r''' 263 r'''
253 library lib1; 264 library lib1;
254 class N {} 265 class N {}
255 class N1 {}'''); 266 class N1 {}''');
256 addNamedSource( 267 addNamedSource(
257 "/lib2.dart", 268 "/lib2.dart",
258 r''' 269 r'''
259 library lib2; 270 library lib2;
260 class N {} 271 class N {}
261 class N2 {}'''); 272 class N2 {}''');
262 await assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]); 273 await computeAnalysisResult(source);
274 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
263 } 275 }
264 276
265 test_annotated_partOfDeclaration() async { 277 test_annotated_partOfDeclaration() async {
266 Source source = addSource('library L; part "part.dart";'); 278 Source source = addSource('library L; part "part.dart";');
267 addNamedSource('/part.dart', '@deprecated part of L;'); 279 addNamedSource('/part.dart', '@deprecated part of L;');
268 await assertNoErrors(source); 280 await computeAnalysisResult(source);
281 assertNoErrors(source);
269 verify([source]); 282 verify([source]);
270 } 283 }
271 284
272 test_argumentTypeNotAssignable_classWithCall_Function() async { 285 test_argumentTypeNotAssignable_classWithCall_Function() async {
273 Source source = addSource(r''' 286 Source source = addSource(r'''
274 caller(Function callee) { 287 caller(Function callee) {
275 callee(); 288 callee();
276 } 289 }
277 290
278 class CallMeBack { 291 class CallMeBack {
279 call() => 0; 292 call() => 0;
280 } 293 }
281 294
282 main() { 295 main() {
283 caller(new CallMeBack()); 296 caller(new CallMeBack());
284 }'''); 297 }''');
285 await assertNoErrors(source); 298 await computeAnalysisResult(source);
299 assertNoErrors(source);
286 verify([source]); 300 verify([source]);
287 } 301 }
288 302
289 test_argumentTypeNotAssignable_fieldFormalParameterElement_member() async { 303 test_argumentTypeNotAssignable_fieldFormalParameterElement_member() async {
290 Source source = addSource(r''' 304 Source source = addSource(r'''
291 class ObjectSink<T> { 305 class ObjectSink<T> {
292 void sink(T object) { 306 void sink(T object) {
293 new TimestampedObject<T>(object); 307 new TimestampedObject<T>(object);
294 } 308 }
295 } 309 }
296 class TimestampedObject<E> { 310 class TimestampedObject<E> {
297 E object2; 311 E object2;
298 TimestampedObject(this.object2); 312 TimestampedObject(this.object2);
299 }'''); 313 }''');
300 await assertNoErrors(source); 314 await computeAnalysisResult(source);
315 assertNoErrors(source);
301 verify([source]); 316 verify([source]);
302 } 317 }
303 318
304 test_argumentTypeNotAssignable_invocation_functionParameter_generic() async { 319 test_argumentTypeNotAssignable_invocation_functionParameter_generic() async {
305 Source source = addSource(r''' 320 Source source = addSource(r'''
306 class A<K> { 321 class A<K> {
307 m(f(K k), K v) { 322 m(f(K k), K v) {
308 f(v); 323 f(v);
309 } 324 }
310 }'''); 325 }''');
311 await assertNoErrors(source); 326 await computeAnalysisResult(source);
327 assertNoErrors(source);
312 verify([source]); 328 verify([source]);
313 } 329 }
314 330
315 test_argumentTypeNotAssignable_invocation_typedef_generic() async { 331 test_argumentTypeNotAssignable_invocation_typedef_generic() async {
316 Source source = addSource(r''' 332 Source source = addSource(r'''
317 typedef A<T>(T p); 333 typedef A<T>(T p);
318 f(A<int> a) { 334 f(A<int> a) {
319 a(1); 335 a(1);
320 }'''); 336 }''');
321 await assertNoErrors(source); 337 await computeAnalysisResult(source);
338 assertNoErrors(source);
322 verify([source]); 339 verify([source]);
323 } 340 }
324 341
325 test_argumentTypeNotAssignable_Object_Function() async { 342 test_argumentTypeNotAssignable_Object_Function() async {
326 Source source = addSource(r''' 343 Source source = addSource(r'''
327 main() { 344 main() {
328 process(() {}); 345 process(() {});
329 } 346 }
330 process(Object x) {}'''); 347 process(Object x) {}''');
331 await assertNoErrors(source); 348 await computeAnalysisResult(source);
349 assertNoErrors(source);
332 verify([source]); 350 verify([source]);
333 } 351 }
334 352
335 test_argumentTypeNotAssignable_typedef_local() async { 353 test_argumentTypeNotAssignable_typedef_local() async {
336 Source source = addSource(r''' 354 Source source = addSource(r'''
337 typedef A(int p1, String p2); 355 typedef A(int p1, String p2);
338 A getA() => null; 356 A getA() => null;
339 f() { 357 f() {
340 A a = getA(); 358 A a = getA();
341 a(1, '2'); 359 a(1, '2');
342 }'''); 360 }''');
343 await assertNoErrors(source); 361 await computeAnalysisResult(source);
362 assertNoErrors(source);
344 verify([source]); 363 verify([source]);
345 } 364 }
346 365
347 test_argumentTypeNotAssignable_typedef_parameter() async { 366 test_argumentTypeNotAssignable_typedef_parameter() async {
348 Source source = addSource(r''' 367 Source source = addSource(r'''
349 typedef A(int p1, String p2); 368 typedef A(int p1, String p2);
350 f(A a) { 369 f(A a) {
351 a(1, '2'); 370 a(1, '2');
352 }'''); 371 }''');
353 await assertNoErrors(source); 372 await computeAnalysisResult(source);
373 assertNoErrors(source);
354 verify([source]); 374 verify([source]);
355 } 375 }
356 376
357 test_assert_with_message_await() async { 377 test_assert_with_message_await() async {
358 Source source = addSource(''' 378 Source source = addSource('''
359 import 'dart:async'; 379 import 'dart:async';
360 f() async { 380 f() async {
361 assert(false, await g()); 381 assert(false, await g());
362 } 382 }
363 Future<String> g() => null; 383 Future<String> g() => null;
364 '''); 384 ''');
365 await assertNoErrors(source); 385 await computeAnalysisResult(source);
386 assertNoErrors(source);
366 verify([source]); 387 verify([source]);
367 } 388 }
368 389
369 test_assert_with_message_dynamic() async { 390 test_assert_with_message_dynamic() async {
370 Source source = addSource(''' 391 Source source = addSource('''
371 f() { 392 f() {
372 assert(false, g()); 393 assert(false, g());
373 } 394 }
374 g() => null; 395 g() => null;
375 '''); 396 ''');
376 await assertNoErrors(source); 397 await computeAnalysisResult(source);
398 assertNoErrors(source);
377 verify([source]); 399 verify([source]);
378 } 400 }
379 401
380 test_assert_with_message_non_string() async { 402 test_assert_with_message_non_string() async {
381 Source source = addSource(''' 403 Source source = addSource('''
382 f() { 404 f() {
383 assert(false, 3); 405 assert(false, 3);
384 } 406 }
385 '''); 407 ''');
386 await assertNoErrors(source); 408 await computeAnalysisResult(source);
409 assertNoErrors(source);
387 verify([source]); 410 verify([source]);
388 } 411 }
389 412
390 test_assert_with_message_null() async { 413 test_assert_with_message_null() async {
391 Source source = addSource(''' 414 Source source = addSource('''
392 f() { 415 f() {
393 assert(false, null); 416 assert(false, null);
394 } 417 }
395 '''); 418 ''');
396 await assertNoErrors(source); 419 await computeAnalysisResult(source);
420 assertNoErrors(source);
397 verify([source]); 421 verify([source]);
398 } 422 }
399 423
400 test_assert_with_message_string() async { 424 test_assert_with_message_string() async {
401 Source source = addSource(''' 425 Source source = addSource('''
402 f() { 426 f() {
403 assert(false, 'message'); 427 assert(false, 'message');
404 } 428 }
405 '''); 429 ''');
406 await assertNoErrors(source); 430 await computeAnalysisResult(source);
431 assertNoErrors(source);
407 verify([source]); 432 verify([source]);
408 } 433 }
409 434
410 test_assert_with_message_suppresses_unused_var_hint() async { 435 test_assert_with_message_suppresses_unused_var_hint() async {
411 Source source = addSource(''' 436 Source source = addSource('''
412 f() { 437 f() {
413 String message = 'msg'; 438 String message = 'msg';
414 assert(true, message); 439 assert(true, message);
415 } 440 }
416 '''); 441 ''');
417 await assertNoErrors(source); 442 await computeAnalysisResult(source);
443 assertNoErrors(source);
418 verify([source]); 444 verify([source]);
419 } 445 }
420 446
421 test_assignability_function_expr_rettype_from_typedef_cls() async { 447 test_assignability_function_expr_rettype_from_typedef_cls() async {
422 // In the code below, the type of (() => f()) has a return type which is 448 // In the code below, the type of (() => f()) has a return type which is
423 // a class, and that class is inferred from the return type of the typedef 449 // a class, and that class is inferred from the return type of the typedef
424 // F. 450 // F.
425 Source source = addSource(''' 451 Source source = addSource('''
426 class C {} 452 class C {}
427 typedef C F(); 453 typedef C F();
428 F f; 454 F f;
429 main() { 455 main() {
430 F f2 = (() => f()); 456 F f2 = (() => f());
431 } 457 }
432 '''); 458 ''');
433 await assertNoErrors(source); 459 await computeAnalysisResult(source);
460 assertNoErrors(source);
434 verify([source]); 461 verify([source]);
435 } 462 }
436 463
437 test_assignability_function_expr_rettype_from_typedef_typedef() async { 464 test_assignability_function_expr_rettype_from_typedef_typedef() async {
438 // In the code below, the type of (() => f()) has a return type which is 465 // In the code below, the type of (() => f()) has a return type which is
439 // a typedef, and that typedef is inferred from the return type of the 466 // a typedef, and that typedef is inferred from the return type of the
440 // typedef F. 467 // typedef F.
441 Source source = addSource(''' 468 Source source = addSource('''
442 typedef G F(); 469 typedef G F();
443 typedef G(); 470 typedef G();
444 F f; 471 F f;
445 main() { 472 main() {
446 F f2 = (() => f()); 473 F f2 = (() => f());
447 } 474 }
448 '''); 475 ''');
449 await assertNoErrors(source); 476 await computeAnalysisResult(source);
477 assertNoErrors(source);
450 verify([source]); 478 verify([source]);
451 } 479 }
452 480
453 test_assignmentToFinal_prefixNegate() async { 481 test_assignmentToFinal_prefixNegate() async {
454 Source source = addSource(r''' 482 Source source = addSource(r'''
455 f() { 483 f() {
456 final x = 0; 484 final x = 0;
457 -x; 485 -x;
458 }'''); 486 }''');
459 await assertNoErrors(source); 487 await computeAnalysisResult(source);
488 assertNoErrors(source);
460 verify([source]); 489 verify([source]);
461 } 490 }
462 491
463 test_assignmentToFinalNoSetter_prefixedIdentifier() async { 492 test_assignmentToFinalNoSetter_prefixedIdentifier() async {
464 Source source = addSource(r''' 493 Source source = addSource(r'''
465 class A { 494 class A {
466 int get x => 0; 495 int get x => 0;
467 set x(v) {} 496 set x(v) {}
468 } 497 }
469 main() { 498 main() {
470 A a = new A(); 499 A a = new A();
471 a.x = 0; 500 a.x = 0;
472 }'''); 501 }''');
473 await assertNoErrors(source); 502 await computeAnalysisResult(source);
503 assertNoErrors(source);
474 verify([source]); 504 verify([source]);
475 } 505 }
476 506
477 test_assignmentToFinalNoSetter_propertyAccess() async { 507 test_assignmentToFinalNoSetter_propertyAccess() async {
478 Source source = addSource(r''' 508 Source source = addSource(r'''
479 class A { 509 class A {
480 int get x => 0; 510 int get x => 0;
481 set x(v) {} 511 set x(v) {}
482 } 512 }
483 class B { 513 class B {
484 static A a; 514 static A a;
485 } 515 }
486 main() { 516 main() {
487 B.a.x = 0; 517 B.a.x = 0;
488 }'''); 518 }''');
489 await assertNoErrors(source); 519 await computeAnalysisResult(source);
520 assertNoErrors(source);
490 verify([source]); 521 verify([source]);
491 } 522 }
492 523
493 test_assignmentToFinals_importWithPrefix() async { 524 test_assignmentToFinals_importWithPrefix() async {
494 Source source = addSource(r''' 525 Source source = addSource(r'''
495 library lib; 526 library lib;
496 import 'lib1.dart' as foo; 527 import 'lib1.dart' as foo;
497 main() { 528 main() {
498 foo.x = true; 529 foo.x = true;
499 }'''); 530 }''');
500 addNamedSource( 531 addNamedSource(
501 "/lib1.dart", 532 "/lib1.dart",
502 r''' 533 r'''
503 library lib1; 534 library lib1;
504 bool x = false;'''); 535 bool x = false;''');
505 await assertNoErrors(source); 536 await computeAnalysisResult(source);
537 assertNoErrors(source);
506 verify([source]); 538 verify([source]);
507 } 539 }
508 540
509 test_async_dynamic_with_return() async { 541 test_async_dynamic_with_return() async {
510 Source source = addSource(''' 542 Source source = addSource('''
511 dynamic f() async { 543 dynamic f() async {
512 return; 544 return;
513 } 545 }
514 '''); 546 ''');
515 await assertNoErrors(source); 547 await computeAnalysisResult(source);
548 assertNoErrors(source);
516 verify([source]); 549 verify([source]);
517 } 550 }
518 551
519 test_async_dynamic_with_return_value() async { 552 test_async_dynamic_with_return_value() async {
520 Source source = addSource(''' 553 Source source = addSource('''
521 dynamic f() async { 554 dynamic f() async {
522 return 5; 555 return 5;
523 } 556 }
524 '''); 557 ''');
525 await assertNoErrors(source); 558 await computeAnalysisResult(source);
559 assertNoErrors(source);
526 verify([source]); 560 verify([source]);
527 } 561 }
528 562
529 test_async_dynamic_without_return() async { 563 test_async_dynamic_without_return() async {
530 Source source = addSource(''' 564 Source source = addSource('''
531 dynamic f() async {} 565 dynamic f() async {}
532 '''); 566 ''');
533 await assertNoErrors(source); 567 await computeAnalysisResult(source);
568 assertNoErrors(source);
534 verify([source]); 569 verify([source]);
535 } 570 }
536 571
537 test_async_expression_function_type() async { 572 test_async_expression_function_type() async {
538 Source source = addSource(''' 573 Source source = addSource('''
539 import 'dart:async'; 574 import 'dart:async';
540 typedef Future<int> F(int i); 575 typedef Future<int> F(int i);
541 main() { 576 main() {
542 F f = (int i) async => i; 577 F f = (int i) async => i;
543 } 578 }
544 '''); 579 ''');
545 await assertNoErrors(source); 580 await computeAnalysisResult(source);
581 assertNoErrors(source);
546 verify([source]); 582 verify([source]);
547 } 583 }
548 584
549 test_async_flattened() async { 585 test_async_flattened() async {
550 Source source = addSource(''' 586 Source source = addSource('''
551 import 'dart:async'; 587 import 'dart:async';
552 typedef Future<int> CreatesFutureInt(); 588 typedef Future<int> CreatesFutureInt();
553 main() { 589 main() {
554 CreatesFutureInt createFutureInt = () async => f(); 590 CreatesFutureInt createFutureInt = () async => f();
555 Future<int> futureInt = createFutureInt(); 591 Future<int> futureInt = createFutureInt();
556 futureInt.then((int i) => print(i)); 592 futureInt.then((int i) => print(i));
557 } 593 }
558 Future<int> f() => null; 594 Future<int> f() => null;
559 '''); 595 ''');
560 await assertNoErrors(source); 596 await computeAnalysisResult(source);
597 assertNoErrors(source);
561 verify([source]); 598 verify([source]);
562 } 599 }
563 600
564 test_async_future_dynamic_with_return() async { 601 test_async_future_dynamic_with_return() async {
565 Source source = addSource(''' 602 Source source = addSource('''
566 import 'dart:async'; 603 import 'dart:async';
567 Future<dynamic> f() async { 604 Future<dynamic> f() async {
568 return; 605 return;
569 } 606 }
570 '''); 607 ''');
571 await assertNoErrors(source); 608 await computeAnalysisResult(source);
609 assertNoErrors(source);
572 verify([source]); 610 verify([source]);
573 } 611 }
574 612
575 test_async_future_dynamic_with_return_value() async { 613 test_async_future_dynamic_with_return_value() async {
576 Source source = addSource(''' 614 Source source = addSource('''
577 import 'dart:async'; 615 import 'dart:async';
578 Future<dynamic> f() async { 616 Future<dynamic> f() async {
579 return 5; 617 return 5;
580 } 618 }
581 '''); 619 ''');
582 await assertNoErrors(source); 620 await computeAnalysisResult(source);
621 assertNoErrors(source);
583 verify([source]); 622 verify([source]);
584 } 623 }
585 624
586 test_async_future_dynamic_without_return() async { 625 test_async_future_dynamic_without_return() async {
587 Source source = addSource(''' 626 Source source = addSource('''
588 import 'dart:async'; 627 import 'dart:async';
589 Future<dynamic> f() async {} 628 Future<dynamic> f() async {}
590 '''); 629 ''');
591 await assertNoErrors(source); 630 await computeAnalysisResult(source);
631 assertNoErrors(source);
592 verify([source]); 632 verify([source]);
593 } 633 }
594 634
595 test_async_future_int_with_return_future_int() async { 635 test_async_future_int_with_return_future_int() async {
596 Source source = addSource(''' 636 Source source = addSource('''
597 import 'dart:async'; 637 import 'dart:async';
598 Future<int> f() async { 638 Future<int> f() async {
599 return new Future<int>.value(5); 639 return new Future<int>.value(5);
600 } 640 }
601 '''); 641 ''');
602 await assertNoErrors(source); 642 await computeAnalysisResult(source);
643 assertNoErrors(source);
603 verify([source]); 644 verify([source]);
604 } 645 }
605 646
606 test_async_future_int_with_return_value() async { 647 test_async_future_int_with_return_value() async {
607 Source source = addSource(''' 648 Source source = addSource('''
608 import 'dart:async'; 649 import 'dart:async';
609 Future<int> f() async { 650 Future<int> f() async {
610 return 5; 651 return 5;
611 } 652 }
612 '''); 653 ''');
613 await assertNoErrors(source); 654 await computeAnalysisResult(source);
655 assertNoErrors(source);
614 verify([source]); 656 verify([source]);
615 } 657 }
616 658
617 test_async_future_null_with_return() async { 659 test_async_future_null_with_return() async {
618 Source source = addSource(''' 660 Source source = addSource('''
619 import 'dart:async'; 661 import 'dart:async';
620 Future<Null> f() async { 662 Future<Null> f() async {
621 return; 663 return;
622 } 664 }
623 '''); 665 ''');
624 await assertNoErrors(source); 666 await computeAnalysisResult(source);
667 assertNoErrors(source);
625 verify([source]); 668 verify([source]);
626 } 669 }
627 670
628 test_async_future_null_without_return() async { 671 test_async_future_null_without_return() async {
629 Source source = addSource(''' 672 Source source = addSource('''
630 import 'dart:async'; 673 import 'dart:async';
631 Future<Null> f() async {} 674 Future<Null> f() async {}
632 '''); 675 ''');
633 await assertNoErrors(source); 676 await computeAnalysisResult(source);
677 assertNoErrors(source);
634 verify([source]); 678 verify([source]);
635 } 679 }
636 680
637 test_async_future_object_with_return() async { 681 test_async_future_object_with_return() async {
638 Source source = addSource(''' 682 Source source = addSource('''
639 import 'dart:async'; 683 import 'dart:async';
640 Future<Object> f() async { 684 Future<Object> f() async {
641 return; 685 return;
642 } 686 }
643 '''); 687 ''');
644 await assertNoErrors(source); 688 await computeAnalysisResult(source);
689 assertNoErrors(source);
645 verify([source]); 690 verify([source]);
646 } 691 }
647 692
648 test_async_future_object_with_return_value() async { 693 test_async_future_object_with_return_value() async {
649 Source source = addSource(''' 694 Source source = addSource('''
650 import 'dart:async'; 695 import 'dart:async';
651 Future<Object> f() async { 696 Future<Object> f() async {
652 return 5; 697 return 5;
653 } 698 }
654 '''); 699 ''');
655 await assertNoErrors(source); 700 await computeAnalysisResult(source);
701 assertNoErrors(source);
656 verify([source]); 702 verify([source]);
657 } 703 }
658 704
659 test_async_future_object_without_return() async { 705 test_async_future_object_without_return() async {
660 Source source = addSource(''' 706 Source source = addSource('''
661 import 'dart:async'; 707 import 'dart:async';
662 Future<Object> f() async {} 708 Future<Object> f() async {}
663 '''); 709 ''');
664 await assertNoErrors(source); 710 await computeAnalysisResult(source);
711 assertNoErrors(source);
665 verify([source]); 712 verify([source]);
666 } 713 }
667 714
668 test_async_future_with_return() async { 715 test_async_future_with_return() async {
669 Source source = addSource(''' 716 Source source = addSource('''
670 import 'dart:async'; 717 import 'dart:async';
671 Future f() async { 718 Future f() async {
672 return; 719 return;
673 } 720 }
674 '''); 721 ''');
675 await assertNoErrors(source); 722 await computeAnalysisResult(source);
723 assertNoErrors(source);
676 verify([source]); 724 verify([source]);
677 } 725 }
678 726
679 test_async_future_with_return_value() async { 727 test_async_future_with_return_value() async {
680 Source source = addSource(''' 728 Source source = addSource('''
681 import 'dart:async'; 729 import 'dart:async';
682 Future f() async { 730 Future f() async {
683 return 5; 731 return 5;
684 } 732 }
685 '''); 733 ''');
686 await assertNoErrors(source); 734 await computeAnalysisResult(source);
735 assertNoErrors(source);
687 verify([source]); 736 verify([source]);
688 } 737 }
689 738
690 test_async_future_without_return() async { 739 test_async_future_without_return() async {
691 Source source = addSource(''' 740 Source source = addSource('''
692 import 'dart:async'; 741 import 'dart:async';
693 Future f() async {} 742 Future f() async {}
694 '''); 743 ''');
695 await assertNoErrors(source); 744 await computeAnalysisResult(source);
745 assertNoErrors(source);
696 verify([source]); 746 verify([source]);
697 } 747 }
698 748
699 test_async_return_flattens_futures() async { 749 test_async_return_flattens_futures() async {
700 Source source = addSource(''' 750 Source source = addSource('''
701 import 'dart:async'; 751 import 'dart:async';
702 Future<int> f() async { 752 Future<int> f() async {
703 return g(); 753 return g();
704 } 754 }
705 Future<Future<int>> g() => null; 755 Future<Future<int>> g() => null;
706 '''); 756 ''');
707 await assertNoErrors(source); 757 await computeAnalysisResult(source);
758 assertNoErrors(source);
708 verify([source]); 759 verify([source]);
709 } 760 }
710 761
711 test_async_with_return() async { 762 test_async_with_return() async {
712 Source source = addSource(''' 763 Source source = addSource('''
713 f() async { 764 f() async {
714 return; 765 return;
715 } 766 }
716 '''); 767 ''');
717 await assertNoErrors(source); 768 await computeAnalysisResult(source);
769 assertNoErrors(source);
718 verify([source]); 770 verify([source]);
719 } 771 }
720 772
721 test_async_with_return_value() async { 773 test_async_with_return_value() async {
722 Source source = addSource(''' 774 Source source = addSource('''
723 f() async { 775 f() async {
724 return 5; 776 return 5;
725 } 777 }
726 '''); 778 ''');
727 await assertNoErrors(source); 779 await computeAnalysisResult(source);
780 assertNoErrors(source);
728 verify([source]); 781 verify([source]);
729 } 782 }
730 783
731 test_async_without_return() async { 784 test_async_without_return() async {
732 Source source = addSource(''' 785 Source source = addSource('''
733 f() async {} 786 f() async {}
734 '''); 787 ''');
735 await assertNoErrors(source); 788 await computeAnalysisResult(source);
789 assertNoErrors(source);
736 verify([source]); 790 verify([source]);
737 } 791 }
738 792
739 test_asyncForInWrongContext_async() async { 793 test_asyncForInWrongContext_async() async {
740 Source source = addSource(r''' 794 Source source = addSource(r'''
741 f(list) async { 795 f(list) async {
742 await for (var e in list) { 796 await for (var e in list) {
743 } 797 }
744 }'''); 798 }''');
745 await assertNoErrors(source); 799 await computeAnalysisResult(source);
800 assertNoErrors(source);
746 verify([source]); 801 verify([source]);
747 } 802 }
748 803
749 test_asyncForInWrongContext_asyncStar() async { 804 test_asyncForInWrongContext_asyncStar() async {
750 Source source = addSource(r''' 805 Source source = addSource(r'''
751 f(list) async* { 806 f(list) async* {
752 await for (var e in list) { 807 await for (var e in list) {
753 } 808 }
754 }'''); 809 }''');
755 await assertNoErrors(source); 810 await computeAnalysisResult(source);
811 assertNoErrors(source);
756 verify([source]); 812 verify([source]);
757 } 813 }
758 814
759 test_await_flattened() async { 815 test_await_flattened() async {
760 Source source = addSource(''' 816 Source source = addSource('''
761 import 'dart:async'; 817 import 'dart:async';
762 Future<Future<int>> ffi() => null; 818 Future<Future<int>> ffi() => null;
763 f() async { 819 f() async {
764 int b = await ffi(); 820 int b = await ffi();
765 } 821 }
766 '''); 822 ''');
767 await assertNoErrors(source); 823 await computeAnalysisResult(source);
824 assertNoErrors(source);
768 verify([source]); 825 verify([source]);
769 } 826 }
770 827
771 test_await_simple() async { 828 test_await_simple() async {
772 Source source = addSource(''' 829 Source source = addSource('''
773 import 'dart:async'; 830 import 'dart:async';
774 Future<int> fi() => null; 831 Future<int> fi() => null;
775 f() async { 832 f() async {
776 int a = await fi(); 833 int a = await fi();
777 } 834 }
778 '''); 835 ''');
779 await assertNoErrors(source); 836 await computeAnalysisResult(source);
837 assertNoErrors(source);
780 verify([source]); 838 verify([source]);
781 } 839 }
782 840
783 test_awaitInWrongContext_async() async { 841 test_awaitInWrongContext_async() async {
784 Source source = addSource(r''' 842 Source source = addSource(r'''
785 f(x, y) async { 843 f(x, y) async {
786 return await x + await y; 844 return await x + await y;
787 }'''); 845 }''');
788 await assertNoErrors(source); 846 await computeAnalysisResult(source);
847 assertNoErrors(source);
789 verify([source]); 848 verify([source]);
790 } 849 }
791 850
792 test_awaitInWrongContext_asyncStar() async { 851 test_awaitInWrongContext_asyncStar() async {
793 Source source = addSource(r''' 852 Source source = addSource(r'''
794 f(x, y) async* { 853 f(x, y) async* {
795 yield await x + await y; 854 yield await x + await y;
796 }'''); 855 }''');
797 await assertNoErrors(source); 856 await computeAnalysisResult(source);
857 assertNoErrors(source);
798 verify([source]); 858 verify([source]);
799 } 859 }
800 860
801 test_breakWithoutLabelInSwitch() async { 861 test_breakWithoutLabelInSwitch() async {
802 Source source = addSource(r''' 862 Source source = addSource(r'''
803 class A { 863 class A {
804 void m(int i) { 864 void m(int i) {
805 switch (i) { 865 switch (i) {
806 case 0: 866 case 0:
807 break; 867 break;
808 } 868 }
809 } 869 }
810 }'''); 870 }''');
811 await assertNoErrors(source); 871 await computeAnalysisResult(source);
872 assertNoErrors(source);
812 verify([source]); 873 verify([source]);
813 } 874 }
814 875
815 test_bug_24539_getter() async { 876 test_bug_24539_getter() async {
816 Source source = addSource(''' 877 Source source = addSource('''
817 class C<T> { 878 class C<T> {
818 List<Foo> get x => null; 879 List<Foo> get x => null;
819 } 880 }
820 881
821 typedef Foo(param); 882 typedef Foo(param);
822 '''); 883 ''');
823 await assertNoErrors(source); 884 await computeAnalysisResult(source);
885 assertNoErrors(source);
824 verify([source]); 886 verify([source]);
825 } 887 }
826 888
827 test_bug_24539_setter() async { 889 test_bug_24539_setter() async {
828 Source source = addSource(''' 890 Source source = addSource('''
829 class C<T> { 891 class C<T> {
830 void set x(List<Foo> value) {} 892 void set x(List<Foo> value) {}
831 } 893 }
832 894
833 typedef Foo(param); 895 typedef Foo(param);
834 '''); 896 ''');
835 await assertNoErrors(source); 897 await computeAnalysisResult(source);
898 assertNoErrors(source);
836 verify([source]); 899 verify([source]);
837 } 900 }
838 901
839 test_builtInIdentifierAsType_dynamic() async { 902 test_builtInIdentifierAsType_dynamic() async {
840 Source source = addSource(r''' 903 Source source = addSource(r'''
841 f() { 904 f() {
842 dynamic x; 905 dynamic x;
843 }'''); 906 }''');
844 await assertNoErrors(source); 907 await computeAnalysisResult(source);
908 assertNoErrors(source);
845 verify([source]); 909 verify([source]);
846 } 910 }
847 911
848 test_caseBlockNotTerminated() async { 912 test_caseBlockNotTerminated() async {
849 Source source = addSource(r''' 913 Source source = addSource(r'''
850 f(int p) { 914 f(int p) {
851 for (int i = 0; i < 10; i++) { 915 for (int i = 0; i < 10; i++) {
852 switch (p) { 916 switch (p) {
853 case 0: 917 case 0:
854 break; 918 break;
855 case 1: 919 case 1:
856 continue; 920 continue;
857 case 2: 921 case 2:
858 return; 922 return;
859 case 3: 923 case 3:
860 throw new Object(); 924 throw new Object();
861 case 4: 925 case 4:
862 case 5: 926 case 5:
863 return; 927 return;
864 case 6: 928 case 6:
865 default: 929 default:
866 return; 930 return;
867 } 931 }
868 } 932 }
869 }'''); 933 }''');
870 await assertNoErrors(source); 934 await computeAnalysisResult(source);
935 assertNoErrors(source);
871 verify([source]); 936 verify([source]);
872 } 937 }
873 938
874 test_caseBlockNotTerminated_lastCase() async { 939 test_caseBlockNotTerminated_lastCase() async {
875 Source source = addSource(r''' 940 Source source = addSource(r'''
876 f(int p) { 941 f(int p) {
877 switch (p) { 942 switch (p) {
878 case 0: 943 case 0:
879 p = p + 1; 944 p = p + 1;
880 } 945 }
881 }'''); 946 }''');
882 await assertNoErrors(source); 947 await computeAnalysisResult(source);
948 assertNoErrors(source);
883 verify([source]); 949 verify([source]);
884 } 950 }
885 951
886 test_caseExpressionTypeImplementsEquals() async { 952 test_caseExpressionTypeImplementsEquals() async {
887 Source source = addSource(r''' 953 Source source = addSource(r'''
888 print(p) {} 954 print(p) {}
889 955
890 abstract class B { 956 abstract class B {
891 final id; 957 final id;
892 const B(this.id); 958 const B(this.id);
893 String toString() => 'C($id)'; 959 String toString() => 'C($id)';
894 /** Equality is identity equality, the id isn't used. */ 960 /** Equality is identity equality, the id isn't used. */
895 bool operator==(Object other); 961 bool operator==(Object other);
896 } 962 }
897 963
898 class C extends B { 964 class C extends B {
899 const C(id) : super(id); 965 const C(id) : super(id);
900 } 966 }
901 967
902 void doSwitch(c) { 968 void doSwitch(c) {
903 switch (c) { 969 switch (c) {
904 case const C(0): print('Switch: 0'); break; 970 case const C(0): print('Switch: 0'); break;
905 case const C(1): print('Switch: 1'); break; 971 case const C(1): print('Switch: 1'); break;
906 } 972 }
907 }'''); 973 }''');
908 await assertNoErrors(source); 974 await computeAnalysisResult(source);
975 assertNoErrors(source);
909 verify([source]); 976 verify([source]);
910 } 977 }
911 978
912 test_caseExpressionTypeImplementsEquals_int() async { 979 test_caseExpressionTypeImplementsEquals_int() async {
913 Source source = addSource(r''' 980 Source source = addSource(r'''
914 f(int i) { 981 f(int i) {
915 switch(i) { 982 switch(i) {
916 case(1) : return 1; 983 case(1) : return 1;
917 default: return 0; 984 default: return 0;
918 } 985 }
919 }'''); 986 }''');
920 await assertNoErrors(source); 987 await computeAnalysisResult(source);
988 assertNoErrors(source);
921 verify([source]); 989 verify([source]);
922 } 990 }
923 991
924 test_caseExpressionTypeImplementsEquals_Object() async { 992 test_caseExpressionTypeImplementsEquals_Object() async {
925 Source source = addSource(r''' 993 Source source = addSource(r'''
926 class IntWrapper { 994 class IntWrapper {
927 final int value; 995 final int value;
928 const IntWrapper(this.value); 996 const IntWrapper(this.value);
929 } 997 }
930 998
931 f(IntWrapper intWrapper) { 999 f(IntWrapper intWrapper) {
932 switch(intWrapper) { 1000 switch(intWrapper) {
933 case(const IntWrapper(1)) : return 1; 1001 case(const IntWrapper(1)) : return 1;
934 default: return 0; 1002 default: return 0;
935 } 1003 }
936 }'''); 1004 }''');
937 await assertNoErrors(source); 1005 await computeAnalysisResult(source);
1006 assertNoErrors(source);
938 verify([source]); 1007 verify([source]);
939 } 1008 }
940 1009
941 test_caseExpressionTypeImplementsEquals_String() async { 1010 test_caseExpressionTypeImplementsEquals_String() async {
942 Source source = addSource(r''' 1011 Source source = addSource(r'''
943 f(String s) { 1012 f(String s) {
944 switch(s) { 1013 switch(s) {
945 case('1') : return 1; 1014 case('1') : return 1;
946 default: return 0; 1015 default: return 0;
947 } 1016 }
948 }'''); 1017 }''');
949 await assertNoErrors(source); 1018 await computeAnalysisResult(source);
1019 assertNoErrors(source);
950 verify([source]); 1020 verify([source]);
951 } 1021 }
952 1022
953 test_class_type_alias_documentationComment() async { 1023 test_class_type_alias_documentationComment() async {
954 Source source = addSource(''' 1024 Source source = addSource('''
955 /** 1025 /**
956 * Documentation 1026 * Documentation
957 */ 1027 */
958 class C = D with E; 1028 class C = D with E;
959 1029
960 class D {} 1030 class D {}
961 class E {}'''); 1031 class E {}''');
962 await assertNoErrors(source); 1032 await computeAnalysisResult(source);
1033 assertNoErrors(source);
963 verify([source]); 1034 verify([source]);
964 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1035 CompilationUnit unit = await _getResolvedLibraryUnit(source);
965 ClassElement classC = 1036 ClassElement classC =
966 resolutionMap.elementDeclaredByCompilationUnit(unit).getType('C'); 1037 resolutionMap.elementDeclaredByCompilationUnit(unit).getType('C');
967 expect(classC.documentationComment, isNotNull); 1038 expect(classC.documentationComment, isNotNull);
968 } 1039 }
969 1040
970 test_commentReference_beforeConstructor() async { 1041 test_commentReference_beforeConstructor() async {
971 String code = r''' 1042 String code = r'''
972 abstract class A { 1043 abstract class A {
973 /// [p] 1044 /// [p]
974 A(int p) {} 1045 A(int p) {}
975 }'''; 1046 }''';
976 Source source = addSource(code); 1047 Source source = addSource(code);
977 await assertNoErrors(source); 1048 await computeAnalysisResult(source);
1049 assertNoErrors(source);
978 verify([source]); 1050 verify([source]);
979 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1051 CompilationUnit unit = await _getResolvedLibraryUnit(source);
980 { 1052 {
981 SimpleIdentifier ref = 1053 SimpleIdentifier ref =
982 EngineTestCase.findSimpleIdentifier(unit, code, "p]"); 1054 EngineTestCase.findSimpleIdentifier(unit, code, "p]");
983 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1055 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
984 } 1056 }
985 } 1057 }
986 1058
987 test_commentReference_beforeEnum() async { 1059 test_commentReference_beforeEnum() async {
988 String code = r''' 1060 String code = r'''
989 /// This is the [Samurai] kind. 1061 /// This is the [Samurai] kind.
990 enum Samurai { 1062 enum Samurai {
991 /// Use [int]. 1063 /// Use [int].
992 WITH_SWORD, 1064 WITH_SWORD,
993 /// Like [WITH_SWORD], but only without one. 1065 /// Like [WITH_SWORD], but only without one.
994 WITHOUT_SWORD 1066 WITHOUT_SWORD
995 }'''; 1067 }''';
996 Source source = addSource(code); 1068 Source source = addSource(code);
997 await assertNoErrors(source); 1069 await computeAnalysisResult(source);
1070 assertNoErrors(source);
998 verify([source]); 1071 verify([source]);
999 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1072 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1000 { 1073 {
1001 SimpleIdentifier ref = 1074 SimpleIdentifier ref =
1002 EngineTestCase.findSimpleIdentifier(unit, code, 'Samurai]'); 1075 EngineTestCase.findSimpleIdentifier(unit, code, 'Samurai]');
1003 ClassElement refElement = ref.staticElement; 1076 ClassElement refElement = ref.staticElement;
1004 expect(refElement, isNotNull); 1077 expect(refElement, isNotNull);
1005 expect(refElement.name, 'Samurai'); 1078 expect(refElement.name, 'Samurai');
1006 } 1079 }
1007 { 1080 {
(...skipping 11 matching lines...) Expand all
1019 expect(refElement.name, 'WITH_SWORD'); 1092 expect(refElement.name, 'WITH_SWORD');
1020 } 1093 }
1021 } 1094 }
1022 1095
1023 test_commentReference_beforeFunction_blockBody() async { 1096 test_commentReference_beforeFunction_blockBody() async {
1024 String code = r''' 1097 String code = r'''
1025 /// [p] 1098 /// [p]
1026 foo(int p) { 1099 foo(int p) {
1027 }'''; 1100 }''';
1028 Source source = addSource(code); 1101 Source source = addSource(code);
1029 await assertNoErrors(source); 1102 await computeAnalysisResult(source);
1103 assertNoErrors(source);
1030 verify([source]); 1104 verify([source]);
1031 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1105 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1032 SimpleIdentifier ref = 1106 SimpleIdentifier ref =
1033 EngineTestCase.findSimpleIdentifier(unit, code, 'p]'); 1107 EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
1034 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1108 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1035 } 1109 }
1036 1110
1037 test_commentReference_beforeFunction_expressionBody() async { 1111 test_commentReference_beforeFunction_expressionBody() async {
1038 String code = r''' 1112 String code = r'''
1039 /// [p] 1113 /// [p]
1040 foo(int p) => null;'''; 1114 foo(int p) => null;''';
1041 Source source = addSource(code); 1115 Source source = addSource(code);
1042 await assertNoErrors(source); 1116 await computeAnalysisResult(source);
1117 assertNoErrors(source);
1043 verify([source]); 1118 verify([source]);
1044 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1119 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1045 SimpleIdentifier ref = 1120 SimpleIdentifier ref =
1046 EngineTestCase.findSimpleIdentifier(unit, code, 'p]'); 1121 EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
1047 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1122 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1048 } 1123 }
1049 1124
1050 test_commentReference_beforeFunctionTypeAlias() async { 1125 test_commentReference_beforeFunctionTypeAlias() async {
1051 String code = r''' 1126 String code = r'''
1052 /// [p] 1127 /// [p]
1053 typedef Foo(int p); 1128 typedef Foo(int p);
1054 '''; 1129 ''';
1055 Source source = addSource(code); 1130 Source source = addSource(code);
1056 await assertNoErrors(source); 1131 await computeAnalysisResult(source);
1132 assertNoErrors(source);
1057 verify([source]); 1133 verify([source]);
1058 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1134 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1059 SimpleIdentifier ref = 1135 SimpleIdentifier ref =
1060 EngineTestCase.findSimpleIdentifier(unit, code, 'p]'); 1136 EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
1061 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1137 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1062 } 1138 }
1063 1139
1064 test_commentReference_beforeGetter() async { 1140 test_commentReference_beforeGetter() async {
1065 String code = r''' 1141 String code = r'''
1066 abstract class A { 1142 abstract class A {
1067 /// [int] 1143 /// [int]
1068 get g => null; 1144 get g => null;
1069 }'''; 1145 }''';
1070 Source source = addSource(code); 1146 Source source = addSource(code);
1071 await assertNoErrors(source); 1147 await computeAnalysisResult(source);
1148 assertNoErrors(source);
1072 verify([source]); 1149 verify([source]);
1073 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1150 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1074 { 1151 {
1075 SimpleIdentifier ref = 1152 SimpleIdentifier ref =
1076 EngineTestCase.findSimpleIdentifier(unit, code, 'int]'); 1153 EngineTestCase.findSimpleIdentifier(unit, code, 'int]');
1077 expect(ref.staticElement, isNotNull); 1154 expect(ref.staticElement, isNotNull);
1078 } 1155 }
1079 } 1156 }
1080 1157
1081 test_commentReference_beforeMethod() async { 1158 test_commentReference_beforeMethod() async {
1082 String code = r''' 1159 String code = r'''
1083 abstract class A { 1160 abstract class A {
1084 /// [p1] 1161 /// [p1]
1085 ma(int p1) {} 1162 ma(int p1) {}
1086 /// [p2] 1163 /// [p2]
1087 mb(int p2); 1164 mb(int p2);
1088 /// [p3] and [p4] 1165 /// [p3] and [p4]
1089 mc(int p3, p4()); 1166 mc(int p3, p4());
1090 /// [p5] 1167 /// [p5]
1091 md(int p5, {int p6}); 1168 md(int p5, {int p6});
1092 }'''; 1169 }''';
1093 Source source = addSource(code); 1170 Source source = addSource(code);
1094 await assertNoErrors(source); 1171 await computeAnalysisResult(source);
1172 assertNoErrors(source);
1095 verify([source]); 1173 verify([source]);
1096 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1174 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1097 assertIsParameter(String search) { 1175 assertIsParameter(String search) {
1098 SimpleIdentifier ref = 1176 SimpleIdentifier ref =
1099 EngineTestCase.findSimpleIdentifier(unit, code, search); 1177 EngineTestCase.findSimpleIdentifier(unit, code, search);
1100 expect(ref.staticElement, new isInstanceOf<ParameterElement>()); 1178 expect(ref.staticElement, new isInstanceOf<ParameterElement>());
1101 } 1179 }
1102 1180
1103 assertIsParameter('p1'); 1181 assertIsParameter('p1');
1104 assertIsParameter('p2'); 1182 assertIsParameter('p2');
1105 assertIsParameter('p3'); 1183 assertIsParameter('p3');
1106 assertIsParameter('p4'); 1184 assertIsParameter('p4');
1107 assertIsParameter('p5'); 1185 assertIsParameter('p5');
1108 assertIsParameter('p6'); 1186 assertIsParameter('p6');
1109 } 1187 }
1110 1188
1111 test_commentReference_class() async { 1189 test_commentReference_class() async {
1112 String code = r''' 1190 String code = r'''
1113 /// [foo] 1191 /// [foo]
1114 class A { 1192 class A {
1115 foo() {} 1193 foo() {}
1116 }'''; 1194 }''';
1117 Source source = addSource(code); 1195 Source source = addSource(code);
1118 await assertNoErrors(source); 1196 await computeAnalysisResult(source);
1197 assertNoErrors(source);
1119 verify([source]); 1198 verify([source]);
1120 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1199 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1121 SimpleIdentifier ref = 1200 SimpleIdentifier ref =
1122 EngineTestCase.findSimpleIdentifier(unit, code, 'foo]'); 1201 EngineTestCase.findSimpleIdentifier(unit, code, 'foo]');
1123 expect(ref.staticElement, new isInstanceOf<MethodElement>()); 1202 expect(ref.staticElement, new isInstanceOf<MethodElement>());
1124 } 1203 }
1125 1204
1126 test_commentReference_setter() async { 1205 test_commentReference_setter() async {
1127 String code = r''' 1206 String code = r'''
1128 class A { 1207 class A {
1129 /// [x] in A 1208 /// [x] in A
1130 mA() {} 1209 mA() {}
1131 set x(value) {} 1210 set x(value) {}
1132 } 1211 }
1133 class B extends A { 1212 class B extends A {
1134 /// [x] in B 1213 /// [x] in B
1135 mB() {} 1214 mB() {}
1136 } 1215 }
1137 '''; 1216 ''';
1138 Source source = addSource(code); 1217 Source source = addSource(code);
1139 await assertNoErrors(source); 1218 await computeAnalysisResult(source);
1219 assertNoErrors(source);
1140 verify([source]); 1220 verify([source]);
1141 CompilationUnit unit = await _getResolvedLibraryUnit(source); 1221 CompilationUnit unit = await _getResolvedLibraryUnit(source);
1142 { 1222 {
1143 SimpleIdentifier ref = 1223 SimpleIdentifier ref =
1144 EngineTestCase.findSimpleIdentifier(unit, code, "x] in A"); 1224 EngineTestCase.findSimpleIdentifier(unit, code, "x] in A");
1145 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>()); 1225 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>());
1146 } 1226 }
1147 { 1227 {
1148 SimpleIdentifier ref = 1228 SimpleIdentifier ref =
1149 EngineTestCase.findSimpleIdentifier(unit, code, 'x] in B'); 1229 EngineTestCase.findSimpleIdentifier(unit, code, 'x] in B');
1150 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>()); 1230 expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>());
1151 } 1231 }
1152 } 1232 }
1153 1233
1154 test_concreteClassWithAbstractMember() async { 1234 test_concreteClassWithAbstractMember() async {
1155 Source source = addSource(r''' 1235 Source source = addSource(r'''
1156 abstract class A { 1236 abstract class A {
1157 m(); 1237 m();
1158 }'''); 1238 }''');
1159 await assertNoErrors(source); 1239 await computeAnalysisResult(source);
1240 assertNoErrors(source);
1160 verify([source]); 1241 verify([source]);
1161 } 1242 }
1162 1243
1163 test_concreteClassWithAbstractMember_inherited() async { 1244 test_concreteClassWithAbstractMember_inherited() async {
1164 Source source = addSource(r''' 1245 Source source = addSource(r'''
1165 class A { 1246 class A {
1166 m() {} 1247 m() {}
1167 } 1248 }
1168 class B extends A { 1249 class B extends A {
1169 m(); 1250 m();
1170 }'''); 1251 }''');
1171 await assertNoErrors(source); 1252 await computeAnalysisResult(source);
1253 assertNoErrors(source);
1172 verify([source]); 1254 verify([source]);
1173 } 1255 }
1174 1256
1175 test_conflictingInstanceGetterAndSuperclassMember_instance() async { 1257 test_conflictingInstanceGetterAndSuperclassMember_instance() async {
1176 Source source = addSource(r''' 1258 Source source = addSource(r'''
1177 class A { 1259 class A {
1178 get v => 0; 1260 get v => 0;
1179 } 1261 }
1180 class B extends A { 1262 class B extends A {
1181 get v => 1; 1263 get v => 1;
1182 }'''); 1264 }''');
1183 await assertNoErrors(source); 1265 await computeAnalysisResult(source);
1266 assertNoErrors(source);
1184 verify([source]); 1267 verify([source]);
1185 } 1268 }
1186 1269
1187 test_conflictingStaticGetterAndInstanceSetter_thisClass() async { 1270 test_conflictingStaticGetterAndInstanceSetter_thisClass() async {
1188 Source source = addSource(r''' 1271 Source source = addSource(r'''
1189 class A { 1272 class A {
1190 static get x => 0; 1273 static get x => 0;
1191 static set x(int p) {} 1274 static set x(int p) {}
1192 }'''); 1275 }''');
1193 await assertNoErrors(source); 1276 await computeAnalysisResult(source);
1277 assertNoErrors(source);
1194 verify([source]); 1278 verify([source]);
1195 } 1279 }
1196 1280
1197 test_conflictingStaticSetterAndInstanceMember_thisClass_method() async { 1281 test_conflictingStaticSetterAndInstanceMember_thisClass_method() async {
1198 Source source = addSource(r''' 1282 Source source = addSource(r'''
1199 class A { 1283 class A {
1200 static x() {} 1284 static x() {}
1201 static set x(int p) {} 1285 static set x(int p) {}
1202 }'''); 1286 }''');
1203 await assertNoErrors(source); 1287 await computeAnalysisResult(source);
1288 assertNoErrors(source);
1204 verify([source]); 1289 verify([source]);
1205 } 1290 }
1206 1291
1207 test_const_constructor_with_named_generic_parameter() async { 1292 test_const_constructor_with_named_generic_parameter() async {
1208 Source source = addSource(''' 1293 Source source = addSource('''
1209 class C<T> { 1294 class C<T> {
1210 const C({T t}); 1295 const C({T t});
1211 } 1296 }
1212 const c = const C(t: 1); 1297 const c = const C(t: 1);
1213 '''); 1298 ''');
1214 await assertNoErrors(source); 1299 await computeAnalysisResult(source);
1300 assertNoErrors(source);
1215 verify([source]); 1301 verify([source]);
1216 } 1302 }
1217 1303
1218 test_const_dynamic() async { 1304 test_const_dynamic() async {
1219 Source source = addSource(''' 1305 Source source = addSource('''
1220 const Type d = dynamic; 1306 const Type d = dynamic;
1221 '''); 1307 ''');
1222 await assertNoErrors(source); 1308 await computeAnalysisResult(source);
1309 assertNoErrors(source);
1223 verify([source]); 1310 verify([source]);
1224 } 1311 }
1225 1312
1226 test_constConstructorWithNonConstSuper_explicit() async { 1313 test_constConstructorWithNonConstSuper_explicit() async {
1227 Source source = addSource(r''' 1314 Source source = addSource(r'''
1228 class A { 1315 class A {
1229 const A(); 1316 const A();
1230 } 1317 }
1231 class B extends A { 1318 class B extends A {
1232 const B(): super(); 1319 const B(): super();
1233 }'''); 1320 }''');
1234 await assertNoErrors(source); 1321 await computeAnalysisResult(source);
1322 assertNoErrors(source);
1235 verify([source]); 1323 verify([source]);
1236 } 1324 }
1237 1325
1238 test_constConstructorWithNonConstSuper_redirectingFactory() async { 1326 test_constConstructorWithNonConstSuper_redirectingFactory() async {
1239 Source source = addSource(r''' 1327 Source source = addSource(r'''
1240 class A { 1328 class A {
1241 A(); 1329 A();
1242 } 1330 }
1243 class B implements C { 1331 class B implements C {
1244 const B(); 1332 const B();
1245 } 1333 }
1246 class C extends A { 1334 class C extends A {
1247 const factory C() = B; 1335 const factory C() = B;
1248 }'''); 1336 }''');
1249 await assertNoErrors(source); 1337 await computeAnalysisResult(source);
1338 assertNoErrors(source);
1250 verify([source]); 1339 verify([source]);
1251 } 1340 }
1252 1341
1253 test_constConstructorWithNonConstSuper_unresolved() async { 1342 test_constConstructorWithNonConstSuper_unresolved() async {
1254 Source source = addSource(r''' 1343 Source source = addSource(r'''
1255 class A { 1344 class A {
1256 A.a(); 1345 A.a();
1257 } 1346 }
1258 class B extends A { 1347 class B extends A {
1259 const B(): super(); 1348 const B(): super();
1260 }'''); 1349 }''');
1261 await assertErrors(source, 1350 await computeAnalysisResult(source);
1351 assertErrors(source,
1262 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 1352 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
1263 verify([source]); 1353 verify([source]);
1264 } 1354 }
1265 1355
1266 test_constConstructorWithNonFinalField_finalInstanceVar() async { 1356 test_constConstructorWithNonFinalField_finalInstanceVar() async {
1267 Source source = addSource(r''' 1357 Source source = addSource(r'''
1268 class A { 1358 class A {
1269 final int x = 0; 1359 final int x = 0;
1270 const A(); 1360 const A();
1271 }'''); 1361 }''');
1272 await assertNoErrors(source); 1362 await computeAnalysisResult(source);
1363 assertNoErrors(source);
1273 verify([source]); 1364 verify([source]);
1274 } 1365 }
1275 1366
1276 test_constConstructorWithNonFinalField_mixin() async { 1367 test_constConstructorWithNonFinalField_mixin() async {
1277 Source source = addSource(r''' 1368 Source source = addSource(r'''
1278 class A { 1369 class A {
1279 a() {} 1370 a() {}
1280 } 1371 }
1281 class B extends Object with A { 1372 class B extends Object with A {
1282 const B(); 1373 const B();
1283 }'''); 1374 }''');
1284 await assertErrors( 1375 await computeAnalysisResult(source);
1285 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]); 1376 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]);
1286 verify([source]); 1377 verify([source]);
1287 } 1378 }
1288 1379
1289 test_constConstructorWithNonFinalField_static() async { 1380 test_constConstructorWithNonFinalField_static() async {
1290 Source source = addSource(r''' 1381 Source source = addSource(r'''
1291 class A { 1382 class A {
1292 static int x; 1383 static int x;
1293 const A(); 1384 const A();
1294 }'''); 1385 }''');
1295 await assertNoErrors(source); 1386 await computeAnalysisResult(source);
1387 assertNoErrors(source);
1296 verify([source]); 1388 verify([source]);
1297 } 1389 }
1298 1390
1299 test_constConstructorWithNonFinalField_syntheticField() async { 1391 test_constConstructorWithNonFinalField_syntheticField() async {
1300 Source source = addSource(r''' 1392 Source source = addSource(r'''
1301 class A { 1393 class A {
1302 const A(); 1394 const A();
1303 set x(value) {} 1395 set x(value) {}
1304 get x {return 0;} 1396 get x {return 0;}
1305 }'''); 1397 }''');
1306 await assertNoErrors(source); 1398 await computeAnalysisResult(source);
1399 assertNoErrors(source);
1307 verify([source]); 1400 verify([source]);
1308 } 1401 }
1309 1402
1310 test_constDeferredClass_new() async { 1403 test_constDeferredClass_new() async {
1311 await resolveWithErrors(<String>[ 1404 await resolveWithErrors(<String>[
1312 r''' 1405 r'''
1313 library lib1; 1406 library lib1;
1314 class A { 1407 class A {
1315 const A.b(); 1408 const A.b();
1316 }''', 1409 }''',
1317 r''' 1410 r'''
1318 library root; 1411 library root;
1319 import 'lib1.dart' deferred as a; 1412 import 'lib1.dart' deferred as a;
1320 main() { 1413 main() {
1321 new a.A.b(); 1414 new a.A.b();
1322 }''' 1415 }'''
1323 ], <ErrorCode>[]); 1416 ], <ErrorCode>[]);
1324 } 1417 }
1325 1418
1326 test_constEval_functionTypeLiteral() async { 1419 test_constEval_functionTypeLiteral() async {
1327 Source source = addSource(r''' 1420 Source source = addSource(r'''
1328 typedef F(); 1421 typedef F();
1329 const C = F;'''); 1422 const C = F;''');
1330 await assertNoErrors(source); 1423 await computeAnalysisResult(source);
1424 assertNoErrors(source);
1331 verify([source]); 1425 verify([source]);
1332 } 1426 }
1333 1427
1334 test_constEval_propertyExtraction_fieldStatic_targetType() async { 1428 test_constEval_propertyExtraction_fieldStatic_targetType() async {
1335 addNamedSource( 1429 addNamedSource(
1336 "/math.dart", 1430 "/math.dart",
1337 r''' 1431 r'''
1338 library math; 1432 library math;
1339 const PI = 3.14;'''); 1433 const PI = 3.14;''');
1340 Source source = addSource(r''' 1434 Source source = addSource(r'''
1341 import 'math.dart' as math; 1435 import 'math.dart' as math;
1342 const C = math.PI;'''); 1436 const C = math.PI;''');
1343 await assertNoErrors(source); 1437 await computeAnalysisResult(source);
1438 assertNoErrors(source);
1344 verify([source]); 1439 verify([source]);
1345 } 1440 }
1346 1441
1347 test_constEval_propertyExtraction_methodStatic_targetType() async { 1442 test_constEval_propertyExtraction_methodStatic_targetType() async {
1348 Source source = addSource(r''' 1443 Source source = addSource(r'''
1349 class A { 1444 class A {
1350 const A(); 1445 const A();
1351 static m() {} 1446 static m() {}
1352 } 1447 }
1353 const C = A.m;'''); 1448 const C = A.m;''');
1354 await assertNoErrors(source); 1449 await computeAnalysisResult(source);
1450 assertNoErrors(source);
1355 verify([source]); 1451 verify([source]);
1356 } 1452 }
1357 1453
1358 test_constEval_symbol() async { 1454 test_constEval_symbol() async {
1359 addNamedSource( 1455 addNamedSource(
1360 "/math.dart", 1456 "/math.dart",
1361 r''' 1457 r'''
1362 library math; 1458 library math;
1363 const PI = 3.14;'''); 1459 const PI = 3.14;''');
1364 Source source = addSource(r''' 1460 Source source = addSource(r'''
1365 const C = #foo; 1461 const C = #foo;
1366 foo() {}'''); 1462 foo() {}''');
1367 await assertNoErrors(source); 1463 await computeAnalysisResult(source);
1464 assertNoErrors(source);
1368 verify([source]); 1465 verify([source]);
1369 } 1466 }
1370 1467
1371 test_constEvalTypeBoolNumString_equal() async { 1468 test_constEvalTypeBoolNumString_equal() async {
1372 Source source = addSource(r''' 1469 Source source = addSource(r'''
1373 class A { 1470 class A {
1374 const A(); 1471 const A();
1375 } 1472 }
1376 class B { 1473 class B {
1377 final v; 1474 final v;
1378 const B.a1(bool p) : v = p == true; 1475 const B.a1(bool p) : v = p == true;
1379 const B.a2(bool p) : v = p == false; 1476 const B.a2(bool p) : v = p == false;
1380 const B.a3(bool p) : v = p == 0; 1477 const B.a3(bool p) : v = p == 0;
1381 const B.a4(bool p) : v = p == 0.0; 1478 const B.a4(bool p) : v = p == 0.0;
1382 const B.a5(bool p) : v = p == ''; 1479 const B.a5(bool p) : v = p == '';
1383 const B.b1(int p) : v = p == true; 1480 const B.b1(int p) : v = p == true;
1384 const B.b2(int p) : v = p == false; 1481 const B.b2(int p) : v = p == false;
1385 const B.b3(int p) : v = p == 0; 1482 const B.b3(int p) : v = p == 0;
1386 const B.b4(int p) : v = p == 0.0; 1483 const B.b4(int p) : v = p == 0.0;
1387 const B.b5(int p) : v = p == ''; 1484 const B.b5(int p) : v = p == '';
1388 const B.c1(String p) : v = p == true; 1485 const B.c1(String p) : v = p == true;
1389 const B.c2(String p) : v = p == false; 1486 const B.c2(String p) : v = p == false;
1390 const B.c3(String p) : v = p == 0; 1487 const B.c3(String p) : v = p == 0;
1391 const B.c4(String p) : v = p == 0.0; 1488 const B.c4(String p) : v = p == 0.0;
1392 const B.c5(String p) : v = p == ''; 1489 const B.c5(String p) : v = p == '';
1393 const B.n1(num p) : v = p == null; 1490 const B.n1(num p) : v = p == null;
1394 const B.n2(num p) : v = null == p; 1491 const B.n2(num p) : v = null == p;
1395 }'''); 1492 }''');
1396 await assertNoErrors(source); 1493 await computeAnalysisResult(source);
1494 assertNoErrors(source);
1397 } 1495 }
1398 1496
1399 test_constEvalTypeBoolNumString_notEqual() async { 1497 test_constEvalTypeBoolNumString_notEqual() async {
1400 Source source = addSource(r''' 1498 Source source = addSource(r'''
1401 class A { 1499 class A {
1402 const A(); 1500 const A();
1403 } 1501 }
1404 class B { 1502 class B {
1405 final v; 1503 final v;
1406 const B.a1(bool p) : v = p != true; 1504 const B.a1(bool p) : v = p != true;
1407 const B.a2(bool p) : v = p != false; 1505 const B.a2(bool p) : v = p != false;
1408 const B.a3(bool p) : v = p != 0; 1506 const B.a3(bool p) : v = p != 0;
1409 const B.a4(bool p) : v = p != 0.0; 1507 const B.a4(bool p) : v = p != 0.0;
1410 const B.a5(bool p) : v = p != ''; 1508 const B.a5(bool p) : v = p != '';
1411 const B.b1(int p) : v = p != true; 1509 const B.b1(int p) : v = p != true;
1412 const B.b2(int p) : v = p != false; 1510 const B.b2(int p) : v = p != false;
1413 const B.b3(int p) : v = p != 0; 1511 const B.b3(int p) : v = p != 0;
1414 const B.b4(int p) : v = p != 0.0; 1512 const B.b4(int p) : v = p != 0.0;
1415 const B.b5(int p) : v = p != ''; 1513 const B.b5(int p) : v = p != '';
1416 const B.c1(String p) : v = p != true; 1514 const B.c1(String p) : v = p != true;
1417 const B.c2(String p) : v = p != false; 1515 const B.c2(String p) : v = p != false;
1418 const B.c3(String p) : v = p != 0; 1516 const B.c3(String p) : v = p != 0;
1419 const B.c4(String p) : v = p != 0.0; 1517 const B.c4(String p) : v = p != 0.0;
1420 const B.c5(String p) : v = p != ''; 1518 const B.c5(String p) : v = p != '';
1421 const B.n1(num p) : v = p != null; 1519 const B.n1(num p) : v = p != null;
1422 const B.n2(num p) : v = null != p; 1520 const B.n2(num p) : v = null != p;
1423 }'''); 1521 }''');
1424 await assertNoErrors(source); 1522 await computeAnalysisResult(source);
1523 assertNoErrors(source);
1425 verify([source]); 1524 verify([source]);
1426 } 1525 }
1427 1526
1428 test_constEvelTypeNum_String() async { 1527 test_constEvelTypeNum_String() async {
1429 Source source = addSource(r''' 1528 Source source = addSource(r'''
1430 const String A = 'a'; 1529 const String A = 'a';
1431 const String B = A + 'b'; 1530 const String B = A + 'b';
1432 '''); 1531 ''');
1433 await assertNoErrors(source); 1532 await computeAnalysisResult(source);
1533 assertNoErrors(source);
1434 verify([source]); 1534 verify([source]);
1435 } 1535 }
1436 1536
1437 test_constMapKeyExpressionTypeImplementsEquals_abstract() async { 1537 test_constMapKeyExpressionTypeImplementsEquals_abstract() async {
1438 Source source = addSource(r''' 1538 Source source = addSource(r'''
1439 abstract class B { 1539 abstract class B {
1440 final id; 1540 final id;
1441 const B(this.id); 1541 const B(this.id);
1442 String toString() => 'C($id)'; 1542 String toString() => 'C($id)';
1443 /** Equality is identity equality, the id isn't used. */ 1543 /** Equality is identity equality, the id isn't used. */
1444 bool operator==(Object other); 1544 bool operator==(Object other);
1445 } 1545 }
1446 1546
1447 class C extends B { 1547 class C extends B {
1448 const C(id) : super(id); 1548 const C(id) : super(id);
1449 } 1549 }
1450 1550
1451 Map getMap() { 1551 Map getMap() {
1452 return const { const C(0): 'Map: 0' }; 1552 return const { const C(0): 'Map: 0' };
1453 }'''); 1553 }''');
1454 await assertNoErrors(source); 1554 await computeAnalysisResult(source);
1555 assertNoErrors(source);
1455 verify([source]); 1556 verify([source]);
1456 } 1557 }
1457 1558
1458 test_constNotInitialized_field() async { 1559 test_constNotInitialized_field() async {
1459 Source source = addSource(r''' 1560 Source source = addSource(r'''
1460 class A { 1561 class A {
1461 static const int x = 0; 1562 static const int x = 0;
1462 }'''); 1563 }''');
1463 await assertNoErrors(source); 1564 await computeAnalysisResult(source);
1565 assertNoErrors(source);
1464 verify([source]); 1566 verify([source]);
1465 } 1567 }
1466 1568
1467 test_constNotInitialized_local() async { 1569 test_constNotInitialized_local() async {
1468 Source source = addSource(r''' 1570 Source source = addSource(r'''
1469 main() { 1571 main() {
1470 const int x = 0; 1572 const int x = 0;
1471 }'''); 1573 }''');
1472 await assertNoErrors(source); 1574 await computeAnalysisResult(source);
1575 assertNoErrors(source);
1473 verify([source]); 1576 verify([source]);
1474 } 1577 }
1475 1578
1476 test_constRedirectSkipsSupertype() async { 1579 test_constRedirectSkipsSupertype() async {
1477 // Since C redirects to C.named, it doesn't implicitly refer to B's 1580 // Since C redirects to C.named, it doesn't implicitly refer to B's
1478 // unnamed constructor. Therefore there is no cycle. 1581 // unnamed constructor. Therefore there is no cycle.
1479 Source source = addSource(''' 1582 Source source = addSource('''
1480 class B { 1583 class B {
1481 final x; 1584 final x;
1482 const B() : x = y; 1585 const B() : x = y;
1483 const B.named() : x = null; 1586 const B.named() : x = null;
1484 } 1587 }
1485 class C extends B { 1588 class C extends B {
1486 const C() : this.named(); 1589 const C() : this.named();
1487 const C.named() : super.named(); 1590 const C.named() : super.named();
1488 } 1591 }
1489 const y = const C(); 1592 const y = const C();
1490 '''); 1593 ''');
1491 await assertNoErrors(source); 1594 await computeAnalysisResult(source);
1595 assertNoErrors(source);
1492 verify([source]); 1596 verify([source]);
1493 } 1597 }
1494 1598
1495 test_constructorDeclaration_scope_signature() async { 1599 test_constructorDeclaration_scope_signature() async {
1496 Source source = addSource(r''' 1600 Source source = addSource(r'''
1497 const app = 0; 1601 const app = 0;
1498 class A { 1602 class A {
1499 A(@app int app) {} 1603 A(@app int app) {}
1500 }'''); 1604 }''');
1501 await assertNoErrors(source); 1605 await computeAnalysisResult(source);
1606 assertNoErrors(source);
1502 verify([source]); 1607 verify([source]);
1503 } 1608 }
1504 1609
1505 test_constWithNonConstantArgument_constField() async { 1610 test_constWithNonConstantArgument_constField() async {
1506 Source source = addSource(r''' 1611 Source source = addSource(r'''
1507 class A { 1612 class A {
1508 const A(x); 1613 const A(x);
1509 } 1614 }
1510 main() { 1615 main() {
1511 const A(double.INFINITY); 1616 const A(double.INFINITY);
1512 }'''); 1617 }''');
1513 await assertNoErrors(source); 1618 await computeAnalysisResult(source);
1619 assertNoErrors(source);
1514 verify([source]); 1620 verify([source]);
1515 } 1621 }
1516 1622
1517 test_constWithNonConstantArgument_literals() async { 1623 test_constWithNonConstantArgument_literals() async {
1518 Source source = addSource(r''' 1624 Source source = addSource(r'''
1519 class A { 1625 class A {
1520 const A(a, b, c, d); 1626 const A(a, b, c, d);
1521 } 1627 }
1522 f() { return const A(true, 0, 1.0, '2'); }'''); 1628 f() { return const A(true, 0, 1.0, '2'); }''');
1523 await assertNoErrors(source); 1629 await computeAnalysisResult(source);
1630 assertNoErrors(source);
1524 verify([source]); 1631 verify([source]);
1525 } 1632 }
1526 1633
1527 test_constWithTypeParameters_direct() async { 1634 test_constWithTypeParameters_direct() async {
1528 Source source = addSource(r''' 1635 Source source = addSource(r'''
1529 class A<T> { 1636 class A<T> {
1530 static const V = const A<int>(); 1637 static const V = const A<int>();
1531 const A(); 1638 const A();
1532 }'''); 1639 }''');
1533 await assertNoErrors(source); 1640 await computeAnalysisResult(source);
1641 assertNoErrors(source);
1534 verify([source]); 1642 verify([source]);
1535 } 1643 }
1536 1644
1537 test_constWithUndefinedConstructor() async { 1645 test_constWithUndefinedConstructor() async {
1538 Source source = addSource(r''' 1646 Source source = addSource(r'''
1539 class A { 1647 class A {
1540 const A.name(); 1648 const A.name();
1541 } 1649 }
1542 f() { 1650 f() {
1543 return const A.name(); 1651 return const A.name();
1544 }'''); 1652 }''');
1545 await assertNoErrors(source); 1653 await computeAnalysisResult(source);
1654 assertNoErrors(source);
1546 verify([source]); 1655 verify([source]);
1547 } 1656 }
1548 1657
1549 test_constWithUndefinedConstructorDefault() async { 1658 test_constWithUndefinedConstructorDefault() async {
1550 Source source = addSource(r''' 1659 Source source = addSource(r'''
1551 class A { 1660 class A {
1552 const A(); 1661 const A();
1553 } 1662 }
1554 f() { 1663 f() {
1555 return const A(); 1664 return const A();
1556 }'''); 1665 }''');
1557 await assertNoErrors(source); 1666 await computeAnalysisResult(source);
1667 assertNoErrors(source);
1558 verify([source]); 1668 verify([source]);
1559 } 1669 }
1560 1670
1561 test_defaultValueInFunctionTypeAlias() async { 1671 test_defaultValueInFunctionTypeAlias() async {
1562 Source source = addSource("typedef F([x]);"); 1672 Source source = addSource("typedef F([x]);");
1563 await assertNoErrors(source); 1673 await computeAnalysisResult(source);
1674 assertNoErrors(source);
1564 verify([source]); 1675 verify([source]);
1565 } 1676 }
1566 1677
1567 test_defaultValueInFunctionTypedParameter_named() async { 1678 test_defaultValueInFunctionTypedParameter_named() async {
1568 Source source = addSource("f(g({p})) {}"); 1679 Source source = addSource("f(g({p})) {}");
1569 await assertNoErrors(source); 1680 await computeAnalysisResult(source);
1681 assertNoErrors(source);
1570 verify([source]); 1682 verify([source]);
1571 } 1683 }
1572 1684
1573 test_defaultValueInFunctionTypedParameter_optional() async { 1685 test_defaultValueInFunctionTypedParameter_optional() async {
1574 Source source = addSource("f(g([p])) {}"); 1686 Source source = addSource("f(g([p])) {}");
1575 await assertNoErrors(source); 1687 await computeAnalysisResult(source);
1688 assertNoErrors(source);
1576 verify([source]); 1689 verify([source]);
1577 } 1690 }
1578 1691
1579 test_deprecatedMemberUse_hide() async { 1692 test_deprecatedMemberUse_hide() async {
1580 Source source = addSource(r''' 1693 Source source = addSource(r'''
1581 library lib; 1694 library lib;
1582 import 'lib1.dart' hide B; 1695 import 'lib1.dart' hide B;
1583 A a = new A();'''); 1696 A a = new A();''');
1584 addNamedSource( 1697 addNamedSource(
1585 "/lib1.dart", 1698 "/lib1.dart",
1586 r''' 1699 r'''
1587 library lib1; 1700 library lib1;
1588 class A {} 1701 class A {}
1589 @deprecated 1702 @deprecated
1590 class B {}'''); 1703 class B {}''');
1591 await assertNoErrors(source); 1704 await computeAnalysisResult(source);
1705 assertNoErrors(source);
1592 verify([source]); 1706 verify([source]);
1593 } 1707 }
1594 1708
1595 test_duplicateDefinition_emptyName() async { 1709 test_duplicateDefinition_emptyName() async {
1596 // Note: This code has two FunctionElements '() {}' with an empty name, 1710 // Note: This code has two FunctionElements '() {}' with an empty name,
1597 // this tests that the empty string is not put into the scope 1711 // this tests that the empty string is not put into the scope
1598 // (more than once). 1712 // (more than once).
1599 Source source = addSource(r''' 1713 Source source = addSource(r'''
1600 Map _globalMap = { 1714 Map _globalMap = {
1601 'a' : () {}, 1715 'a' : () {},
1602 'b' : () {} 1716 'b' : () {}
1603 };'''); 1717 };''');
1604 await assertNoErrors(source); 1718 await computeAnalysisResult(source);
1719 assertNoErrors(source);
1605 verify([source]); 1720 verify([source]);
1606 } 1721 }
1607 1722
1608 test_duplicateDefinition_getter() async { 1723 test_duplicateDefinition_getter() async {
1609 Source source = addSource("bool get a => true;"); 1724 Source source = addSource("bool get a => true;");
1610 await assertNoErrors(source); 1725 await computeAnalysisResult(source);
1726 assertNoErrors(source);
1611 verify([source]); 1727 verify([source]);
1612 } 1728 }
1613 1729
1614 test_duplicatePart() async { 1730 test_duplicatePart() async {
1615 addNamedSource('/part1.dart', 'part of lib;'); 1731 addNamedSource('/part1.dart', 'part of lib;');
1616 addNamedSource('/part2.dart', 'part of lib;'); 1732 addNamedSource('/part2.dart', 'part of lib;');
1617 Source source = addSource(r''' 1733 Source source = addSource(r'''
1618 library lib; 1734 library lib;
1619 part 'part1.dart'; 1735 part 'part1.dart';
1620 part 'part2.dart'; 1736 part 'part2.dart';
1621 '''); 1737 ''');
1622 await assertNoErrors(source); 1738 await computeAnalysisResult(source);
1739 assertNoErrors(source);
1623 verify([source]); 1740 verify([source]);
1624 } 1741 }
1625 1742
1626 test_dynamicIdentifier() async { 1743 test_dynamicIdentifier() async {
1627 Source source = addSource(r''' 1744 Source source = addSource(r'''
1628 main() { 1745 main() {
1629 var v = dynamic; 1746 var v = dynamic;
1630 }'''); 1747 }''');
1631 await assertNoErrors(source); 1748 await computeAnalysisResult(source);
1749 assertNoErrors(source);
1632 verify([source]); 1750 verify([source]);
1633 } 1751 }
1634 1752
1635 test_empty_generator_async() async { 1753 test_empty_generator_async() async {
1636 Source source = addSource(''' 1754 Source source = addSource('''
1637 import 'dart:async'; 1755 import 'dart:async';
1638 Stream<int> f() async* { 1756 Stream<int> f() async* {
1639 } 1757 }
1640 '''); 1758 ''');
1641 await assertNoErrors(source); 1759 await computeAnalysisResult(source);
1760 assertNoErrors(source);
1642 verify([source]); 1761 verify([source]);
1643 } 1762 }
1644 1763
1645 test_empty_generator_sync() async { 1764 test_empty_generator_sync() async {
1646 Source source = addSource(''' 1765 Source source = addSource('''
1647 Iterable<int> f() sync* { 1766 Iterable<int> f() sync* {
1648 } 1767 }
1649 '''); 1768 ''');
1650 await assertNoErrors(source); 1769 await computeAnalysisResult(source);
1770 assertNoErrors(source);
1651 verify([source]); 1771 verify([source]);
1652 } 1772 }
1653 1773
1654 test_expectedOneListTypeArgument() async { 1774 test_expectedOneListTypeArgument() async {
1655 Source source = addSource(r''' 1775 Source source = addSource(r'''
1656 main() { 1776 main() {
1657 <int> []; 1777 <int> [];
1658 }'''); 1778 }''');
1659 await assertNoErrors(source); 1779 await computeAnalysisResult(source);
1780 assertNoErrors(source);
1660 verify([source]); 1781 verify([source]);
1661 } 1782 }
1662 1783
1663 test_expectedTwoMapTypeArguments() async { 1784 test_expectedTwoMapTypeArguments() async {
1664 Source source = addSource(r''' 1785 Source source = addSource(r'''
1665 main() { 1786 main() {
1666 <int, int> {}; 1787 <int, int> {};
1667 }'''); 1788 }''');
1668 await assertNoErrors(source); 1789 await computeAnalysisResult(source);
1790 assertNoErrors(source);
1669 verify([source]); 1791 verify([source]);
1670 } 1792 }
1671 1793
1672 test_exportDuplicatedLibraryUnnamed() async { 1794 test_exportDuplicatedLibraryUnnamed() async {
1673 Source source = addSource(r''' 1795 Source source = addSource(r'''
1674 library test; 1796 library test;
1675 export 'lib1.dart'; 1797 export 'lib1.dart';
1676 export 'lib2.dart';'''); 1798 export 'lib2.dart';''');
1677 addNamedSource("/lib1.dart", ""); 1799 addNamedSource("/lib1.dart", "");
1678 addNamedSource("/lib2.dart", ""); 1800 addNamedSource("/lib2.dart", "");
1679 await assertNoErrors(source); 1801 await computeAnalysisResult(source);
1802 assertNoErrors(source);
1680 verify([source]); 1803 verify([source]);
1681 } 1804 }
1682 1805
1683 test_exportOfNonLibrary_libraryDeclared() async { 1806 test_exportOfNonLibrary_libraryDeclared() async {
1684 Source source = addSource(r''' 1807 Source source = addSource(r'''
1685 library L; 1808 library L;
1686 export 'lib1.dart';'''); 1809 export 'lib1.dart';''');
1687 addNamedSource("/lib1.dart", "library lib1;"); 1810 addNamedSource("/lib1.dart", "library lib1;");
1688 await assertNoErrors(source); 1811 await computeAnalysisResult(source);
1812 assertNoErrors(source);
1689 verify([source]); 1813 verify([source]);
1690 } 1814 }
1691 1815
1692 test_exportOfNonLibrary_libraryNotDeclared() async { 1816 test_exportOfNonLibrary_libraryNotDeclared() async {
1693 Source source = addSource(r''' 1817 Source source = addSource(r'''
1694 library L; 1818 library L;
1695 export 'lib1.dart';'''); 1819 export 'lib1.dart';''');
1696 addNamedSource("/lib1.dart", ""); 1820 addNamedSource("/lib1.dart", "");
1697 await assertNoErrors(source); 1821 await computeAnalysisResult(source);
1822 assertNoErrors(source);
1698 verify([source]); 1823 verify([source]);
1699 } 1824 }
1700 1825
1701 test_extraPositionalArguments_function() async { 1826 test_extraPositionalArguments_function() async {
1702 Source source = addSource(r''' 1827 Source source = addSource(r'''
1703 f(p1, p2) {} 1828 f(p1, p2) {}
1704 main() { 1829 main() {
1705 f(1, 2); 1830 f(1, 2);
1706 }'''); 1831 }''');
1707 await assertNoErrors(source); 1832 await computeAnalysisResult(source);
1833 assertNoErrors(source);
1708 verify([source]); 1834 verify([source]);
1709 } 1835 }
1710 1836
1711 test_extraPositionalArguments_Function() async { 1837 test_extraPositionalArguments_Function() async {
1712 Source source = addSource(r''' 1838 Source source = addSource(r'''
1713 f(Function a) { 1839 f(Function a) {
1714 a(1, 2); 1840 a(1, 2);
1715 }'''); 1841 }''');
1716 await assertNoErrors(source); 1842 await computeAnalysisResult(source);
1843 assertNoErrors(source);
1717 verify([source]); 1844 verify([source]);
1718 } 1845 }
1719 1846
1720 test_extraPositionalArguments_implicitConstructor() async { 1847 test_extraPositionalArguments_implicitConstructor() async {
1721 Source source = addSource(r''' 1848 Source source = addSource(r'''
1722 class A<E extends num> { 1849 class A<E extends num> {
1723 A(E x, E y); 1850 A(E x, E y);
1724 } 1851 }
1725 class M {} 1852 class M {}
1726 class B<E extends num> = A<E> with M; 1853 class B<E extends num> = A<E> with M;
1727 void main() { 1854 void main() {
1728 B<int> x = new B<int>(0,0); 1855 B<int> x = new B<int>(0,0);
1729 }'''); 1856 }''');
1730 await assertNoErrors(source); 1857 await computeAnalysisResult(source);
1858 assertNoErrors(source);
1731 verify([source]); 1859 verify([source]);
1732 } 1860 }
1733 1861
1734 test_extraPositionalArguments_typedef_local() async { 1862 test_extraPositionalArguments_typedef_local() async {
1735 Source source = addSource(r''' 1863 Source source = addSource(r'''
1736 typedef A(p1, p2); 1864 typedef A(p1, p2);
1737 A getA() => null; 1865 A getA() => null;
1738 f() { 1866 f() {
1739 A a = getA(); 1867 A a = getA();
1740 a(1, 2); 1868 a(1, 2);
1741 }'''); 1869 }''');
1742 await assertNoErrors(source); 1870 await computeAnalysisResult(source);
1871 assertNoErrors(source);
1743 verify([source]); 1872 verify([source]);
1744 } 1873 }
1745 1874
1746 test_extraPositionalArguments_typedef_parameter() async { 1875 test_extraPositionalArguments_typedef_parameter() async {
1747 Source source = addSource(r''' 1876 Source source = addSource(r'''
1748 typedef A(p1, p2); 1877 typedef A(p1, p2);
1749 f(A a) { 1878 f(A a) {
1750 a(1, 2); 1879 a(1, 2);
1751 }'''); 1880 }''');
1752 await assertNoErrors(source); 1881 await computeAnalysisResult(source);
1882 assertNoErrors(source);
1753 verify([source]); 1883 verify([source]);
1754 } 1884 }
1755 1885
1756 test_fieldInitializedByMultipleInitializers() async { 1886 test_fieldInitializedByMultipleInitializers() async {
1757 Source source = addSource(r''' 1887 Source source = addSource(r'''
1758 class A { 1888 class A {
1759 int x; 1889 int x;
1760 int y; 1890 int y;
1761 A() : x = 0, y = 0 {} 1891 A() : x = 0, y = 0 {}
1762 }'''); 1892 }''');
1763 await assertNoErrors(source); 1893 await computeAnalysisResult(source);
1894 assertNoErrors(source);
1764 verify([source]); 1895 verify([source]);
1765 } 1896 }
1766 1897
1767 test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() async { 1898 test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() async {
1768 Source source = addSource(r''' 1899 Source source = addSource(r'''
1769 class A { 1900 class A {
1770 int x = 0; 1901 int x = 0;
1771 A() : x = 1 {} 1902 A() : x = 1 {}
1772 }'''); 1903 }''');
1773 await assertNoErrors(source); 1904 await computeAnalysisResult(source);
1905 assertNoErrors(source);
1774 verify([source]); 1906 verify([source]);
1775 } 1907 }
1776 1908
1777 test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() async { 1909 test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() async {
1778 Source source = addSource(r''' 1910 Source source = addSource(r'''
1779 class A { 1911 class A {
1780 final int x; 1912 final int x;
1781 A() : x = 1 {} 1913 A() : x = 1 {}
1782 }'''); 1914 }''');
1783 await assertNoErrors(source); 1915 await computeAnalysisResult(source);
1916 assertNoErrors(source);
1784 verify([source]); 1917 verify([source]);
1785 } 1918 }
1786 1919
1787 test_fieldInitializerOutsideConstructor() async { 1920 test_fieldInitializerOutsideConstructor() async {
1788 Source source = addSource(r''' 1921 Source source = addSource(r'''
1789 class A { 1922 class A {
1790 int x; 1923 int x;
1791 A(this.x) {} 1924 A(this.x) {}
1792 }'''); 1925 }''');
1793 await assertNoErrors(source); 1926 await computeAnalysisResult(source);
1927 assertNoErrors(source);
1794 verify([source]); 1928 verify([source]);
1795 } 1929 }
1796 1930
1797 test_fieldInitializerOutsideConstructor_defaultParameters() async { 1931 test_fieldInitializerOutsideConstructor_defaultParameters() async {
1798 Source source = addSource(r''' 1932 Source source = addSource(r'''
1799 class A { 1933 class A {
1800 int x; 1934 int x;
1801 A([this.x]) {} 1935 A([this.x]) {}
1802 }'''); 1936 }''');
1803 await assertNoErrors(source); 1937 await computeAnalysisResult(source);
1938 assertNoErrors(source);
1804 verify([source]); 1939 verify([source]);
1805 } 1940 }
1806 1941
1807 test_fieldInitializerRedirectingConstructor_super() async { 1942 test_fieldInitializerRedirectingConstructor_super() async {
1808 Source source = addSource(r''' 1943 Source source = addSource(r'''
1809 class A { 1944 class A {
1810 A() {} 1945 A() {}
1811 } 1946 }
1812 class B extends A { 1947 class B extends A {
1813 int x; 1948 int x;
1814 B(this.x) : super(); 1949 B(this.x) : super();
1815 }'''); 1950 }''');
1816 await assertNoErrors(source); 1951 await computeAnalysisResult(source);
1952 assertNoErrors(source);
1817 verify([source]); 1953 verify([source]);
1818 } 1954 }
1819 1955
1820 test_finalInitializedInDeclarationAndConstructor_initializer() async { 1956 test_finalInitializedInDeclarationAndConstructor_initializer() async {
1821 Source source = addSource(r''' 1957 Source source = addSource(r'''
1822 class A { 1958 class A {
1823 final x; 1959 final x;
1824 A() : x = 1 {} 1960 A() : x = 1 {}
1825 }'''); 1961 }''');
1826 await assertNoErrors(source); 1962 await computeAnalysisResult(source);
1963 assertNoErrors(source);
1827 verify([source]); 1964 verify([source]);
1828 } 1965 }
1829 1966
1830 test_finalInitializedInDeclarationAndConstructor_initializingFormal() async { 1967 test_finalInitializedInDeclarationAndConstructor_initializingFormal() async {
1831 Source source = addSource(r''' 1968 Source source = addSource(r'''
1832 class A { 1969 class A {
1833 final x; 1970 final x;
1834 A(this.x) {} 1971 A(this.x) {}
1835 }'''); 1972 }''');
1836 await assertNoErrors(source); 1973 await computeAnalysisResult(source);
1974 assertNoErrors(source);
1837 verify([source]); 1975 verify([source]);
1838 } 1976 }
1839 1977
1840 test_finalNotInitialized_atDeclaration() async { 1978 test_finalNotInitialized_atDeclaration() async {
1841 Source source = addSource(r''' 1979 Source source = addSource(r'''
1842 class A { 1980 class A {
1843 final int x = 0; 1981 final int x = 0;
1844 A() {} 1982 A() {}
1845 }'''); 1983 }''');
1846 await assertNoErrors(source); 1984 await computeAnalysisResult(source);
1985 assertNoErrors(source);
1847 verify([source]); 1986 verify([source]);
1848 } 1987 }
1849 1988
1850 test_finalNotInitialized_fieldFormal() async { 1989 test_finalNotInitialized_fieldFormal() async {
1851 Source source = addSource(r''' 1990 Source source = addSource(r'''
1852 class A { 1991 class A {
1853 final int x = 0; 1992 final int x = 0;
1854 A() {} 1993 A() {}
1855 }'''); 1994 }''');
1856 await assertNoErrors(source); 1995 await computeAnalysisResult(source);
1996 assertNoErrors(source);
1857 verify([source]); 1997 verify([source]);
1858 } 1998 }
1859 1999
1860 test_finalNotInitialized_functionTypedFieldFormal() async { 2000 test_finalNotInitialized_functionTypedFieldFormal() async {
1861 Source source = addSource(r''' 2001 Source source = addSource(r'''
1862 class A { 2002 class A {
1863 final Function x; 2003 final Function x;
1864 A(int this.x(int p)) {} 2004 A(int this.x(int p)) {}
1865 }'''); 2005 }''');
1866 await assertNoErrors(source); 2006 await computeAnalysisResult(source);
2007 assertNoErrors(source);
1867 verify([source]); 2008 verify([source]);
1868 } 2009 }
1869 2010
1870 test_finalNotInitialized_hasNativeClause_hasConstructor() async { 2011 test_finalNotInitialized_hasNativeClause_hasConstructor() async {
1871 Source source = addSource(r''' 2012 Source source = addSource(r'''
1872 class A native 'something' { 2013 class A native 'something' {
1873 final int x; 2014 final int x;
1874 A() {} 2015 A() {}
1875 }'''); 2016 }''');
1876 await assertErrors( 2017 await computeAnalysisResult(source);
1877 source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); 2018 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
1878 verify([source]); 2019 verify([source]);
1879 } 2020 }
1880 2021
1881 test_finalNotInitialized_hasNativeClause_noConstructor() async { 2022 test_finalNotInitialized_hasNativeClause_noConstructor() async {
1882 Source source = addSource(r''' 2023 Source source = addSource(r'''
1883 class A native 'something' { 2024 class A native 'something' {
1884 final int x; 2025 final int x;
1885 }'''); 2026 }''');
1886 await assertErrors( 2027 await computeAnalysisResult(source);
1887 source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); 2028 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
1888 verify([source]); 2029 verify([source]);
1889 } 2030 }
1890 2031
1891 test_finalNotInitialized_initializer() async { 2032 test_finalNotInitialized_initializer() async {
1892 Source source = addSource(r''' 2033 Source source = addSource(r'''
1893 class A { 2034 class A {
1894 final int x; 2035 final int x;
1895 A() : x = 0 {} 2036 A() : x = 0 {}
1896 }'''); 2037 }''');
1897 await assertNoErrors(source); 2038 await computeAnalysisResult(source);
2039 assertNoErrors(source);
1898 verify([source]); 2040 verify([source]);
1899 } 2041 }
1900 2042
1901 test_finalNotInitialized_redirectingConstructor() async { 2043 test_finalNotInitialized_redirectingConstructor() async {
1902 Source source = addSource(r''' 2044 Source source = addSource(r'''
1903 class A { 2045 class A {
1904 final int x; 2046 final int x;
1905 A(this.x); 2047 A(this.x);
1906 A.named() : this (42); 2048 A.named() : this (42);
1907 }'''); 2049 }''');
1908 await assertNoErrors(source); 2050 await computeAnalysisResult(source);
2051 assertNoErrors(source);
1909 verify([source]); 2052 verify([source]);
1910 } 2053 }
1911 2054
1912 test_functionDeclaration_scope_returnType() async { 2055 test_functionDeclaration_scope_returnType() async {
1913 Source source = addSource("int f(int) { return 0; }"); 2056 Source source = addSource("int f(int) { return 0; }");
1914 await assertNoErrors(source); 2057 await computeAnalysisResult(source);
2058 assertNoErrors(source);
1915 verify([source]); 2059 verify([source]);
1916 } 2060 }
1917 2061
1918 test_functionDeclaration_scope_signature() async { 2062 test_functionDeclaration_scope_signature() async {
1919 Source source = addSource(r''' 2063 Source source = addSource(r'''
1920 const app = 0; 2064 const app = 0;
1921 f(@app int app) {}'''); 2065 f(@app int app) {}''');
1922 await assertNoErrors(source); 2066 await computeAnalysisResult(source);
2067 assertNoErrors(source);
1923 verify([source]); 2068 verify([source]);
1924 } 2069 }
1925 2070
1926 test_functionTypeAlias_scope_returnType() async { 2071 test_functionTypeAlias_scope_returnType() async {
1927 Source source = addSource("typedef int f(int);"); 2072 Source source = addSource("typedef int f(int);");
1928 await assertNoErrors(source); 2073 await computeAnalysisResult(source);
2074 assertNoErrors(source);
1929 verify([source]); 2075 verify([source]);
1930 } 2076 }
1931 2077
1932 test_functionTypeAlias_scope_signature() async { 2078 test_functionTypeAlias_scope_signature() async {
1933 Source source = addSource(r''' 2079 Source source = addSource(r'''
1934 const app = 0; 2080 const app = 0;
1935 typedef int f(@app int app);'''); 2081 typedef int f(@app int app);''');
1936 await assertNoErrors(source); 2082 await computeAnalysisResult(source);
2083 assertNoErrors(source);
1937 verify([source]); 2084 verify([source]);
1938 } 2085 }
1939 2086
1940 test_functionWithoutCall() async { 2087 test_functionWithoutCall() async {
1941 Source source = addSource(r''' 2088 Source source = addSource(r'''
1942 abstract class A implements Function { 2089 abstract class A implements Function {
1943 } 2090 }
1944 class B implements A { 2091 class B implements A {
1945 void call() {} 2092 void call() {}
1946 } 2093 }
1947 class C extends A { 2094 class C extends A {
1948 void call() {} 2095 void call() {}
1949 } 2096 }
1950 class D extends C { 2097 class D extends C {
1951 }'''); 2098 }''');
1952 await assertNoErrors(source); 2099 await computeAnalysisResult(source);
2100 assertNoErrors(source);
1953 verify([source]); 2101 verify([source]);
1954 } 2102 }
1955 2103
1956 test_functionWithoutCall_doesNotImplementFunction() async { 2104 test_functionWithoutCall_doesNotImplementFunction() async {
1957 Source source = addSource("class A {}"); 2105 Source source = addSource("class A {}");
1958 await assertNoErrors(source); 2106 await computeAnalysisResult(source);
2107 assertNoErrors(source);
1959 verify([source]); 2108 verify([source]);
1960 } 2109 }
1961 2110
1962 test_functionWithoutCall_staticCallMethod() async { 2111 test_functionWithoutCall_staticCallMethod() async {
1963 Source source = addSource(r''' 2112 Source source = addSource(r'''
1964 class A { } 2113 class A { }
1965 class B extends A { 2114 class B extends A {
1966 static call() { } 2115 static call() { }
1967 } 2116 }
1968 '''); 2117 ''');
1969 await assertNoErrors(source); 2118 await computeAnalysisResult(source);
2119 assertNoErrors(source);
1970 verify([source]); 2120 verify([source]);
1971 } 2121 }
1972 2122
1973 test_functionWithoutCall_withNoSuchMethod() async { 2123 test_functionWithoutCall_withNoSuchMethod() async {
1974 // 16078 2124 // 16078
1975 Source source = addSource(r''' 2125 Source source = addSource(r'''
1976 class A implements Function { 2126 class A implements Function {
1977 noSuchMethod(inv) { 2127 noSuchMethod(inv) {
1978 return 42; 2128 return 42;
1979 } 2129 }
1980 }'''); 2130 }''');
1981 await assertNoErrors(source); 2131 await computeAnalysisResult(source);
2132 assertNoErrors(source);
1982 verify([source]); 2133 verify([source]);
1983 } 2134 }
1984 2135
1985 test_functionWithoutCall_withNoSuchMethod_mixin() async { 2136 test_functionWithoutCall_withNoSuchMethod_mixin() async {
1986 Source source = addSource(r''' 2137 Source source = addSource(r'''
1987 class A { 2138 class A {
1988 noSuchMethod(inv) {} 2139 noSuchMethod(inv) {}
1989 } 2140 }
1990 class B extends Object with A implements Function { 2141 class B extends Object with A implements Function {
1991 }'''); 2142 }''');
1992 await assertNoErrors(source); 2143 await computeAnalysisResult(source);
2144 assertNoErrors(source);
1993 verify([source]); 2145 verify([source]);
1994 } 2146 }
1995 2147
1996 test_functionWithoutCall_withNoSuchMethod_superclass() async { 2148 test_functionWithoutCall_withNoSuchMethod_superclass() async {
1997 Source source = addSource(r''' 2149 Source source = addSource(r'''
1998 class A { 2150 class A {
1999 noSuchMethod(inv) {} 2151 noSuchMethod(inv) {}
2000 } 2152 }
2001 class B extends A implements Function { 2153 class B extends A implements Function {
2002 }'''); 2154 }''');
2003 await assertNoErrors(source); 2155 await computeAnalysisResult(source);
2156 assertNoErrors(source);
2004 verify([source]); 2157 verify([source]);
2005 } 2158 }
2006 2159
2007 test_implicitConstructorDependencies() async { 2160 test_implicitConstructorDependencies() async {
2008 // No warning should be generated for the code below; this requires that 2161 // No warning should be generated for the code below; this requires that
2009 // implicit constructors are generated for C1 before C2, even though C1 2162 // implicit constructors are generated for C1 before C2, even though C1
2010 // follows C2 in the file. See dartbug.com/21600. 2163 // follows C2 in the file. See dartbug.com/21600.
2011 Source source = addSource(r''' 2164 Source source = addSource(r'''
2012 class B { 2165 class B {
2013 B(int i); 2166 B(int i);
2014 } 2167 }
2015 class M1 {} 2168 class M1 {}
2016 class M2 {} 2169 class M2 {}
2017 2170
2018 class C2 = C1 with M2; 2171 class C2 = C1 with M2;
2019 class C1 = B with M1; 2172 class C1 = B with M1;
2020 2173
2021 main() { 2174 main() {
2022 new C2(5); 2175 new C2(5);
2023 } 2176 }
2024 '''); 2177 ''');
2025 await assertNoErrors(source); 2178 await computeAnalysisResult(source);
2179 assertNoErrors(source);
2026 verify([source]); 2180 verify([source]);
2027 } 2181 }
2028 2182
2029 test_implicitThisReferenceInInitializer_constructorName() async { 2183 test_implicitThisReferenceInInitializer_constructorName() async {
2030 Source source = addSource(r''' 2184 Source source = addSource(r'''
2031 class A { 2185 class A {
2032 A.named() {} 2186 A.named() {}
2033 } 2187 }
2034 class B { 2188 class B {
2035 var v; 2189 var v;
2036 B() : v = new A.named(); 2190 B() : v = new A.named();
2037 }'''); 2191 }''');
2038 await assertNoErrors(source); 2192 await computeAnalysisResult(source);
2193 assertNoErrors(source);
2039 verify([source]); 2194 verify([source]);
2040 } 2195 }
2041 2196
2042 test_implicitThisReferenceInInitializer_importPrefix() async { 2197 test_implicitThisReferenceInInitializer_importPrefix() async {
2043 Source source = addSource(r''' 2198 Source source = addSource(r'''
2044 import 'dart:async' as abstract; 2199 import 'dart:async' as abstract;
2045 class A { 2200 class A {
2046 var v = new abstract.Completer(); 2201 var v = new abstract.Completer();
2047 }'''); 2202 }''');
2048 await assertNoErrors(source); 2203 await computeAnalysisResult(source);
2204 assertNoErrors(source);
2049 verify([source]); 2205 verify([source]);
2050 } 2206 }
2051 2207
2052 test_implicitThisReferenceInInitializer_prefixedIdentifier() async { 2208 test_implicitThisReferenceInInitializer_prefixedIdentifier() async {
2053 Source source = addSource(r''' 2209 Source source = addSource(r'''
2054 class A { 2210 class A {
2055 var f; 2211 var f;
2056 } 2212 }
2057 class B { 2213 class B {
2058 var v; 2214 var v;
2059 B(A a) : v = a.f; 2215 B(A a) : v = a.f;
2060 }'''); 2216 }''');
2061 await assertNoErrors(source); 2217 await computeAnalysisResult(source);
2218 assertNoErrors(source);
2062 verify([source]); 2219 verify([source]);
2063 } 2220 }
2064 2221
2065 test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() async { 2222 test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() async {
2066 Source source = addSource(r''' 2223 Source source = addSource(r'''
2067 class A { 2224 class A {
2068 f() {} 2225 f() {}
2069 } 2226 }
2070 class B { 2227 class B {
2071 var v; 2228 var v;
2072 B() : v = new A().f(); 2229 B() : v = new A().f();
2073 }'''); 2230 }''');
2074 await assertNoErrors(source); 2231 await computeAnalysisResult(source);
2232 assertNoErrors(source);
2075 verify([source]); 2233 verify([source]);
2076 } 2234 }
2077 2235
2078 test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() async { 2236 test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() async {
2079 Source source = addSource(r''' 2237 Source source = addSource(r'''
2080 class A { 2238 class A {
2081 var f; 2239 var f;
2082 } 2240 }
2083 class B { 2241 class B {
2084 var v; 2242 var v;
2085 B() : v = new A().f; 2243 B() : v = new A().f;
2086 }'''); 2244 }''');
2087 await assertNoErrors(source); 2245 await computeAnalysisResult(source);
2246 assertNoErrors(source);
2088 verify([source]); 2247 verify([source]);
2089 } 2248 }
2090 2249
2091 test_implicitThisReferenceInInitializer_staticField_thisClass() async { 2250 test_implicitThisReferenceInInitializer_staticField_thisClass() async {
2092 Source source = addSource(r''' 2251 Source source = addSource(r'''
2093 class A { 2252 class A {
2094 var v; 2253 var v;
2095 A() : v = f; 2254 A() : v = f;
2096 static var f; 2255 static var f;
2097 }'''); 2256 }''');
2098 await assertNoErrors(source); 2257 await computeAnalysisResult(source);
2258 assertNoErrors(source);
2099 verify([source]); 2259 verify([source]);
2100 } 2260 }
2101 2261
2102 test_implicitThisReferenceInInitializer_staticGetter() async { 2262 test_implicitThisReferenceInInitializer_staticGetter() async {
2103 Source source = addSource(r''' 2263 Source source = addSource(r'''
2104 class A { 2264 class A {
2105 var v; 2265 var v;
2106 A() : v = f; 2266 A() : v = f;
2107 static get f => 42; 2267 static get f => 42;
2108 }'''); 2268 }''');
2109 await assertNoErrors(source); 2269 await computeAnalysisResult(source);
2270 assertNoErrors(source);
2110 verify([source]); 2271 verify([source]);
2111 } 2272 }
2112 2273
2113 test_implicitThisReferenceInInitializer_staticMethod() async { 2274 test_implicitThisReferenceInInitializer_staticMethod() async {
2114 Source source = addSource(r''' 2275 Source source = addSource(r'''
2115 class A { 2276 class A {
2116 var v; 2277 var v;
2117 A() : v = f(); 2278 A() : v = f();
2118 static f() => 42; 2279 static f() => 42;
2119 }'''); 2280 }''');
2120 await assertNoErrors(source); 2281 await computeAnalysisResult(source);
2282 assertNoErrors(source);
2121 verify([source]); 2283 verify([source]);
2122 } 2284 }
2123 2285
2124 test_implicitThisReferenceInInitializer_topLevelField() async { 2286 test_implicitThisReferenceInInitializer_topLevelField() async {
2125 Source source = addSource(r''' 2287 Source source = addSource(r'''
2126 class A { 2288 class A {
2127 var v; 2289 var v;
2128 A() : v = f; 2290 A() : v = f;
2129 } 2291 }
2130 var f = 42;'''); 2292 var f = 42;''');
2131 await assertNoErrors(source); 2293 await computeAnalysisResult(source);
2294 assertNoErrors(source);
2132 verify([source]); 2295 verify([source]);
2133 } 2296 }
2134 2297
2135 test_implicitThisReferenceInInitializer_topLevelFunction() async { 2298 test_implicitThisReferenceInInitializer_topLevelFunction() async {
2136 Source source = addSource(r''' 2299 Source source = addSource(r'''
2137 class A { 2300 class A {
2138 var v; 2301 var v;
2139 A() : v = f(); 2302 A() : v = f();
2140 } 2303 }
2141 f() => 42;'''); 2304 f() => 42;''');
2142 await assertNoErrors(source); 2305 await computeAnalysisResult(source);
2306 assertNoErrors(source);
2143 verify([source]); 2307 verify([source]);
2144 } 2308 }
2145 2309
2146 test_implicitThisReferenceInInitializer_topLevelGetter() async { 2310 test_implicitThisReferenceInInitializer_topLevelGetter() async {
2147 Source source = addSource(r''' 2311 Source source = addSource(r'''
2148 class A { 2312 class A {
2149 var v; 2313 var v;
2150 A() : v = f; 2314 A() : v = f;
2151 } 2315 }
2152 get f => 42;'''); 2316 get f => 42;''');
2153 await assertNoErrors(source); 2317 await computeAnalysisResult(source);
2318 assertNoErrors(source);
2154 verify([source]); 2319 verify([source]);
2155 } 2320 }
2156 2321
2157 test_implicitThisReferenceInInitializer_typeParameter() async { 2322 test_implicitThisReferenceInInitializer_typeParameter() async {
2158 Source source = addSource(r''' 2323 Source source = addSource(r'''
2159 class A<T> { 2324 class A<T> {
2160 var v; 2325 var v;
2161 A(p) : v = (p is T); 2326 A(p) : v = (p is T);
2162 }'''); 2327 }''');
2163 await assertNoErrors(source); 2328 await computeAnalysisResult(source);
2329 assertNoErrors(source);
2164 verify([source]); 2330 verify([source]);
2165 } 2331 }
2166 2332
2167 test_importDuplicatedLibraryName() async { 2333 test_importDuplicatedLibraryName() async {
2168 Source source = addSource(r''' 2334 Source source = addSource(r'''
2169 library test; 2335 library test;
2170 import 'lib.dart'; 2336 import 'lib.dart';
2171 import 'lib.dart';'''); 2337 import 'lib.dart';''');
2172 addNamedSource("/lib.dart", "library lib;"); 2338 addNamedSource("/lib.dart", "library lib;");
2173 await assertErrors(source, [ 2339 await computeAnalysisResult(source);
2340 assertErrors(source, [
2174 HintCode.UNUSED_IMPORT, 2341 HintCode.UNUSED_IMPORT,
2175 HintCode.UNUSED_IMPORT, 2342 HintCode.UNUSED_IMPORT,
2176 HintCode.DUPLICATE_IMPORT 2343 HintCode.DUPLICATE_IMPORT
2177 ]); 2344 ]);
2178 verify([source]); 2345 verify([source]);
2179 } 2346 }
2180 2347
2181 test_importDuplicatedLibraryUnnamed() async { 2348 test_importDuplicatedLibraryUnnamed() async {
2182 Source source = addSource(r''' 2349 Source source = addSource(r'''
2183 library test; 2350 library test;
2184 import 'lib1.dart'; 2351 import 'lib1.dart';
2185 import 'lib2.dart';'''); 2352 import 'lib2.dart';''');
2186 addNamedSource("/lib1.dart", ""); 2353 addNamedSource("/lib1.dart", "");
2187 addNamedSource("/lib2.dart", ""); 2354 addNamedSource("/lib2.dart", "");
2188 await assertErrors(source, [ 2355 await computeAnalysisResult(source);
2356 assertErrors(source, [
2189 // No warning on duplicate import (https://github.com/dart-lang/sdk/issues /24156) 2357 // No warning on duplicate import (https://github.com/dart-lang/sdk/issues /24156)
2190 HintCode.UNUSED_IMPORT, 2358 HintCode.UNUSED_IMPORT,
2191 HintCode.UNUSED_IMPORT 2359 HintCode.UNUSED_IMPORT
2192 ]); 2360 ]);
2193 verify([source]); 2361 verify([source]);
2194 } 2362 }
2195 2363
2196 test_importOfNonLibrary_libraryDeclared() async { 2364 test_importOfNonLibrary_libraryDeclared() async {
2197 Source source = addSource(r''' 2365 Source source = addSource(r'''
2198 library lib; 2366 library lib;
2199 import 'part.dart'; 2367 import 'part.dart';
2200 A a;'''); 2368 A a;''');
2201 addNamedSource( 2369 addNamedSource(
2202 "/part.dart", 2370 "/part.dart",
2203 r''' 2371 r'''
2204 library lib1; 2372 library lib1;
2205 class A {}'''); 2373 class A {}''');
2206 await assertNoErrors(source); 2374 await computeAnalysisResult(source);
2375 assertNoErrors(source);
2207 verify([source]); 2376 verify([source]);
2208 } 2377 }
2209 2378
2210 test_importOfNonLibrary_libraryNotDeclared() async { 2379 test_importOfNonLibrary_libraryNotDeclared() async {
2211 Source source = addSource(r''' 2380 Source source = addSource(r'''
2212 library lib; 2381 library lib;
2213 import 'part.dart'; 2382 import 'part.dart';
2214 A a;'''); 2383 A a;''');
2215 addNamedSource("/part.dart", "class A {}"); 2384 addNamedSource("/part.dart", "class A {}");
2216 await assertNoErrors(source); 2385 await computeAnalysisResult(source);
2386 assertNoErrors(source);
2217 verify([source]); 2387 verify([source]);
2218 } 2388 }
2219 2389
2220 test_importPrefixes_withFirstLetterDifference() async { 2390 test_importPrefixes_withFirstLetterDifference() async {
2221 Source source = addSource(r''' 2391 Source source = addSource(r'''
2222 library L; 2392 library L;
2223 import 'lib1.dart' as math; 2393 import 'lib1.dart' as math;
2224 import 'lib2.dart' as path; 2394 import 'lib2.dart' as path;
2225 main() { 2395 main() {
2226 math.test1(); 2396 math.test1();
2227 path.test2(); 2397 path.test2();
2228 }'''); 2398 }''');
2229 addNamedSource( 2399 addNamedSource(
2230 "/lib1.dart", 2400 "/lib1.dart",
2231 r''' 2401 r'''
2232 library lib1; 2402 library lib1;
2233 test1() {}'''); 2403 test1() {}''');
2234 addNamedSource( 2404 addNamedSource(
2235 "/lib2.dart", 2405 "/lib2.dart",
2236 r''' 2406 r'''
2237 library lib2; 2407 library lib2;
2238 test2() {}'''); 2408 test2() {}''');
2239 await assertNoErrors(source); 2409 await computeAnalysisResult(source);
2410 assertNoErrors(source);
2240 verify([source]); 2411 verify([source]);
2241 } 2412 }
2242 2413
2243 test_inconsistentCaseExpressionTypes() async { 2414 test_inconsistentCaseExpressionTypes() async {
2244 Source source = addSource(r''' 2415 Source source = addSource(r'''
2245 f(var p) { 2416 f(var p) {
2246 switch (p) { 2417 switch (p) {
2247 case 1: 2418 case 1:
2248 break; 2419 break;
2249 case 2: 2420 case 2:
2250 break; 2421 break;
2251 } 2422 }
2252 }'''); 2423 }''');
2253 await assertNoErrors(source); 2424 await computeAnalysisResult(source);
2425 assertNoErrors(source);
2254 verify([source]); 2426 verify([source]);
2255 } 2427 }
2256 2428
2257 test_inconsistentMethodInheritance_accessors_typeParameter2() async { 2429 test_inconsistentMethodInheritance_accessors_typeParameter2() async {
2258 Source source = addSource(r''' 2430 Source source = addSource(r'''
2259 abstract class A<E> { 2431 abstract class A<E> {
2260 E get x {return null;} 2432 E get x {return null;}
2261 } 2433 }
2262 class B<E> { 2434 class B<E> {
2263 E get x {return null;} 2435 E get x {return null;}
2264 } 2436 }
2265 class C<E> extends A<E> implements B<E> {}'''); 2437 class C<E> extends A<E> implements B<E> {}''');
2266 await assertNoErrors(source); 2438 await computeAnalysisResult(source);
2439 assertNoErrors(source);
2267 verify([source]); 2440 verify([source]);
2268 } 2441 }
2269 2442
2270 test_inconsistentMethodInheritance_accessors_typeParameters1() async { 2443 test_inconsistentMethodInheritance_accessors_typeParameters1() async {
2271 Source source = addSource(r''' 2444 Source source = addSource(r'''
2272 abstract class A<E> { 2445 abstract class A<E> {
2273 E get x; 2446 E get x;
2274 } 2447 }
2275 abstract class B<E> { 2448 abstract class B<E> {
2276 E get x; 2449 E get x;
2277 } 2450 }
2278 class C<E> implements A<E>, B<E> { 2451 class C<E> implements A<E>, B<E> {
2279 E get x => null; 2452 E get x => null;
2280 }'''); 2453 }''');
2281 await assertNoErrors(source); 2454 await computeAnalysisResult(source);
2455 assertNoErrors(source);
2282 verify([source]); 2456 verify([source]);
2283 } 2457 }
2284 2458
2285 test_inconsistentMethodInheritance_accessors_typeParameters_diamond() async { 2459 test_inconsistentMethodInheritance_accessors_typeParameters_diamond() async {
2286 Source source = addSource(r''' 2460 Source source = addSource(r'''
2287 abstract class F<E> extends B<E> {} 2461 abstract class F<E> extends B<E> {}
2288 class D<E> extends F<E> { 2462 class D<E> extends F<E> {
2289 external E get g; 2463 external E get g;
2290 } 2464 }
2291 abstract class C<E> { 2465 abstract class C<E> {
2292 E get g; 2466 E get g;
2293 } 2467 }
2294 abstract class B<E> implements C<E> { 2468 abstract class B<E> implements C<E> {
2295 E get g { return null; } 2469 E get g { return null; }
2296 } 2470 }
2297 class A<E> extends B<E> implements D<E> { 2471 class A<E> extends B<E> implements D<E> {
2298 }'''); 2472 }''');
2299 await assertNoErrors(source); 2473 await computeAnalysisResult(source);
2474 assertNoErrors(source);
2300 verify([source]); 2475 verify([source]);
2301 } 2476 }
2302 2477
2303 test_inconsistentMethodInheritance_methods_typeParameter2() async { 2478 test_inconsistentMethodInheritance_methods_typeParameter2() async {
2304 Source source = addSource(r''' 2479 Source source = addSource(r'''
2305 class A<E> { 2480 class A<E> {
2306 x(E e) {} 2481 x(E e) {}
2307 } 2482 }
2308 class B<E> { 2483 class B<E> {
2309 x(E e) {} 2484 x(E e) {}
2310 } 2485 }
2311 class C<E> extends A<E> implements B<E> { 2486 class C<E> extends A<E> implements B<E> {
2312 x(E e) {} 2487 x(E e) {}
2313 }'''); 2488 }''');
2314 await assertNoErrors(source); 2489 await computeAnalysisResult(source);
2490 assertNoErrors(source);
2315 verify([source]); 2491 verify([source]);
2316 } 2492 }
2317 2493
2318 test_inconsistentMethodInheritance_methods_typeParameters1() async { 2494 test_inconsistentMethodInheritance_methods_typeParameters1() async {
2319 Source source = addSource(r''' 2495 Source source = addSource(r'''
2320 class A<E> { 2496 class A<E> {
2321 x(E e) {} 2497 x(E e) {}
2322 } 2498 }
2323 class B<E> { 2499 class B<E> {
2324 x(E e) {} 2500 x(E e) {}
2325 } 2501 }
2326 class C<E> implements A<E>, B<E> { 2502 class C<E> implements A<E>, B<E> {
2327 x(E e) {} 2503 x(E e) {}
2328 }'''); 2504 }''');
2329 await assertNoErrors(source); 2505 await computeAnalysisResult(source);
2506 assertNoErrors(source);
2330 verify([source]); 2507 verify([source]);
2331 } 2508 }
2332 2509
2333 test_inconsistentMethodInheritance_overrideTrumpsInherits_getter() async { 2510 test_inconsistentMethodInheritance_overrideTrumpsInherits_getter() async {
2334 // 16134 2511 // 16134
2335 Source source = addSource(r''' 2512 Source source = addSource(r'''
2336 class B<S> { 2513 class B<S> {
2337 S get g => null; 2514 S get g => null;
2338 } 2515 }
2339 abstract class I<U> { 2516 abstract class I<U> {
2340 U get g => null; 2517 U get g => null;
2341 } 2518 }
2342 class C extends B<double> implements I<int> { 2519 class C extends B<double> implements I<int> {
2343 num get g => null; 2520 num get g => null;
2344 }'''); 2521 }''');
2345 await assertNoErrors(source); 2522 await computeAnalysisResult(source);
2523 assertNoErrors(source);
2346 verify([source]); 2524 verify([source]);
2347 } 2525 }
2348 2526
2349 test_inconsistentMethodInheritance_overrideTrumpsInherits_method() async { 2527 test_inconsistentMethodInheritance_overrideTrumpsInherits_method() async {
2350 // 16134 2528 // 16134
2351 Source source = addSource(r''' 2529 Source source = addSource(r'''
2352 class B<S> { 2530 class B<S> {
2353 m(S s) => null; 2531 m(S s) => null;
2354 } 2532 }
2355 abstract class I<U> { 2533 abstract class I<U> {
2356 m(U u) => null; 2534 m(U u) => null;
2357 } 2535 }
2358 class C extends B<double> implements I<int> { 2536 class C extends B<double> implements I<int> {
2359 m(num n) => null; 2537 m(num n) => null;
2360 }'''); 2538 }''');
2361 await assertNoErrors(source); 2539 await computeAnalysisResult(source);
2540 assertNoErrors(source);
2362 verify([source]); 2541 verify([source]);
2363 } 2542 }
2364 2543
2365 test_inconsistentMethodInheritance_overrideTrumpsInherits_setter() async { 2544 test_inconsistentMethodInheritance_overrideTrumpsInherits_setter() async {
2366 // 16134 2545 // 16134
2367 Source source = addSource(r''' 2546 Source source = addSource(r'''
2368 class B<S> { 2547 class B<S> {
2369 set t(S s) {} 2548 set t(S s) {}
2370 } 2549 }
2371 abstract class I<U> { 2550 abstract class I<U> {
2372 set t(U u) {} 2551 set t(U u) {}
2373 } 2552 }
2374 class C extends B<double> implements I<int> { 2553 class C extends B<double> implements I<int> {
2375 set t(num n) {} 2554 set t(num n) {}
2376 }'''); 2555 }''');
2377 await assertNoErrors(source); 2556 await computeAnalysisResult(source);
2557 assertNoErrors(source);
2378 verify([source]); 2558 verify([source]);
2379 } 2559 }
2380 2560
2381 test_inconsistentMethodInheritance_simple() async { 2561 test_inconsistentMethodInheritance_simple() async {
2382 Source source = addSource(r''' 2562 Source source = addSource(r'''
2383 abstract class A { 2563 abstract class A {
2384 x(); 2564 x();
2385 } 2565 }
2386 abstract class B { 2566 abstract class B {
2387 x(); 2567 x();
2388 } 2568 }
2389 class C implements A, B { 2569 class C implements A, B {
2390 x() {} 2570 x() {}
2391 }'''); 2571 }''');
2392 await assertNoErrors(source); 2572 await computeAnalysisResult(source);
2573 assertNoErrors(source);
2393 verify([source]); 2574 verify([source]);
2394 } 2575 }
2395 2576
2396 test_initializingFormalForNonExistentField() async { 2577 test_initializingFormalForNonExistentField() async {
2397 Source source = addSource(r''' 2578 Source source = addSource(r'''
2398 class A { 2579 class A {
2399 int x; 2580 int x;
2400 A(this.x) {} 2581 A(this.x) {}
2401 }'''); 2582 }''');
2402 await assertNoErrors(source); 2583 await computeAnalysisResult(source);
2584 assertNoErrors(source);
2403 verify([source]); 2585 verify([source]);
2404 } 2586 }
2405 2587
2406 test_instance_creation_inside_annotation() async { 2588 test_instance_creation_inside_annotation() async {
2407 Source source = addSource(''' 2589 Source source = addSource('''
2408 class C { 2590 class C {
2409 const C(); 2591 const C();
2410 } 2592 }
2411 class D { 2593 class D {
2412 final C c; 2594 final C c;
2413 const D(this.c); 2595 const D(this.c);
2414 } 2596 }
2415 @D(const C()) 2597 @D(const C())
2416 f() {} 2598 f() {}
2417 '''); 2599 ''');
2418 await assertNoErrors(source); 2600 await computeAnalysisResult(source);
2601 assertNoErrors(source);
2419 verify([source]); 2602 verify([source]);
2420 } 2603 }
2421 2604
2422 test_instanceAccessToStaticMember_fromComment() async { 2605 test_instanceAccessToStaticMember_fromComment() async {
2423 Source source = addSource(r''' 2606 Source source = addSource(r'''
2424 class A { 2607 class A {
2425 static m() {} 2608 static m() {}
2426 } 2609 }
2427 /// [A.m] 2610 /// [A.m]
2428 main() { 2611 main() {
2429 }'''); 2612 }''');
2430 await assertNoErrors(source); 2613 await computeAnalysisResult(source);
2614 assertNoErrors(source);
2431 verify([source]); 2615 verify([source]);
2432 } 2616 }
2433 2617
2434 test_instanceAccessToStaticMember_topLevel() async { 2618 test_instanceAccessToStaticMember_topLevel() async {
2435 Source source = addSource(r''' 2619 Source source = addSource(r'''
2436 m() {} 2620 m() {}
2437 main() { 2621 main() {
2438 m(); 2622 m();
2439 }'''); 2623 }''');
2440 await assertNoErrors(source); 2624 await computeAnalysisResult(source);
2625 assertNoErrors(source);
2441 verify([source]); 2626 verify([source]);
2442 } 2627 }
2443 2628
2444 test_instanceMemberAccessFromStatic_fromComment() async { 2629 test_instanceMemberAccessFromStatic_fromComment() async {
2445 Source source = addSource(r''' 2630 Source source = addSource(r'''
2446 class A { 2631 class A {
2447 m() {} 2632 m() {}
2448 /// [m] 2633 /// [m]
2449 static foo() { 2634 static foo() {
2450 } 2635 }
2451 }'''); 2636 }''');
2452 await assertNoErrors(source); 2637 await computeAnalysisResult(source);
2638 assertNoErrors(source);
2453 verify([source]); 2639 verify([source]);
2454 } 2640 }
2455 2641
2456 test_instanceMethodNameCollidesWithSuperclassStatic_field() async { 2642 test_instanceMethodNameCollidesWithSuperclassStatic_field() async {
2457 Source source = addSource(r''' 2643 Source source = addSource(r'''
2458 import 'lib.dart'; 2644 import 'lib.dart';
2459 class B extends A { 2645 class B extends A {
2460 _m() {} 2646 _m() {}
2461 }'''); 2647 }''');
2462 addNamedSource( 2648 addNamedSource(
2463 "/lib.dart", 2649 "/lib.dart",
2464 r''' 2650 r'''
2465 library L; 2651 library L;
2466 class A { 2652 class A {
2467 static var _m; 2653 static var _m;
2468 }'''); 2654 }''');
2469 await assertNoErrors(source); 2655 await computeAnalysisResult(source);
2656 assertNoErrors(source);
2470 verify([source]); 2657 verify([source]);
2471 } 2658 }
2472 2659
2473 test_instanceMethodNameCollidesWithSuperclassStatic_method() async { 2660 test_instanceMethodNameCollidesWithSuperclassStatic_method() async {
2474 Source source = addSource(r''' 2661 Source source = addSource(r'''
2475 import 'lib.dart'; 2662 import 'lib.dart';
2476 class B extends A { 2663 class B extends A {
2477 _m() {} 2664 _m() {}
2478 }'''); 2665 }''');
2479 addNamedSource( 2666 addNamedSource(
2480 "/lib.dart", 2667 "/lib.dart",
2481 r''' 2668 r'''
2482 library L; 2669 library L;
2483 class A { 2670 class A {
2484 static _m() {} 2671 static _m() {}
2485 }'''); 2672 }''');
2486 await assertNoErrors(source); 2673 await computeAnalysisResult(source);
2674 assertNoErrors(source);
2487 verify([source]); 2675 verify([source]);
2488 } 2676 }
2489 2677
2490 test_invalidAnnotation_constantVariable_field() async { 2678 test_invalidAnnotation_constantVariable_field() async {
2491 Source source = addSource(r''' 2679 Source source = addSource(r'''
2492 @A.C 2680 @A.C
2493 class A { 2681 class A {
2494 static const C = 0; 2682 static const C = 0;
2495 }'''); 2683 }''');
2496 await assertNoErrors(source); 2684 await computeAnalysisResult(source);
2685 assertNoErrors(source);
2497 verify([source]); 2686 verify([source]);
2498 } 2687 }
2499 2688
2500 test_invalidAnnotation_constantVariable_field_importWithPrefix() async { 2689 test_invalidAnnotation_constantVariable_field_importWithPrefix() async {
2501 addNamedSource( 2690 addNamedSource(
2502 "/lib.dart", 2691 "/lib.dart",
2503 r''' 2692 r'''
2504 library lib; 2693 library lib;
2505 class A { 2694 class A {
2506 static const C = 0; 2695 static const C = 0;
2507 }'''); 2696 }''');
2508 Source source = addSource(r''' 2697 Source source = addSource(r'''
2509 import 'lib.dart' as p; 2698 import 'lib.dart' as p;
2510 @p.A.C 2699 @p.A.C
2511 main() { 2700 main() {
2512 }'''); 2701 }''');
2513 await assertNoErrors(source); 2702 await computeAnalysisResult(source);
2703 assertNoErrors(source);
2514 verify([source]); 2704 verify([source]);
2515 } 2705 }
2516 2706
2517 test_invalidAnnotation_constantVariable_topLevel() async { 2707 test_invalidAnnotation_constantVariable_topLevel() async {
2518 Source source = addSource(r''' 2708 Source source = addSource(r'''
2519 const C = 0; 2709 const C = 0;
2520 @C 2710 @C
2521 main() { 2711 main() {
2522 }'''); 2712 }''');
2523 await assertNoErrors(source); 2713 await computeAnalysisResult(source);
2714 assertNoErrors(source);
2524 verify([source]); 2715 verify([source]);
2525 } 2716 }
2526 2717
2527 test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() async { 2718 test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() async {
2528 addNamedSource( 2719 addNamedSource(
2529 "/lib.dart", 2720 "/lib.dart",
2530 r''' 2721 r'''
2531 library lib; 2722 library lib;
2532 const C = 0;'''); 2723 const C = 0;''');
2533 Source source = addSource(r''' 2724 Source source = addSource(r'''
2534 import 'lib.dart' as p; 2725 import 'lib.dart' as p;
2535 @p.C 2726 @p.C
2536 main() { 2727 main() {
2537 }'''); 2728 }''');
2538 await assertNoErrors(source); 2729 await computeAnalysisResult(source);
2730 assertNoErrors(source);
2539 verify([source]); 2731 verify([source]);
2540 } 2732 }
2541 2733
2542 test_invalidAnnotation_constConstructor_importWithPrefix() async { 2734 test_invalidAnnotation_constConstructor_importWithPrefix() async {
2543 addNamedSource( 2735 addNamedSource(
2544 "/lib.dart", 2736 "/lib.dart",
2545 r''' 2737 r'''
2546 library lib; 2738 library lib;
2547 class A { 2739 class A {
2548 const A(int p); 2740 const A(int p);
2549 }'''); 2741 }''');
2550 Source source = addSource(r''' 2742 Source source = addSource(r'''
2551 import 'lib.dart' as p; 2743 import 'lib.dart' as p;
2552 @p.A(42) 2744 @p.A(42)
2553 main() { 2745 main() {
2554 }'''); 2746 }''');
2555 await assertNoErrors(source); 2747 await computeAnalysisResult(source);
2748 assertNoErrors(source);
2556 verify([source]); 2749 verify([source]);
2557 } 2750 }
2558 2751
2559 test_invalidAnnotation_constConstructor_named_importWithPrefix() async { 2752 test_invalidAnnotation_constConstructor_named_importWithPrefix() async {
2560 addNamedSource( 2753 addNamedSource(
2561 "/lib.dart", 2754 "/lib.dart",
2562 r''' 2755 r'''
2563 library lib; 2756 library lib;
2564 class A { 2757 class A {
2565 const A.named(int p); 2758 const A.named(int p);
2566 }'''); 2759 }''');
2567 Source source = addSource(r''' 2760 Source source = addSource(r'''
2568 import 'lib.dart' as p; 2761 import 'lib.dart' as p;
2569 @p.A.named(42) 2762 @p.A.named(42)
2570 main() { 2763 main() {
2571 }'''); 2764 }''');
2572 await assertNoErrors(source); 2765 await computeAnalysisResult(source);
2766 assertNoErrors(source);
2573 verify([source]); 2767 verify([source]);
2574 } 2768 }
2575 2769
2576 test_invalidAssignment() async { 2770 test_invalidAssignment() async {
2577 Source source = addSource(r''' 2771 Source source = addSource(r'''
2578 f() { 2772 f() {
2579 var x; 2773 var x;
2580 var y; 2774 var y;
2581 x = y; 2775 x = y;
2582 }'''); 2776 }''');
2583 await assertNoErrors(source); 2777 await computeAnalysisResult(source);
2778 assertNoErrors(source);
2584 verify([source]); 2779 verify([source]);
2585 } 2780 }
2586 2781
2587 test_invalidAssignment_compoundAssignment() async { 2782 test_invalidAssignment_compoundAssignment() async {
2588 Source source = addSource(r''' 2783 Source source = addSource(r'''
2589 class byte { 2784 class byte {
2590 int _value; 2785 int _value;
2591 byte(this._value); 2786 byte(this._value);
2592 byte operator +(int val) { return this; } 2787 byte operator +(int val) { return this; }
2593 } 2788 }
2594 2789
2595 void main() { 2790 void main() {
2596 byte b = new byte(52); 2791 byte b = new byte(52);
2597 b += 3; 2792 b += 3;
2598 }'''); 2793 }''');
2599 await assertNoErrors(source); 2794 await computeAnalysisResult(source);
2795 assertNoErrors(source);
2600 verify([source]); 2796 verify([source]);
2601 } 2797 }
2602 2798
2603 test_invalidAssignment_defaultValue_named() async { 2799 test_invalidAssignment_defaultValue_named() async {
2604 Source source = addSource(r''' 2800 Source source = addSource(r'''
2605 f({String x: '0'}) { 2801 f({String x: '0'}) {
2606 }'''); 2802 }''');
2607 await assertNoErrors(source); 2803 await computeAnalysisResult(source);
2804 assertNoErrors(source);
2608 verify([source]); 2805 verify([source]);
2609 } 2806 }
2610 2807
2611 test_invalidAssignment_defaultValue_optional() async { 2808 test_invalidAssignment_defaultValue_optional() async {
2612 Source source = addSource(r''' 2809 Source source = addSource(r'''
2613 f([String x = '0']) { 2810 f([String x = '0']) {
2614 }'''); 2811 }''');
2615 await assertNoErrors(source); 2812 await computeAnalysisResult(source);
2813 assertNoErrors(source);
2616 verify([source]); 2814 verify([source]);
2617 } 2815 }
2618 2816
2619 test_invalidAssignment_ifNullAssignment_compatibleType() async { 2817 test_invalidAssignment_ifNullAssignment_compatibleType() async {
2620 Source source = addSource(''' 2818 Source source = addSource('''
2621 void f(int i) { 2819 void f(int i) {
2622 num n; 2820 num n;
2623 n ??= i; 2821 n ??= i;
2624 } 2822 }
2625 '''); 2823 ''');
2626 await assertNoErrors(source); 2824 await computeAnalysisResult(source);
2825 assertNoErrors(source);
2627 verify([source]); 2826 verify([source]);
2628 } 2827 }
2629 2828
2630 test_invalidAssignment_ifNullAssignment_sameType() async { 2829 test_invalidAssignment_ifNullAssignment_sameType() async {
2631 Source source = addSource(''' 2830 Source source = addSource('''
2632 void f(int i) { 2831 void f(int i) {
2633 int j; 2832 int j;
2634 j ??= i; 2833 j ??= i;
2635 } 2834 }
2636 '''); 2835 ''');
2637 await assertNoErrors(source); 2836 await computeAnalysisResult(source);
2837 assertNoErrors(source);
2638 verify([source]); 2838 verify([source]);
2639 } 2839 }
2640 2840
2641 test_invalidAssignment_implicitlyImplementFunctionViaCall_1() async { 2841 test_invalidAssignment_implicitlyImplementFunctionViaCall_1() async {
2642 // 18341 2842 // 18341
2643 // 2843 //
2644 // This test and 2844 // This test and
2645 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()' 2845 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()'
2646 // are closely related: here we see that 'I' checks as a subtype of 2846 // are closely related: here we see that 'I' checks as a subtype of
2647 // 'IntToInt'. 2847 // 'IntToInt'.
2648 Source source = addSource(r''' 2848 Source source = addSource(r'''
2649 class I { 2849 class I {
2650 int call(int x) => 0; 2850 int call(int x) => 0;
2651 } 2851 }
2652 class C implements I { 2852 class C implements I {
2653 noSuchMethod(_) => null; 2853 noSuchMethod(_) => null;
2654 } 2854 }
2655 typedef int IntToInt(int x); 2855 typedef int IntToInt(int x);
2656 IntToInt f = new I();'''); 2856 IntToInt f = new I();''');
2657 await assertNoErrors(source); 2857 await computeAnalysisResult(source);
2858 assertNoErrors(source);
2658 verify([source]); 2859 verify([source]);
2659 } 2860 }
2660 2861
2661 test_invalidAssignment_implicitlyImplementFunctionViaCall_2() async { 2862 test_invalidAssignment_implicitlyImplementFunctionViaCall_2() async {
2662 // 18341 2863 // 18341
2663 // 2864 //
2664 // Here 'C' checks as a subtype of 'I', but 'C' does not 2865 // Here 'C' checks as a subtype of 'I', but 'C' does not
2665 // check as a subtype of 'IntToInt'. Together with 2866 // check as a subtype of 'IntToInt'. Together with
2666 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_1()' we see 2867 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_1()' we see
2667 // that subtyping is not transitive here. 2868 // that subtyping is not transitive here.
2668 Source source = addSource(r''' 2869 Source source = addSource(r'''
2669 class I { 2870 class I {
2670 int call(int x) => 0; 2871 int call(int x) => 0;
2671 } 2872 }
2672 class C implements I { 2873 class C implements I {
2673 noSuchMethod(_) => null; 2874 noSuchMethod(_) => null;
2674 } 2875 }
2675 typedef int IntToInt(int x); 2876 typedef int IntToInt(int x);
2676 IntToInt f = new C();'''); 2877 IntToInt f = new C();''');
2677 await assertNoErrors(source); 2878 await computeAnalysisResult(source);
2879 assertNoErrors(source);
2678 verify([source]); 2880 verify([source]);
2679 } 2881 }
2680 2882
2681 test_invalidAssignment_implicitlyImplementFunctionViaCall_3() async { 2883 test_invalidAssignment_implicitlyImplementFunctionViaCall_3() async {
2682 // 18341 2884 // 18341
2683 // 2885 //
2684 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()', 2886 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()',
2685 // but uses type 'Function' instead of more precise type 'IntToInt' for 'f'. 2887 // but uses type 'Function' instead of more precise type 'IntToInt' for 'f'.
2686 Source source = addSource(r''' 2888 Source source = addSource(r'''
2687 class I { 2889 class I {
2688 int call(int x) => 0; 2890 int call(int x) => 0;
2689 } 2891 }
2690 class C implements I { 2892 class C implements I {
2691 noSuchMethod(_) => null; 2893 noSuchMethod(_) => null;
2692 } 2894 }
2693 typedef int IntToInt(int x); 2895 typedef int IntToInt(int x);
2694 Function f = new C();'''); 2896 Function f = new C();''');
2695 await assertNoErrors(source); 2897 await computeAnalysisResult(source);
2898 assertNoErrors(source);
2696 verify([source]); 2899 verify([source]);
2697 } 2900 }
2698 2901
2699 test_invalidAssignment_implicitlyImplementFunctionViaCall_4() async { 2902 test_invalidAssignment_implicitlyImplementFunctionViaCall_4() async {
2700 // 18341 2903 // 18341
2701 // 2904 //
2702 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()', 2905 // Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()',
2703 // but uses type 'VoidToInt' instead of more precise type 'IntToInt' for 2906 // but uses type 'VoidToInt' instead of more precise type 'IntToInt' for
2704 // 'f'. 2907 // 'f'.
2705 // 2908 //
2706 // Here 'C <: IntToInt <: VoidToInt', but the spec gives no transitivity 2909 // Here 'C <: IntToInt <: VoidToInt', but the spec gives no transitivity
2707 // rule for '<:'. However, many of the :/tools/test.py tests assume this 2910 // rule for '<:'. However, many of the :/tools/test.py tests assume this
2708 // transitivity for 'JsBuilder' objects, assigning them to 2911 // transitivity for 'JsBuilder' objects, assigning them to
2709 // '(String) -> dynamic'. The declared type of 'JsBuilder.call' is 2912 // '(String) -> dynamic'. The declared type of 'JsBuilder.call' is
2710 // '(String, [dynamic]) -> Expression'. 2913 // '(String, [dynamic]) -> Expression'.
2711 Source source = addSource(r''' 2914 Source source = addSource(r'''
2712 class I { 2915 class I {
2713 int call([int x]) => 0; 2916 int call([int x]) => 0;
2714 } 2917 }
2715 class C implements I { 2918 class C implements I {
2716 noSuchMethod(_) => null; 2919 noSuchMethod(_) => null;
2717 } 2920 }
2718 typedef int VoidToInt(); 2921 typedef int VoidToInt();
2719 VoidToInt f = new C();'''); 2922 VoidToInt f = new C();''');
2720 await assertNoErrors(source); 2923 await computeAnalysisResult(source);
2924 assertNoErrors(source);
2721 verify([source]); 2925 verify([source]);
2722 } 2926 }
2723 2927
2724 test_invalidAssignment_toDynamic() async { 2928 test_invalidAssignment_toDynamic() async {
2725 Source source = addSource(r''' 2929 Source source = addSource(r'''
2726 f() { 2930 f() {
2727 var g; 2931 var g;
2728 g = () => 0; 2932 g = () => 0;
2729 }'''); 2933 }''');
2730 await assertNoErrors(source); 2934 await computeAnalysisResult(source);
2935 assertNoErrors(source);
2731 verify([source]); 2936 verify([source]);
2732 } 2937 }
2733 2938
2734 test_invalidFactoryNameNotAClass() async { 2939 test_invalidFactoryNameNotAClass() async {
2735 Source source = addSource(r''' 2940 Source source = addSource(r'''
2736 class A { 2941 class A {
2737 factory A() => null; 2942 factory A() => null;
2738 }'''); 2943 }''');
2739 await assertNoErrors(source); 2944 await computeAnalysisResult(source);
2945 assertNoErrors(source);
2740 verify([source]); 2946 verify([source]);
2741 } 2947 }
2742 2948
2743 test_invalidIdentifierInAsync() async { 2949 test_invalidIdentifierInAsync() async {
2744 Source source = addSource(r''' 2950 Source source = addSource(r'''
2745 class A { 2951 class A {
2746 m() { 2952 m() {
2747 int async; 2953 int async;
2748 int await; 2954 int await;
2749 int yield; 2955 int yield;
2750 } 2956 }
2751 }'''); 2957 }''');
2752 await assertNoErrors(source); 2958 await computeAnalysisResult(source);
2959 assertNoErrors(source);
2753 verify([source]); 2960 verify([source]);
2754 } 2961 }
2755 2962
2756 test_invalidMethodOverrideNamedParamType() async { 2963 test_invalidMethodOverrideNamedParamType() async {
2757 Source source = addSource(r''' 2964 Source source = addSource(r'''
2758 class A { 2965 class A {
2759 m({int a}) {} 2966 m({int a}) {}
2760 } 2967 }
2761 class B implements A { 2968 class B implements A {
2762 m({int a, int b}) {} 2969 m({int a, int b}) {}
2763 }'''); 2970 }''');
2764 await assertNoErrors(source); 2971 await computeAnalysisResult(source);
2972 assertNoErrors(source);
2765 verify([source]); 2973 verify([source]);
2766 } 2974 }
2767 2975
2768 test_invalidOverrideDifferentDefaultValues_named() async { 2976 test_invalidOverrideDifferentDefaultValues_named() async {
2769 Source source = addSource(r''' 2977 Source source = addSource(r'''
2770 class A { 2978 class A {
2771 m({int p : 0}) {} 2979 m({int p : 0}) {}
2772 } 2980 }
2773 class B extends A { 2981 class B extends A {
2774 m({int p : 0}) {} 2982 m({int p : 0}) {}
2775 }'''); 2983 }''');
2776 await assertNoErrors(source); 2984 await computeAnalysisResult(source);
2985 assertNoErrors(source);
2777 verify([source]); 2986 verify([source]);
2778 } 2987 }
2779 2988
2780 test_invalidOverrideDifferentDefaultValues_named_function() async { 2989 test_invalidOverrideDifferentDefaultValues_named_function() async {
2781 Source source = addSource(r''' 2990 Source source = addSource(r'''
2782 nothing() => 'nothing'; 2991 nothing() => 'nothing';
2783 class A { 2992 class A {
2784 thing(String a, {orElse : nothing}) {} 2993 thing(String a, {orElse : nothing}) {}
2785 } 2994 }
2786 class B extends A { 2995 class B extends A {
2787 thing(String a, {orElse : nothing}) {} 2996 thing(String a, {orElse : nothing}) {}
2788 }'''); 2997 }''');
2789 await assertNoErrors(source); 2998 await computeAnalysisResult(source);
2999 assertNoErrors(source);
2790 verify([source]); 3000 verify([source]);
2791 } 3001 }
2792 3002
2793 test_invalidOverrideDifferentDefaultValues_positional() async { 3003 test_invalidOverrideDifferentDefaultValues_positional() async {
2794 Source source = addSource(r''' 3004 Source source = addSource(r'''
2795 class A { 3005 class A {
2796 m([int p = 0]) {} 3006 m([int p = 0]) {}
2797 } 3007 }
2798 class B extends A { 3008 class B extends A {
2799 m([int p = 0]) {} 3009 m([int p = 0]) {}
2800 }'''); 3010 }''');
2801 await assertNoErrors(source); 3011 await computeAnalysisResult(source);
3012 assertNoErrors(source);
2802 verify([source]); 3013 verify([source]);
2803 } 3014 }
2804 3015
2805 test_invalidOverrideDifferentDefaultValues_positional_changedOrder() async { 3016 test_invalidOverrideDifferentDefaultValues_positional_changedOrder() async {
2806 Source source = addSource(r''' 3017 Source source = addSource(r'''
2807 class A { 3018 class A {
2808 m([int a = 0, String b = '0']) {} 3019 m([int a = 0, String b = '0']) {}
2809 } 3020 }
2810 class B extends A { 3021 class B extends A {
2811 m([int b = 0, String a = '0']) {} 3022 m([int b = 0, String a = '0']) {}
2812 }'''); 3023 }''');
2813 await assertNoErrors(source); 3024 await computeAnalysisResult(source);
3025 assertNoErrors(source);
2814 verify([source]); 3026 verify([source]);
2815 } 3027 }
2816 3028
2817 test_invalidOverrideDifferentDefaultValues_positional_function() async { 3029 test_invalidOverrideDifferentDefaultValues_positional_function() async {
2818 Source source = addSource(r''' 3030 Source source = addSource(r'''
2819 nothing() => 'nothing'; 3031 nothing() => 'nothing';
2820 class A { 3032 class A {
2821 thing(String a, [orElse = nothing]) {} 3033 thing(String a, [orElse = nothing]) {}
2822 } 3034 }
2823 class B extends A { 3035 class B extends A {
2824 thing(String a, [orElse = nothing]) {} 3036 thing(String a, [orElse = nothing]) {}
2825 }'''); 3037 }''');
2826 await assertNoErrors(source); 3038 await computeAnalysisResult(source);
3039 assertNoErrors(source);
2827 verify([source]); 3040 verify([source]);
2828 } 3041 }
2829 3042
2830 test_invalidOverrideNamed_unorderedNamedParameter() async { 3043 test_invalidOverrideNamed_unorderedNamedParameter() async {
2831 Source source = addSource(r''' 3044 Source source = addSource(r'''
2832 class A { 3045 class A {
2833 m({a, b}) {} 3046 m({a, b}) {}
2834 } 3047 }
2835 class B extends A { 3048 class B extends A {
2836 m({b, a}) {} 3049 m({b, a}) {}
2837 }'''); 3050 }''');
2838 await assertNoErrors(source); 3051 await computeAnalysisResult(source);
3052 assertNoErrors(source);
2839 verify([source]); 3053 verify([source]);
2840 } 3054 }
2841 3055
2842 test_invalidOverrideRequired_less() async { 3056 test_invalidOverrideRequired_less() async {
2843 Source source = addSource(r''' 3057 Source source = addSource(r'''
2844 class A { 3058 class A {
2845 m(a, b) {} 3059 m(a, b) {}
2846 } 3060 }
2847 class B extends A { 3061 class B extends A {
2848 m(a, [b]) {} 3062 m(a, [b]) {}
2849 }'''); 3063 }''');
2850 await assertNoErrors(source); 3064 await computeAnalysisResult(source);
3065 assertNoErrors(source);
2851 verify([source]); 3066 verify([source]);
2852 } 3067 }
2853 3068
2854 test_invalidOverrideRequired_same() async { 3069 test_invalidOverrideRequired_same() async {
2855 Source source = addSource(r''' 3070 Source source = addSource(r'''
2856 class A { 3071 class A {
2857 m(a) {} 3072 m(a) {}
2858 } 3073 }
2859 class B extends A { 3074 class B extends A {
2860 m(a) {} 3075 m(a) {}
2861 }'''); 3076 }''');
2862 await assertNoErrors(source); 3077 await computeAnalysisResult(source);
3078 assertNoErrors(source);
2863 verify([source]); 3079 verify([source]);
2864 } 3080 }
2865 3081
2866 test_invalidOverrideReturnType_returnType_interface() async { 3082 test_invalidOverrideReturnType_returnType_interface() async {
2867 Source source = addNamedSource( 3083 Source source = addNamedSource(
2868 "/test.dart", 3084 "/test.dart",
2869 r''' 3085 r'''
2870 abstract class A { 3086 abstract class A {
2871 num m(); 3087 num m();
2872 } 3088 }
2873 class B implements A { 3089 class B implements A {
2874 int m() { return 1; } 3090 int m() { return 1; }
2875 }'''); 3091 }''');
2876 await assertNoErrors(source); 3092 await computeAnalysisResult(source);
3093 assertNoErrors(source);
2877 verify([source]); 3094 verify([source]);
2878 } 3095 }
2879 3096
2880 test_invalidOverrideReturnType_returnType_interface2() async { 3097 test_invalidOverrideReturnType_returnType_interface2() async {
2881 Source source = addNamedSource( 3098 Source source = addNamedSource(
2882 "/test.dart", 3099 "/test.dart",
2883 r''' 3100 r'''
2884 abstract class A { 3101 abstract class A {
2885 num m(); 3102 num m();
2886 } 3103 }
2887 abstract class B implements A { 3104 abstract class B implements A {
2888 } 3105 }
2889 class C implements B { 3106 class C implements B {
2890 int m() { return 1; } 3107 int m() { return 1; }
2891 }'''); 3108 }''');
2892 await assertNoErrors(source); 3109 await computeAnalysisResult(source);
3110 assertNoErrors(source);
2893 verify([source]); 3111 verify([source]);
2894 } 3112 }
2895 3113
2896 test_invalidOverrideReturnType_returnType_mixin() async { 3114 test_invalidOverrideReturnType_returnType_mixin() async {
2897 Source source = addNamedSource( 3115 Source source = addNamedSource(
2898 "/test.dart", 3116 "/test.dart",
2899 r''' 3117 r'''
2900 class A { 3118 class A {
2901 num m() { return 0; } 3119 num m() { return 0; }
2902 } 3120 }
2903 class B extends Object with A { 3121 class B extends Object with A {
2904 int m() { return 1; } 3122 int m() { return 1; }
2905 }'''); 3123 }''');
2906 await assertNoErrors(source); 3124 await computeAnalysisResult(source);
3125 assertNoErrors(source);
2907 verify([source]); 3126 verify([source]);
2908 } 3127 }
2909 3128
2910 test_invalidOverrideReturnType_returnType_parameterizedTypes() async { 3129 test_invalidOverrideReturnType_returnType_parameterizedTypes() async {
2911 Source source = addSource(r''' 3130 Source source = addSource(r'''
2912 abstract class A<E> { 3131 abstract class A<E> {
2913 List<E> m(); 3132 List<E> m();
2914 } 3133 }
2915 class B extends A<dynamic> { 3134 class B extends A<dynamic> {
2916 List<dynamic> m() { return new List<dynamic>(); } 3135 List<dynamic> m() { return new List<dynamic>(); }
2917 }'''); 3136 }''');
2918 await assertNoErrors(source); 3137 await computeAnalysisResult(source);
3138 assertNoErrors(source);
2919 verify([source]); 3139 verify([source]);
2920 } 3140 }
2921 3141
2922 test_invalidOverrideReturnType_returnType_sameType() async { 3142 test_invalidOverrideReturnType_returnType_sameType() async {
2923 Source source = addNamedSource( 3143 Source source = addNamedSource(
2924 "/test.dart", 3144 "/test.dart",
2925 r''' 3145 r'''
2926 class A { 3146 class A {
2927 int m() { return 0; } 3147 int m() { return 0; }
2928 } 3148 }
2929 class B extends A { 3149 class B extends A {
2930 int m() { return 1; } 3150 int m() { return 1; }
2931 }'''); 3151 }''');
2932 await assertNoErrors(source); 3152 await computeAnalysisResult(source);
3153 assertNoErrors(source);
2933 verify([source]); 3154 verify([source]);
2934 } 3155 }
2935 3156
2936 test_invalidOverrideReturnType_returnType_superclass() async { 3157 test_invalidOverrideReturnType_returnType_superclass() async {
2937 Source source = addNamedSource( 3158 Source source = addNamedSource(
2938 "/test.dart", 3159 "/test.dart",
2939 r''' 3160 r'''
2940 class A { 3161 class A {
2941 num m() { return 0; } 3162 num m() { return 0; }
2942 } 3163 }
2943 class B extends A { 3164 class B extends A {
2944 int m() { return 1; } 3165 int m() { return 1; }
2945 }'''); 3166 }''');
2946 await assertNoErrors(source); 3167 await computeAnalysisResult(source);
3168 assertNoErrors(source);
2947 verify([source]); 3169 verify([source]);
2948 } 3170 }
2949 3171
2950 test_invalidOverrideReturnType_returnType_superclass2() async { 3172 test_invalidOverrideReturnType_returnType_superclass2() async {
2951 Source source = addNamedSource( 3173 Source source = addNamedSource(
2952 "/test.dart", 3174 "/test.dart",
2953 r''' 3175 r'''
2954 class A { 3176 class A {
2955 num m() { return 0; } 3177 num m() { return 0; }
2956 } 3178 }
2957 class B extends A { 3179 class B extends A {
2958 } 3180 }
2959 class C extends B { 3181 class C extends B {
2960 int m() { return 1; } 3182 int m() { return 1; }
2961 }'''); 3183 }''');
2962 await assertNoErrors(source); 3184 await computeAnalysisResult(source);
3185 assertNoErrors(source);
2963 verify([source]); 3186 verify([source]);
2964 } 3187 }
2965 3188
2966 test_invalidOverrideReturnType_returnType_void() async { 3189 test_invalidOverrideReturnType_returnType_void() async {
2967 Source source = addSource(r''' 3190 Source source = addSource(r'''
2968 class A { 3191 class A {
2969 void m() {} 3192 void m() {}
2970 } 3193 }
2971 class B extends A { 3194 class B extends A {
2972 int m() { return 0; } 3195 int m() { return 0; }
2973 }'''); 3196 }''');
2974 await assertNoErrors(source); 3197 await computeAnalysisResult(source);
3198 assertNoErrors(source);
2975 verify([source]); 3199 verify([source]);
2976 } 3200 }
2977 3201
2978 test_invalidReferenceToThis_constructor() async { 3202 test_invalidReferenceToThis_constructor() async {
2979 Source source = addSource(r''' 3203 Source source = addSource(r'''
2980 class A { 3204 class A {
2981 A() { 3205 A() {
2982 var v = this; 3206 var v = this;
2983 } 3207 }
2984 }'''); 3208 }''');
2985 await assertNoErrors(source); 3209 await computeAnalysisResult(source);
3210 assertNoErrors(source);
2986 verify([source]); 3211 verify([source]);
2987 } 3212 }
2988 3213
2989 test_invalidReferenceToThis_instanceMethod() async { 3214 test_invalidReferenceToThis_instanceMethod() async {
2990 Source source = addSource(r''' 3215 Source source = addSource(r'''
2991 class A { 3216 class A {
2992 m() { 3217 m() {
2993 var v = this; 3218 var v = this;
2994 } 3219 }
2995 }'''); 3220 }''');
2996 await assertNoErrors(source); 3221 await computeAnalysisResult(source);
3222 assertNoErrors(source);
2997 verify([source]); 3223 verify([source]);
2998 } 3224 }
2999 3225
3000 test_invalidTypeArgumentForKey() async { 3226 test_invalidTypeArgumentForKey() async {
3001 Source source = addSource(r''' 3227 Source source = addSource(r'''
3002 class A { 3228 class A {
3003 m() { 3229 m() {
3004 return const <int, int>{}; 3230 return const <int, int>{};
3005 } 3231 }
3006 }'''); 3232 }''');
3007 await assertNoErrors(source); 3233 await computeAnalysisResult(source);
3234 assertNoErrors(source);
3008 verify([source]); 3235 verify([source]);
3009 } 3236 }
3010 3237
3011 test_invalidTypeArgumentInConstList() async { 3238 test_invalidTypeArgumentInConstList() async {
3012 Source source = addSource(r''' 3239 Source source = addSource(r'''
3013 class A<E> { 3240 class A<E> {
3014 m() { 3241 m() {
3015 return <E>[]; 3242 return <E>[];
3016 } 3243 }
3017 }'''); 3244 }''');
3018 await assertNoErrors(source); 3245 await computeAnalysisResult(source);
3246 assertNoErrors(source);
3019 verify([source]); 3247 verify([source]);
3020 } 3248 }
3021 3249
3022 test_invalidTypeArgumentInConstMap() async { 3250 test_invalidTypeArgumentInConstMap() async {
3023 Source source = addSource(r''' 3251 Source source = addSource(r'''
3024 class A<E> { 3252 class A<E> {
3025 m() { 3253 m() {
3026 return <String, E>{}; 3254 return <String, E>{};
3027 } 3255 }
3028 }'''); 3256 }''');
3029 await assertNoErrors(source); 3257 await computeAnalysisResult(source);
3258 assertNoErrors(source);
3030 verify([source]); 3259 verify([source]);
3031 } 3260 }
3032 3261
3033 test_invocationOfNonFunction_dynamic() async { 3262 test_invocationOfNonFunction_dynamic() async {
3034 Source source = addSource(r''' 3263 Source source = addSource(r'''
3035 class A { 3264 class A {
3036 var f; 3265 var f;
3037 } 3266 }
3038 class B extends A { 3267 class B extends A {
3039 g() { 3268 g() {
3040 f(); 3269 f();
3041 } 3270 }
3042 }'''); 3271 }''');
3043 await assertNoErrors(source); 3272 await computeAnalysisResult(source);
3273 assertNoErrors(source);
3044 verify([source]); 3274 verify([source]);
3045 } 3275 }
3046 3276
3047 test_invocationOfNonFunction_functionTypeTypeParameter() async { 3277 test_invocationOfNonFunction_functionTypeTypeParameter() async {
3048 Source source = addSource(r''' 3278 Source source = addSource(r'''
3049 typedef void Action<T>(T x); 3279 typedef void Action<T>(T x);
3050 class C<T, U extends Action<T>> { 3280 class C<T, U extends Action<T>> {
3051 T value; 3281 T value;
3052 U action; 3282 U action;
3053 C(this.value, [this.action]); 3283 C(this.value, [this.action]);
3054 void act() { 3284 void act() {
3055 action(value); 3285 action(value);
3056 } 3286 }
3057 } 3287 }
3058 '''); 3288 ''');
3059 await assertNoErrors(source); 3289 await computeAnalysisResult(source);
3290 assertNoErrors(source);
3060 verify([source]); 3291 verify([source]);
3061 } 3292 }
3062 3293
3063 test_invocationOfNonFunction_getter() async { 3294 test_invocationOfNonFunction_getter() async {
3064 Source source = addSource(r''' 3295 Source source = addSource(r'''
3065 class A { 3296 class A {
3066 var g; 3297 var g;
3067 } 3298 }
3068 f() { 3299 f() {
3069 A a; 3300 A a;
3070 a.g(); 3301 a.g();
3071 }'''); 3302 }''');
3072 await assertNoErrors(source); 3303 await computeAnalysisResult(source);
3304 assertNoErrors(source);
3073 verify([source]); 3305 verify([source]);
3074 } 3306 }
3075 3307
3076 test_invocationOfNonFunction_localVariable() async { 3308 test_invocationOfNonFunction_localVariable() async {
3077 Source source = addSource(r''' 3309 Source source = addSource(r'''
3078 f() { 3310 f() {
3079 var g; 3311 var g;
3080 g(); 3312 g();
3081 }'''); 3313 }''');
3082 await assertNoErrors(source); 3314 await computeAnalysisResult(source);
3315 assertNoErrors(source);
3083 verify([source]); 3316 verify([source]);
3084 } 3317 }
3085 3318
3086 test_invocationOfNonFunction_localVariable_dynamic() async { 3319 test_invocationOfNonFunction_localVariable_dynamic() async {
3087 Source source = addSource(r''' 3320 Source source = addSource(r'''
3088 f() {} 3321 f() {}
3089 main() { 3322 main() {
3090 var v = f; 3323 var v = f;
3091 v(); 3324 v();
3092 }'''); 3325 }''');
3093 await assertNoErrors(source); 3326 await computeAnalysisResult(source);
3327 assertNoErrors(source);
3094 verify([source]); 3328 verify([source]);
3095 } 3329 }
3096 3330
3097 test_invocationOfNonFunction_localVariable_dynamic2() async { 3331 test_invocationOfNonFunction_localVariable_dynamic2() async {
3098 Source source = addSource(r''' 3332 Source source = addSource(r'''
3099 f() {} 3333 f() {}
3100 main() { 3334 main() {
3101 var v = f; 3335 var v = f;
3102 v = 1; 3336 v = 1;
3103 v(); 3337 v();
3104 }'''); 3338 }''');
3105 await assertNoErrors(source); 3339 await computeAnalysisResult(source);
3340 assertNoErrors(source);
3106 verify([source]); 3341 verify([source]);
3107 } 3342 }
3108 3343
3109 test_invocationOfNonFunction_Object() async { 3344 test_invocationOfNonFunction_Object() async {
3110 Source source = addSource(r''' 3345 Source source = addSource(r'''
3111 main() { 3346 main() {
3112 Object v = null; 3347 Object v = null;
3113 v(); 3348 v();
3114 }'''); 3349 }''');
3115 await assertNoErrors(source); 3350 await computeAnalysisResult(source);
3351 assertNoErrors(source);
3116 verify([source]); 3352 verify([source]);
3117 } 3353 }
3118 3354
3119 test_invocationOfNonFunction_proxyOnFunctionClass() async { 3355 test_invocationOfNonFunction_proxyOnFunctionClass() async {
3120 // 16078 3356 // 16078
3121 Source source = addSource(r''' 3357 Source source = addSource(r'''
3122 @proxy 3358 @proxy
3123 class Functor implements Function { 3359 class Functor implements Function {
3124 noSuchMethod(inv) { 3360 noSuchMethod(inv) {
3125 return 42; 3361 return 42;
3126 } 3362 }
3127 } 3363 }
3128 main() { 3364 main() {
3129 Functor f = new Functor(); 3365 Functor f = new Functor();
3130 f(); 3366 f();
3131 }'''); 3367 }''');
3132 await assertNoErrors(source); 3368 await computeAnalysisResult(source);
3369 assertNoErrors(source);
3133 verify([source]); 3370 verify([source]);
3134 } 3371 }
3135 3372
3136 test_issue_24191() async { 3373 test_issue_24191() async {
3137 Source source = addSource(''' 3374 Source source = addSource('''
3138 import 'dart:async'; 3375 import 'dart:async';
3139 3376
3140 class S extends Stream {} 3377 class S extends Stream {}
3141 f(S s) async { 3378 f(S s) async {
3142 await for (var v in s) { 3379 await for (var v in s) {
3143 print(v); 3380 print(v);
3144 } 3381 }
3145 } 3382 }
3146 '''); 3383 ''');
3147 await assertNoErrors(source); 3384 await computeAnalysisResult(source);
3385 assertNoErrors(source);
3148 verify([source]); 3386 verify([source]);
3149 } 3387 }
3150 3388
3151 test_listElementTypeNotAssignable() async { 3389 test_listElementTypeNotAssignable() async {
3152 Source source = addSource(r''' 3390 Source source = addSource(r'''
3153 var v1 = <int> [42]; 3391 var v1 = <int> [42];
3154 var v2 = const <int> [42];'''); 3392 var v2 = const <int> [42];''');
3155 await assertNoErrors(source); 3393 await computeAnalysisResult(source);
3394 assertNoErrors(source);
3156 verify([source]); 3395 verify([source]);
3157 } 3396 }
3158 3397
3159 test_loadLibraryDefined() async { 3398 test_loadLibraryDefined() async {
3160 await resolveWithErrors(<String>[ 3399 await resolveWithErrors(<String>[
3161 r''' 3400 r'''
3162 library lib1; 3401 library lib1;
3163 foo() => 22;''', 3402 foo() => 22;''',
3164 r''' 3403 r'''
3165 import 'lib1.dart' deferred as other; 3404 import 'lib1.dart' deferred as other;
3166 main() { 3405 main() {
3167 other.loadLibrary().then((_) => other.foo()); 3406 other.loadLibrary().then((_) => other.foo());
3168 }''' 3407 }'''
3169 ], <ErrorCode>[]); 3408 ], <ErrorCode>[]);
3170 } 3409 }
3171 3410
3172 test_local_generator_async() async { 3411 test_local_generator_async() async {
3173 Source source = addSource(''' 3412 Source source = addSource('''
3174 f() { 3413 f() {
3175 return () async* { yield 0; }; 3414 return () async* { yield 0; };
3176 } 3415 }
3177 '''); 3416 ''');
3178 await assertNoErrors(source); 3417 await computeAnalysisResult(source);
3418 assertNoErrors(source);
3179 verify([source]); 3419 verify([source]);
3180 } 3420 }
3181 3421
3182 test_local_generator_sync() async { 3422 test_local_generator_sync() async {
3183 Source source = addSource(''' 3423 Source source = addSource('''
3184 f() { 3424 f() {
3185 return () sync* { yield 0; }; 3425 return () sync* { yield 0; };
3186 } 3426 }
3187 '''); 3427 ''');
3188 await assertNoErrors(source); 3428 await computeAnalysisResult(source);
3429 assertNoErrors(source);
3189 verify([source]); 3430 verify([source]);
3190 } 3431 }
3191 3432
3192 test_mapKeyTypeNotAssignable() async { 3433 test_mapKeyTypeNotAssignable() async {
3193 Source source = addSource("var v = <String, int > {'a' : 1};"); 3434 Source source = addSource("var v = <String, int > {'a' : 1};");
3194 await assertNoErrors(source); 3435 await computeAnalysisResult(source);
3436 assertNoErrors(source);
3195 verify([source]); 3437 verify([source]);
3196 } 3438 }
3197 3439
3198 test_memberWithClassName_setter() async { 3440 test_memberWithClassName_setter() async {
3199 Source source = addSource(r''' 3441 Source source = addSource(r'''
3200 class A { 3442 class A {
3201 set A(v) {} 3443 set A(v) {}
3202 }'''); 3444 }''');
3203 await assertNoErrors(source); 3445 await computeAnalysisResult(source);
3446 assertNoErrors(source);
3204 verify([source]); 3447 verify([source]);
3205 } 3448 }
3206 3449
3207 test_methodDeclaration_scope_signature() async { 3450 test_methodDeclaration_scope_signature() async {
3208 Source source = addSource(r''' 3451 Source source = addSource(r'''
3209 const app = 0; 3452 const app = 0;
3210 class A { 3453 class A {
3211 foo(@app int app) {} 3454 foo(@app int app) {}
3212 }'''); 3455 }''');
3213 await assertNoErrors(source); 3456 await computeAnalysisResult(source);
3457 assertNoErrors(source);
3214 verify([source]); 3458 verify([source]);
3215 } 3459 }
3216 3460
3217 test_misMatchedGetterAndSetterTypes_instance_sameTypes() async { 3461 test_misMatchedGetterAndSetterTypes_instance_sameTypes() async {
3218 Source source = addSource(r''' 3462 Source source = addSource(r'''
3219 class C { 3463 class C {
3220 int get x => 0; 3464 int get x => 0;
3221 set x(int v) {} 3465 set x(int v) {}
3222 }'''); 3466 }''');
3223 await assertNoErrors(source); 3467 await computeAnalysisResult(source);
3468 assertNoErrors(source);
3224 verify([source]); 3469 verify([source]);
3225 } 3470 }
3226 3471
3227 test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() async { 3472 test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() async {
3228 Source source = addSource(r''' 3473 Source source = addSource(r'''
3229 class C { 3474 class C {
3230 get x => 0; 3475 get x => 0;
3231 set x(String v) {} 3476 set x(String v) {}
3232 }'''); 3477 }''');
3233 await assertNoErrors(source); 3478 await computeAnalysisResult(source);
3479 assertNoErrors(source);
3234 verify([source]); 3480 verify([source]);
3235 } 3481 }
3236 3482
3237 test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() async { 3483 test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() async {
3238 Source source = addSource(r''' 3484 Source source = addSource(r'''
3239 class C { 3485 class C {
3240 int get x => 0; 3486 int get x => 0;
3241 set x(v) {} 3487 set x(v) {}
3242 }'''); 3488 }''');
3243 await assertNoErrors(source); 3489 await computeAnalysisResult(source);
3490 assertNoErrors(source);
3244 verify([source]); 3491 verify([source]);
3245 } 3492 }
3246 3493
3247 test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() async { 3494 test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() async {
3248 Source source = addSource(r''' 3495 Source source = addSource(r'''
3249 int get x => 0; 3496 int get x => 0;
3250 set x(int v) {}'''); 3497 set x(int v) {}''');
3251 await assertNoErrors(source); 3498 await computeAnalysisResult(source);
3499 assertNoErrors(source);
3252 verify([source]); 3500 verify([source]);
3253 } 3501 }
3254 3502
3255 test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() async { 3503 test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() async {
3256 Source source = addSource(r''' 3504 Source source = addSource(r'''
3257 get x => 0; 3505 get x => 0;
3258 set x(String v) {}'''); 3506 set x(String v) {}''');
3259 await assertNoErrors(source); 3507 await computeAnalysisResult(source);
3508 assertNoErrors(source);
3260 verify([source]); 3509 verify([source]);
3261 } 3510 }
3262 3511
3263 test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() async { 3512 test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() async {
3264 Source source = addSource(r''' 3513 Source source = addSource(r'''
3265 int get x => 0; 3514 int get x => 0;
3266 set x(v) {}'''); 3515 set x(v) {}''');
3267 await assertNoErrors(source); 3516 await computeAnalysisResult(source);
3517 assertNoErrors(source);
3268 verify([source]); 3518 verify([source]);
3269 } 3519 }
3270 3520
3271 test_missingEnumConstantInSwitch_all() async { 3521 test_missingEnumConstantInSwitch_all() async {
3272 Source source = addSource(r''' 3522 Source source = addSource(r'''
3273 enum E { A, B, C } 3523 enum E { A, B, C }
3274 3524
3275 f(E e) { 3525 f(E e) {
3276 switch (e) { 3526 switch (e) {
3277 case E.A: break; 3527 case E.A: break;
3278 case E.B: break; 3528 case E.B: break;
3279 case E.C: break; 3529 case E.C: break;
3280 } 3530 }
3281 }'''); 3531 }''');
3282 await assertNoErrors(source); 3532 await computeAnalysisResult(source);
3533 assertNoErrors(source);
3283 verify([source]); 3534 verify([source]);
3284 } 3535 }
3285 3536
3286 test_missingEnumConstantInSwitch_default() async { 3537 test_missingEnumConstantInSwitch_default() async {
3287 Source source = addSource(r''' 3538 Source source = addSource(r'''
3288 enum E { A, B, C } 3539 enum E { A, B, C }
3289 3540
3290 f(E e) { 3541 f(E e) {
3291 switch (e) { 3542 switch (e) {
3292 case E.B: break; 3543 case E.B: break;
3293 default: break; 3544 default: break;
3294 } 3545 }
3295 }'''); 3546 }''');
3296 await assertNoErrors(source); 3547 await computeAnalysisResult(source);
3548 assertNoErrors(source);
3297 verify([source]); 3549 verify([source]);
3298 } 3550 }
3299 3551
3300 test_mixedReturnTypes_differentScopes() async { 3552 test_mixedReturnTypes_differentScopes() async {
3301 Source source = addSource(r''' 3553 Source source = addSource(r'''
3302 class C { 3554 class C {
3303 m(int x) { 3555 m(int x) {
3304 f(int y) { 3556 f(int y) {
3305 return; 3557 return;
3306 } 3558 }
3307 f(x); 3559 f(x);
3308 return 0; 3560 return 0;
3309 } 3561 }
3310 }'''); 3562 }''');
3311 await assertNoErrors(source); 3563 await computeAnalysisResult(source);
3564 assertNoErrors(source);
3312 verify([source]); 3565 verify([source]);
3313 } 3566 }
3314 3567
3315 test_mixedReturnTypes_ignoreImplicit() async { 3568 test_mixedReturnTypes_ignoreImplicit() async {
3316 Source source = addSource(r''' 3569 Source source = addSource(r'''
3317 f(bool p) { 3570 f(bool p) {
3318 if (p) return 42; 3571 if (p) return 42;
3319 // implicit 'return;' is ignored 3572 // implicit 'return;' is ignored
3320 }'''); 3573 }''');
3321 await assertNoErrors(source); 3574 await computeAnalysisResult(source);
3575 assertNoErrors(source);
3322 verify([source]); 3576 verify([source]);
3323 } 3577 }
3324 3578
3325 test_mixedReturnTypes_ignoreImplicit2() async { 3579 test_mixedReturnTypes_ignoreImplicit2() async {
3326 Source source = addSource(r''' 3580 Source source = addSource(r'''
3327 f(bool p) { 3581 f(bool p) {
3328 if (p) { 3582 if (p) {
3329 return 42; 3583 return 42;
3330 } else { 3584 } else {
3331 return 42; 3585 return 42;
3332 } 3586 }
3333 // implicit 'return;' is ignored 3587 // implicit 'return;' is ignored
3334 }'''); 3588 }''');
3335 await assertNoErrors(source); 3589 await computeAnalysisResult(source);
3590 assertNoErrors(source);
3336 verify([source]); 3591 verify([source]);
3337 } 3592 }
3338 3593
3339 test_mixedReturnTypes_sameKind() async { 3594 test_mixedReturnTypes_sameKind() async {
3340 Source source = addSource(r''' 3595 Source source = addSource(r'''
3341 class C { 3596 class C {
3342 m(int x) { 3597 m(int x) {
3343 if (x < 0) { 3598 if (x < 0) {
3344 return 1; 3599 return 1;
3345 } 3600 }
3346 return 0; 3601 return 0;
3347 } 3602 }
3348 }'''); 3603 }''');
3349 await assertNoErrors(source); 3604 await computeAnalysisResult(source);
3605 assertNoErrors(source);
3350 verify([source]); 3606 verify([source]);
3351 } 3607 }
3352 3608
3353 test_mixinDeclaresConstructor() async { 3609 test_mixinDeclaresConstructor() async {
3354 Source source = addSource(r''' 3610 Source source = addSource(r'''
3355 class A { 3611 class A {
3356 m() {} 3612 m() {}
3357 } 3613 }
3358 class B extends Object with A {}'''); 3614 class B extends Object with A {}''');
3359 await assertNoErrors(source); 3615 await computeAnalysisResult(source);
3616 assertNoErrors(source);
3360 verify([source]); 3617 verify([source]);
3361 } 3618 }
3362 3619
3363 test_mixinDeclaresConstructor_factory() async { 3620 test_mixinDeclaresConstructor_factory() async {
3364 Source source = addSource(r''' 3621 Source source = addSource(r'''
3365 class A { 3622 class A {
3366 factory A() => null; 3623 factory A() => null;
3367 } 3624 }
3368 class B extends Object with A {}'''); 3625 class B extends Object with A {}''');
3369 await assertNoErrors(source); 3626 await computeAnalysisResult(source);
3627 assertNoErrors(source);
3370 verify([source]); 3628 verify([source]);
3371 } 3629 }
3372 3630
3373 test_mixinInheritsFromNotObject_classDeclaration_extends() async { 3631 test_mixinInheritsFromNotObject_classDeclaration_extends() async {
3374 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 3632 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
3375 options.enableSuperMixins = true; 3633 options.enableSuperMixins = true;
3376 resetWithOptions(options); 3634 resetWithOptions(options);
3377 Source source = addSource(r''' 3635 Source source = addSource(r'''
3378 class A {} 3636 class A {}
3379 class B extends A {} 3637 class B extends A {}
3380 class C extends Object with B {}'''); 3638 class C extends Object with B {}''');
3381 await assertNoErrors(source); 3639 await computeAnalysisResult(source);
3640 assertNoErrors(source);
3382 verify([source]); 3641 verify([source]);
3383 } 3642 }
3384 3643
3385 test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() async { 3644 test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() async {
3386 Source source = addSource(r''' 3645 Source source = addSource(r'''
3387 class A {} 3646 class A {}
3388 class B = Object with A; 3647 class B = Object with A;
3389 class C extends Object with B {}'''); 3648 class C extends Object with B {}''');
3390 await assertNoErrors(source); 3649 await computeAnalysisResult(source);
3650 assertNoErrors(source);
3391 verify([source]); 3651 verify([source]);
3392 } 3652 }
3393 3653
3394 test_mixinInheritsFromNotObject_classDeclaration_with() async { 3654 test_mixinInheritsFromNotObject_classDeclaration_with() async {
3395 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 3655 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
3396 options.enableSuperMixins = true; 3656 options.enableSuperMixins = true;
3397 resetWithOptions(options); 3657 resetWithOptions(options);
3398 Source source = addSource(r''' 3658 Source source = addSource(r'''
3399 class A {} 3659 class A {}
3400 class B extends Object with A {} 3660 class B extends Object with A {}
3401 class C extends Object with B {}'''); 3661 class C extends Object with B {}''');
3402 await assertNoErrors(source); 3662 await computeAnalysisResult(source);
3663 assertNoErrors(source);
3403 verify([source]); 3664 verify([source]);
3404 } 3665 }
3405 3666
3406 test_mixinInheritsFromNotObject_typeAlias_extends() async { 3667 test_mixinInheritsFromNotObject_typeAlias_extends() async {
3407 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 3668 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
3408 options.enableSuperMixins = true; 3669 options.enableSuperMixins = true;
3409 resetWithOptions(options); 3670 resetWithOptions(options);
3410 Source source = addSource(r''' 3671 Source source = addSource(r'''
3411 class A {} 3672 class A {}
3412 class B extends A {} 3673 class B extends A {}
3413 class C = Object with B;'''); 3674 class C = Object with B;''');
3414 await assertNoErrors(source); 3675 await computeAnalysisResult(source);
3676 assertNoErrors(source);
3415 verify([source]); 3677 verify([source]);
3416 } 3678 }
3417 3679
3418 test_mixinInheritsFromNotObject_typeAlias_with() async { 3680 test_mixinInheritsFromNotObject_typeAlias_with() async {
3419 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 3681 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
3420 options.enableSuperMixins = true; 3682 options.enableSuperMixins = true;
3421 resetWithOptions(options); 3683 resetWithOptions(options);
3422 Source source = addSource(r''' 3684 Source source = addSource(r'''
3423 class A {} 3685 class A {}
3424 class B extends Object with A {} 3686 class B extends Object with A {}
3425 class C = Object with B;'''); 3687 class C = Object with B;''');
3426 await assertNoErrors(source); 3688 await computeAnalysisResult(source);
3689 assertNoErrors(source);
3427 verify([source]); 3690 verify([source]);
3428 } 3691 }
3429 3692
3430 test_mixinInheritsFromNotObject_typedef_mixTypeAlias() async { 3693 test_mixinInheritsFromNotObject_typedef_mixTypeAlias() async {
3431 Source source = addSource(r''' 3694 Source source = addSource(r'''
3432 class A {} 3695 class A {}
3433 class B = Object with A; 3696 class B = Object with A;
3434 class C = Object with B;'''); 3697 class C = Object with B;''');
3435 await assertNoErrors(source); 3698 await computeAnalysisResult(source);
3699 assertNoErrors(source);
3436 verify([source]); 3700 verify([source]);
3437 } 3701 }
3438 3702
3439 test_mixinReferencesSuper() async { 3703 test_mixinReferencesSuper() async {
3440 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 3704 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
3441 options.enableSuperMixins = true; 3705 options.enableSuperMixins = true;
3442 resetWithOptions(options); 3706 resetWithOptions(options);
3443 Source source = addSource(r''' 3707 Source source = addSource(r'''
3444 class A { 3708 class A {
3445 toString() => super.toString(); 3709 toString() => super.toString();
3446 } 3710 }
3447 class B extends Object with A {}'''); 3711 class B extends Object with A {}''');
3448 await assertNoErrors(source); 3712 await computeAnalysisResult(source);
3713 assertNoErrors(source);
3449 verify([source]); 3714 verify([source]);
3450 } 3715 }
3451 3716
3452 test_multipleSuperInitializers_no() async { 3717 test_multipleSuperInitializers_no() async {
3453 Source source = addSource(r''' 3718 Source source = addSource(r'''
3454 class A {} 3719 class A {}
3455 class B extends A { 3720 class B extends A {
3456 B() {} 3721 B() {}
3457 }'''); 3722 }''');
3458 await assertNoErrors(source); 3723 await computeAnalysisResult(source);
3724 assertNoErrors(source);
3459 verify([source]); 3725 verify([source]);
3460 } 3726 }
3461 3727
3462 test_multipleSuperInitializers_single() async { 3728 test_multipleSuperInitializers_single() async {
3463 Source source = addSource(r''' 3729 Source source = addSource(r'''
3464 class A {} 3730 class A {}
3465 class B extends A { 3731 class B extends A {
3466 B() : super() {} 3732 B() : super() {}
3467 }'''); 3733 }''');
3468 await assertNoErrors(source); 3734 await computeAnalysisResult(source);
3735 assertNoErrors(source);
3469 verify([source]); 3736 verify([source]);
3470 } 3737 }
3471 3738
3472 test_nativeConstConstructor() async { 3739 test_nativeConstConstructor() async {
3473 Source source = addSource(r''' 3740 Source source = addSource(r'''
3474 import 'dart-ext:x'; 3741 import 'dart-ext:x';
3475 class Foo { 3742 class Foo {
3476 const Foo() native 'Foo_Foo'; 3743 const Foo() native 'Foo_Foo';
3477 const factory Foo.foo() native 'Foo_Foo_foo'; 3744 const factory Foo.foo() native 'Foo_Foo_foo';
3478 }'''); 3745 }''');
3479 await assertNoErrors(source); 3746 await computeAnalysisResult(source);
3747 assertNoErrors(source);
3480 // Cannot verify the AST because the import's URI cannot be resolved. 3748 // Cannot verify the AST because the import's URI cannot be resolved.
3481 } 3749 }
3482 3750
3483 test_nativeFunctionBodyInNonSDKCode_function() async { 3751 test_nativeFunctionBodyInNonSDKCode_function() async {
3484 Source source = addSource(r''' 3752 Source source = addSource(r'''
3485 import 'dart-ext:x'; 3753 import 'dart-ext:x';
3486 int m(a) native 'string';'''); 3754 int m(a) native 'string';''');
3487 await assertNoErrors(source); 3755 await computeAnalysisResult(source);
3756 assertNoErrors(source);
3488 // Cannot verify the AST because the import's URI cannot be resolved. 3757 // Cannot verify the AST because the import's URI cannot be resolved.
3489 } 3758 }
3490 3759
3491 test_newWithAbstractClass_factory() async { 3760 test_newWithAbstractClass_factory() async {
3492 Source source = addSource(r''' 3761 Source source = addSource(r'''
3493 abstract class A { 3762 abstract class A {
3494 factory A() { return new B(); } 3763 factory A() { return new B(); }
3495 } 3764 }
3496 class B implements A { 3765 class B implements A {
3497 B() {} 3766 B() {}
3498 } 3767 }
3499 A f() { 3768 A f() {
3500 return new A(); 3769 return new A();
3501 }'''); 3770 }''');
3502 await assertNoErrors(source); 3771 await computeAnalysisResult(source);
3772 assertNoErrors(source);
3503 verify([source]); 3773 verify([source]);
3504 } 3774 }
3505 3775
3506 test_newWithUndefinedConstructor() async { 3776 test_newWithUndefinedConstructor() async {
3507 Source source = addSource(r''' 3777 Source source = addSource(r'''
3508 class A { 3778 class A {
3509 A.name() {} 3779 A.name() {}
3510 } 3780 }
3511 f() { 3781 f() {
3512 new A.name(); 3782 new A.name();
3513 }'''); 3783 }''');
3514 await assertNoErrors(source); 3784 await computeAnalysisResult(source);
3785 assertNoErrors(source);
3515 verify([source]); 3786 verify([source]);
3516 } 3787 }
3517 3788
3518 test_newWithUndefinedConstructorDefault() async { 3789 test_newWithUndefinedConstructorDefault() async {
3519 Source source = addSource(r''' 3790 Source source = addSource(r'''
3520 class A { 3791 class A {
3521 A() {} 3792 A() {}
3522 } 3793 }
3523 f() { 3794 f() {
3524 new A(); 3795 new A();
3525 }'''); 3796 }''');
3526 await assertNoErrors(source); 3797 await computeAnalysisResult(source);
3798 assertNoErrors(source);
3527 verify([source]); 3799 verify([source]);
3528 } 3800 }
3529 3801
3530 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_ getter() async { 3802 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_ getter() async {
3531 Source source = addSource(r''' 3803 Source source = addSource(r'''
3532 class A { 3804 class A {
3533 int get g => 0; 3805 int get g => 0;
3534 } 3806 }
3535 abstract class B extends A { 3807 abstract class B extends A {
3536 int get g; 3808 int get g;
3537 } 3809 }
3538 class C extends B {}'''); 3810 class C extends B {}''');
3539 await assertNoErrors(source); 3811 await computeAnalysisResult(source);
3812 assertNoErrors(source);
3540 verify([source]); 3813 verify([source]);
3541 } 3814 }
3542 3815
3543 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_ method() async { 3816 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_ method() async {
3544 Source source = addSource(r''' 3817 Source source = addSource(r'''
3545 class A { 3818 class A {
3546 m(p) {} 3819 m(p) {}
3547 } 3820 }
3548 abstract class B extends A { 3821 abstract class B extends A {
3549 m(p); 3822 m(p);
3550 } 3823 }
3551 class C extends B {}'''); 3824 class C extends B {}''');
3552 await assertNoErrors(source); 3825 await computeAnalysisResult(source);
3826 assertNoErrors(source);
3553 verify([source]); 3827 verify([source]);
3554 } 3828 }
3555 3829
3556 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_ setter() async { 3830 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_ setter() async {
3557 Source source = addSource(r''' 3831 Source source = addSource(r'''
3558 class A { 3832 class A {
3559 set s(v) {} 3833 set s(v) {}
3560 } 3834 }
3561 abstract class B extends A { 3835 abstract class B extends A {
3562 set s(v); 3836 set s(v);
3563 } 3837 }
3564 class C extends B {}'''); 3838 class C extends B {}''');
3565 await assertNoErrors(source); 3839 await computeAnalysisResult(source);
3840 assertNoErrors(source);
3566 verify([source]); 3841 verify([source]);
3567 } 3842 }
3568 3843
3569 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() asyn c { 3844 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() asyn c {
3570 // 15979 3845 // 15979
3571 Source source = addSource(r''' 3846 Source source = addSource(r'''
3572 abstract class M {} 3847 abstract class M {}
3573 abstract class A {} 3848 abstract class A {}
3574 abstract class I { 3849 abstract class I {
3575 m(); 3850 m();
3576 } 3851 }
3577 abstract class B = A with M implements I;'''); 3852 abstract class B = A with M implements I;''');
3578 await assertNoErrors(source); 3853 await computeAnalysisResult(source);
3854 assertNoErrors(source);
3579 verify([source]); 3855 verify([source]);
3580 } 3856 }
3581 3857
3582 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() async { 3858 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() async {
3583 // 15979 3859 // 15979
3584 Source source = addSource(r''' 3860 Source source = addSource(r'''
3585 abstract class M { 3861 abstract class M {
3586 m(); 3862 m();
3587 } 3863 }
3588 abstract class A {} 3864 abstract class A {}
3589 abstract class B = A with M;'''); 3865 abstract class B = A with M;''');
3590 await assertNoErrors(source); 3866 await computeAnalysisResult(source);
3867 assertNoErrors(source);
3591 verify([source]); 3868 verify([source]);
3592 } 3869 }
3593 3870
3594 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() asy nc { 3871 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() asy nc {
3595 // 15979 3872 // 15979
3596 Source source = addSource(r''' 3873 Source source = addSource(r'''
3597 class M {} 3874 class M {}
3598 abstract class A { 3875 abstract class A {
3599 m(); 3876 m();
3600 } 3877 }
3601 abstract class B = A with M;'''); 3878 abstract class B = A with M;''');
3602 await assertNoErrors(source); 3879 await computeAnalysisResult(source);
3880 assertNoErrors(source);
3603 verify([source]); 3881 verify([source]);
3604 } 3882 }
3605 3883
3606 test_nonAbstractClassInheritsAbstractMemberOne_mixin_getter() async { 3884 test_nonAbstractClassInheritsAbstractMemberOne_mixin_getter() async {
3607 // 17034 3885 // 17034
3608 Source source = addSource(r''' 3886 Source source = addSource(r'''
3609 class A { 3887 class A {
3610 var a; 3888 var a;
3611 } 3889 }
3612 abstract class M { 3890 abstract class M {
3613 get a; 3891 get a;
3614 } 3892 }
3615 class B extends A with M {} 3893 class B extends A with M {}
3616 class C extends B {}'''); 3894 class C extends B {}''');
3617 await assertNoErrors(source); 3895 await computeAnalysisResult(source);
3896 assertNoErrors(source);
3618 verify([source]); 3897 verify([source]);
3619 } 3898 }
3620 3899
3621 test_nonAbstractClassInheritsAbstractMemberOne_mixin_method() async { 3900 test_nonAbstractClassInheritsAbstractMemberOne_mixin_method() async {
3622 Source source = addSource(r''' 3901 Source source = addSource(r'''
3623 class A { 3902 class A {
3624 m() {} 3903 m() {}
3625 } 3904 }
3626 abstract class M { 3905 abstract class M {
3627 m(); 3906 m();
3628 } 3907 }
3629 class B extends A with M {} 3908 class B extends A with M {}
3630 class C extends B {}'''); 3909 class C extends B {}''');
3631 await assertNoErrors(source); 3910 await computeAnalysisResult(source);
3911 assertNoErrors(source);
3632 verify([source]); 3912 verify([source]);
3633 } 3913 }
3634 3914
3635 test_nonAbstractClassInheritsAbstractMemberOne_mixin_setter() async { 3915 test_nonAbstractClassInheritsAbstractMemberOne_mixin_setter() async {
3636 Source source = addSource(r''' 3916 Source source = addSource(r'''
3637 class A { 3917 class A {
3638 var a; 3918 var a;
3639 } 3919 }
3640 abstract class M { 3920 abstract class M {
3641 set a(dynamic v); 3921 set a(dynamic v);
3642 } 3922 }
3643 class B extends A with M {} 3923 class B extends A with M {}
3644 class C extends B {}'''); 3924 class C extends B {}''');
3645 await assertNoErrors(source); 3925 await computeAnalysisResult(source);
3926 assertNoErrors(source);
3646 verify([source]); 3927 verify([source]);
3647 } 3928 }
3648 3929
3649 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() async { 3930 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() async {
3650 Source source = addSource(r''' 3931 Source source = addSource(r'''
3651 abstract class A { 3932 abstract class A {
3652 int get g; 3933 int get g;
3653 } 3934 }
3654 class B extends A { 3935 class B extends A {
3655 noSuchMethod(v) => ''; 3936 noSuchMethod(v) => '';
3656 }'''); 3937 }''');
3657 await assertNoErrors(source); 3938 await computeAnalysisResult(source);
3939 assertNoErrors(source);
3658 verify([source]); 3940 verify([source]);
3659 } 3941 }
3660 3942
3661 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() async { 3943 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() async {
3662 Source source = addSource(r''' 3944 Source source = addSource(r'''
3663 abstract class A { 3945 abstract class A {
3664 m(p); 3946 m(p);
3665 } 3947 }
3666 class B extends A { 3948 class B extends A {
3667 noSuchMethod(v) => ''; 3949 noSuchMethod(v) => '';
3668 }'''); 3950 }''');
3669 await assertNoErrors(source); 3951 await computeAnalysisResult(source);
3952 assertNoErrors(source);
3670 verify([source]); 3953 verify([source]);
3671 } 3954 }
3672 3955
3673 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_mixin() async { 3956 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_mixin() async {
3674 Source source = addSource(r''' 3957 Source source = addSource(r'''
3675 class A { 3958 class A {
3676 noSuchMethod(v) => ''; 3959 noSuchMethod(v) => '';
3677 } 3960 }
3678 class B extends Object with A { 3961 class B extends Object with A {
3679 m(p); 3962 m(p);
3680 }'''); 3963 }''');
3681 await assertNoErrors(source); 3964 await computeAnalysisResult(source);
3965 assertNoErrors(source);
3682 verify([source]); 3966 verify([source]);
3683 } 3967 }
3684 3968
3685 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_superclass() async { 3969 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_superclass() async {
3686 Source source = addSource(r''' 3970 Source source = addSource(r'''
3687 class A { 3971 class A {
3688 noSuchMethod(v) => ''; 3972 noSuchMethod(v) => '';
3689 } 3973 }
3690 class B extends A { 3974 class B extends A {
3691 m(p); 3975 m(p);
3692 }'''); 3976 }''');
3693 await assertNoErrors(source); 3977 await computeAnalysisResult(source);
3978 assertNoErrors(source);
3694 verify([source]); 3979 verify([source]);
3695 } 3980 }
3696 3981
3697 test_nonAbstractClassInheritsAbstractMemberOne_overridesMethodInObject() async { 3982 test_nonAbstractClassInheritsAbstractMemberOne_overridesMethodInObject() async {
3698 Source source = addSource(r''' 3983 Source source = addSource(r'''
3699 class A { 3984 class A {
3700 String toString([String prefix = '']) => '${prefix}Hello'; 3985 String toString([String prefix = '']) => '${prefix}Hello';
3701 } 3986 }
3702 class C {} 3987 class C {}
3703 class B extends A with C {}'''); 3988 class B extends A with C {}''');
3704 await assertNoErrors(source); 3989 await computeAnalysisResult(source);
3990 assertNoErrors(source);
3705 verify([source]); 3991 verify([source]);
3706 } 3992 }
3707 3993
3708 test_nonBoolExpression_functionType() async { 3994 test_nonBoolExpression_functionType() async {
3709 Source source = addSource(r''' 3995 Source source = addSource(r'''
3710 bool makeAssertion() => true; 3996 bool makeAssertion() => true;
3711 f() { 3997 f() {
3712 assert(makeAssertion); 3998 assert(makeAssertion);
3713 }'''); 3999 }''');
3714 await assertNoErrors(source); 4000 await computeAnalysisResult(source);
4001 assertNoErrors(source);
3715 verify([source]); 4002 verify([source]);
3716 } 4003 }
3717 4004
3718 test_nonBoolExpression_interfaceType() async { 4005 test_nonBoolExpression_interfaceType() async {
3719 Source source = addSource(r''' 4006 Source source = addSource(r'''
3720 f() { 4007 f() {
3721 assert(true); 4008 assert(true);
3722 }'''); 4009 }''');
3723 await assertNoErrors(source); 4010 await computeAnalysisResult(source);
4011 assertNoErrors(source);
3724 verify([source]); 4012 verify([source]);
3725 } 4013 }
3726 4014
3727 test_nonBoolNegationExpression() async { 4015 test_nonBoolNegationExpression() async {
3728 Source source = addSource(r''' 4016 Source source = addSource(r'''
3729 f(bool pb, pd) { 4017 f(bool pb, pd) {
3730 !true; 4018 !true;
3731 !false; 4019 !false;
3732 !pb; 4020 !pb;
3733 !pd; 4021 !pd;
3734 }'''); 4022 }''');
3735 await assertNoErrors(source); 4023 await computeAnalysisResult(source);
4024 assertNoErrors(source);
3736 verify([source]); 4025 verify([source]);
3737 } 4026 }
3738 4027
3739 test_nonBoolNegationExpression_dynamic() async { 4028 test_nonBoolNegationExpression_dynamic() async {
3740 Source source = addSource(r''' 4029 Source source = addSource(r'''
3741 f1(bool dynamic) { 4030 f1(bool dynamic) {
3742 !dynamic; 4031 !dynamic;
3743 } 4032 }
3744 f2() { 4033 f2() {
3745 bool dynamic = true; 4034 bool dynamic = true;
3746 !dynamic; 4035 !dynamic;
3747 } 4036 }
3748 '''); 4037 ''');
3749 await assertNoErrors(source); 4038 await computeAnalysisResult(source);
4039 assertNoErrors(source);
3750 verify([source]); 4040 verify([source]);
3751 } 4041 }
3752 4042
3753 test_nonBoolOperand_and_bool() async { 4043 test_nonBoolOperand_and_bool() async {
3754 Source source = addSource(r''' 4044 Source source = addSource(r'''
3755 bool f(bool left, bool right) { 4045 bool f(bool left, bool right) {
3756 return left && right; 4046 return left && right;
3757 }'''); 4047 }''');
3758 await assertNoErrors(source); 4048 await computeAnalysisResult(source);
4049 assertNoErrors(source);
3759 verify([source]); 4050 verify([source]);
3760 } 4051 }
3761 4052
3762 test_nonBoolOperand_and_dynamic() async { 4053 test_nonBoolOperand_and_dynamic() async {
3763 Source source = addSource(r''' 4054 Source source = addSource(r'''
3764 bool f(left, dynamic right) { 4055 bool f(left, dynamic right) {
3765 return left && right; 4056 return left && right;
3766 }'''); 4057 }''');
3767 await assertNoErrors(source); 4058 await computeAnalysisResult(source);
4059 assertNoErrors(source);
3768 verify([source]); 4060 verify([source]);
3769 } 4061 }
3770 4062
3771 test_nonBoolOperand_or_bool() async { 4063 test_nonBoolOperand_or_bool() async {
3772 Source source = addSource(r''' 4064 Source source = addSource(r'''
3773 bool f(bool left, bool right) { 4065 bool f(bool left, bool right) {
3774 return left || right; 4066 return left || right;
3775 }'''); 4067 }''');
3776 await assertNoErrors(source); 4068 await computeAnalysisResult(source);
4069 assertNoErrors(source);
3777 verify([source]); 4070 verify([source]);
3778 } 4071 }
3779 4072
3780 test_nonBoolOperand_or_dynamic() async { 4073 test_nonBoolOperand_or_dynamic() async {
3781 Source source = addSource(r''' 4074 Source source = addSource(r'''
3782 bool f(dynamic left, right) { 4075 bool f(dynamic left, right) {
3783 return left || right; 4076 return left || right;
3784 }'''); 4077 }''');
3785 await assertNoErrors(source); 4078 await computeAnalysisResult(source);
4079 assertNoErrors(source);
3786 verify([source]); 4080 verify([source]);
3787 } 4081 }
3788 4082
3789 test_nonConstantDefaultValue_constField() async { 4083 test_nonConstantDefaultValue_constField() async {
3790 Source source = addSource(r''' 4084 Source source = addSource(r'''
3791 f([a = double.INFINITY]) { 4085 f([a = double.INFINITY]) {
3792 }'''); 4086 }''');
3793 await assertNoErrors(source); 4087 await computeAnalysisResult(source);
4088 assertNoErrors(source);
3794 verify([source]); 4089 verify([source]);
3795 } 4090 }
3796 4091
3797 test_nonConstantDefaultValue_function_named() async { 4092 test_nonConstantDefaultValue_function_named() async {
3798 Source source = addSource("f({x : 2 + 3}) {}"); 4093 Source source = addSource("f({x : 2 + 3}) {}");
3799 await assertNoErrors(source); 4094 await computeAnalysisResult(source);
4095 assertNoErrors(source);
3800 verify([source]); 4096 verify([source]);
3801 } 4097 }
3802 4098
3803 test_nonConstantDefaultValue_function_positional() async { 4099 test_nonConstantDefaultValue_function_positional() async {
3804 Source source = addSource("f([x = 2 + 3]) {}"); 4100 Source source = addSource("f([x = 2 + 3]) {}");
3805 await assertNoErrors(source); 4101 await computeAnalysisResult(source);
4102 assertNoErrors(source);
3806 verify([source]); 4103 verify([source]);
3807 } 4104 }
3808 4105
3809 test_nonConstantDefaultValue_inConstructor_named() async { 4106 test_nonConstantDefaultValue_inConstructor_named() async {
3810 Source source = addSource(r''' 4107 Source source = addSource(r'''
3811 class A { 4108 class A {
3812 A({x : 2 + 3}) {} 4109 A({x : 2 + 3}) {}
3813 }'''); 4110 }''');
3814 await assertNoErrors(source); 4111 await computeAnalysisResult(source);
4112 assertNoErrors(source);
3815 verify([source]); 4113 verify([source]);
3816 } 4114 }
3817 4115
3818 test_nonConstantDefaultValue_inConstructor_positional() async { 4116 test_nonConstantDefaultValue_inConstructor_positional() async {
3819 Source source = addSource(r''' 4117 Source source = addSource(r'''
3820 class A { 4118 class A {
3821 A([x = 2 + 3]) {} 4119 A([x = 2 + 3]) {}
3822 }'''); 4120 }''');
3823 await assertNoErrors(source); 4121 await computeAnalysisResult(source);
4122 assertNoErrors(source);
3824 verify([source]); 4123 verify([source]);
3825 } 4124 }
3826 4125
3827 test_nonConstantDefaultValue_method_named() async { 4126 test_nonConstantDefaultValue_method_named() async {
3828 Source source = addSource(r''' 4127 Source source = addSource(r'''
3829 class A { 4128 class A {
3830 m({x : 2 + 3}) {} 4129 m({x : 2 + 3}) {}
3831 }'''); 4130 }''');
3832 await assertNoErrors(source); 4131 await computeAnalysisResult(source);
4132 assertNoErrors(source);
3833 verify([source]); 4133 verify([source]);
3834 } 4134 }
3835 4135
3836 test_nonConstantDefaultValue_method_positional() async { 4136 test_nonConstantDefaultValue_method_positional() async {
3837 Source source = addSource(r''' 4137 Source source = addSource(r'''
3838 class A { 4138 class A {
3839 m([x = 2 + 3]) {} 4139 m([x = 2 + 3]) {}
3840 }'''); 4140 }''');
3841 await assertNoErrors(source); 4141 await computeAnalysisResult(source);
4142 assertNoErrors(source);
3842 verify([source]); 4143 verify([source]);
3843 } 4144 }
3844 4145
3845 test_nonConstantDefaultValue_typedConstList() async { 4146 test_nonConstantDefaultValue_typedConstList() async {
3846 Source source = addSource(r''' 4147 Source source = addSource(r'''
3847 class A { 4148 class A {
3848 m([p111 = const <String>[]]) {} 4149 m([p111 = const <String>[]]) {}
3849 } 4150 }
3850 class B extends A { 4151 class B extends A {
3851 m([p222 = const <String>[]]) {} 4152 m([p222 = const <String>[]]) {}
3852 }'''); 4153 }''');
3853 await assertNoErrors(source); 4154 await computeAnalysisResult(source);
4155 assertNoErrors(source);
3854 verify([source]); 4156 verify([source]);
3855 } 4157 }
3856 4158
3857 test_nonConstantValueInInitializer_namedArgument() async { 4159 test_nonConstantValueInInitializer_namedArgument() async {
3858 Source source = addSource(r''' 4160 Source source = addSource(r'''
3859 class A { 4161 class A {
3860 final a; 4162 final a;
3861 const A({this.a}); 4163 const A({this.a});
3862 } 4164 }
3863 class B extends A { 4165 class B extends A {
3864 const B({b}) : super(a: b); 4166 const B({b}) : super(a: b);
3865 }'''); 4167 }''');
3866 await assertNoErrors(source); 4168 await computeAnalysisResult(source);
4169 assertNoErrors(source);
3867 verify([source]); 4170 verify([source]);
3868 } 4171 }
3869 4172
3870 test_nonConstCaseExpression_constField() async { 4173 test_nonConstCaseExpression_constField() async {
3871 Source source = addSource(r''' 4174 Source source = addSource(r'''
3872 f(double p) { 4175 f(double p) {
3873 switch (p) { 4176 switch (p) {
3874 case double.INFINITY: 4177 case double.INFINITY:
3875 return true; 4178 return true;
3876 default: 4179 default:
3877 return false; 4180 return false;
3878 } 4181 }
3879 }'''); 4182 }''');
3880 await assertErrors( 4183 await computeAnalysisResult(source);
4184 assertErrors(
3881 source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 4185 source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
3882 verify([source]); 4186 verify([source]);
3883 } 4187 }
3884 4188
3885 test_nonConstCaseExpression_typeLiteral() async { 4189 test_nonConstCaseExpression_typeLiteral() async {
3886 Source source = addSource(r''' 4190 Source source = addSource(r'''
3887 f(Type t) { 4191 f(Type t) {
3888 switch (t) { 4192 switch (t) {
3889 case bool: 4193 case bool:
3890 case int: 4194 case int:
3891 return true; 4195 return true;
3892 default: 4196 default:
3893 return false; 4197 return false;
3894 } 4198 }
3895 }'''); 4199 }''');
3896 await assertNoErrors(source); 4200 await computeAnalysisResult(source);
4201 assertNoErrors(source);
3897 verify([source]); 4202 verify([source]);
3898 } 4203 }
3899 4204
3900 test_nonConstListElement_constField() async { 4205 test_nonConstListElement_constField() async {
3901 Source source = addSource(r''' 4206 Source source = addSource(r'''
3902 main() { 4207 main() {
3903 const [double.INFINITY]; 4208 const [double.INFINITY];
3904 }'''); 4209 }''');
3905 await assertNoErrors(source); 4210 await computeAnalysisResult(source);
4211 assertNoErrors(source);
3906 verify([source]); 4212 verify([source]);
3907 } 4213 }
3908 4214
3909 test_nonConstMapAsExpressionStatement_const() async { 4215 test_nonConstMapAsExpressionStatement_const() async {
3910 Source source = addSource(r''' 4216 Source source = addSource(r'''
3911 f() { 4217 f() {
3912 const {'a' : 0, 'b' : 1}; 4218 const {'a' : 0, 'b' : 1};
3913 }'''); 4219 }''');
3914 await assertNoErrors(source); 4220 await computeAnalysisResult(source);
4221 assertNoErrors(source);
3915 verify([source]); 4222 verify([source]);
3916 } 4223 }
3917 4224
3918 test_nonConstMapAsExpressionStatement_notExpressionStatement() async { 4225 test_nonConstMapAsExpressionStatement_notExpressionStatement() async {
3919 Source source = addSource(r''' 4226 Source source = addSource(r'''
3920 f() { 4227 f() {
3921 var m = {'a' : 0, 'b' : 1}; 4228 var m = {'a' : 0, 'b' : 1};
3922 }'''); 4229 }''');
3923 await assertNoErrors(source); 4230 await computeAnalysisResult(source);
4231 assertNoErrors(source);
3924 verify([source]); 4232 verify([source]);
3925 } 4233 }
3926 4234
3927 test_nonConstMapAsExpressionStatement_typeArguments() async { 4235 test_nonConstMapAsExpressionStatement_typeArguments() async {
3928 Source source = addSource(r''' 4236 Source source = addSource(r'''
3929 f() { 4237 f() {
3930 <String, int> {'a' : 0, 'b' : 1}; 4238 <String, int> {'a' : 0, 'b' : 1};
3931 }'''); 4239 }''');
3932 await assertNoErrors(source); 4240 await computeAnalysisResult(source);
4241 assertNoErrors(source);
3933 verify([source]); 4242 verify([source]);
3934 } 4243 }
3935 4244
3936 test_nonConstMapKey_constField() async { 4245 test_nonConstMapKey_constField() async {
3937 Source source = addSource(r''' 4246 Source source = addSource(r'''
3938 main() { 4247 main() {
3939 const {double.INFINITY: 0}; 4248 const {double.INFINITY: 0};
3940 }'''); 4249 }''');
3941 await assertErrors(source, 4250 await computeAnalysisResult(source);
4251 assertErrors(source,
3942 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 4252 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
3943 verify([source]); 4253 verify([source]);
3944 } 4254 }
3945 4255
3946 test_nonConstMapValue_constField() async { 4256 test_nonConstMapValue_constField() async {
3947 Source source = addSource(r''' 4257 Source source = addSource(r'''
3948 main() { 4258 main() {
3949 const {0: double.INFINITY}; 4259 const {0: double.INFINITY};
3950 }'''); 4260 }''');
3951 await assertNoErrors(source); 4261 await computeAnalysisResult(source);
4262 assertNoErrors(source);
3952 verify([source]); 4263 verify([source]);
3953 } 4264 }
3954 4265
3955 test_nonConstValueInInitializer_binary_bool() async { 4266 test_nonConstValueInInitializer_binary_bool() async {
3956 Source source = addSource(r''' 4267 Source source = addSource(r'''
3957 class A { 4268 class A {
3958 final v; 4269 final v;
3959 const A.a1(bool p) : v = p && true; 4270 const A.a1(bool p) : v = p && true;
3960 const A.a2(bool p) : v = true && p; 4271 const A.a2(bool p) : v = true && p;
3961 const A.b1(bool p) : v = p || true; 4272 const A.b1(bool p) : v = p || true;
3962 const A.b2(bool p) : v = true || p; 4273 const A.b2(bool p) : v = true || p;
3963 }'''); 4274 }''');
3964 await assertErrors(source, [HintCode.DEAD_CODE]); 4275 await computeAnalysisResult(source);
4276 assertErrors(source, [HintCode.DEAD_CODE]);
3965 verify([source]); 4277 verify([source]);
3966 } 4278 }
3967 4279
3968 test_nonConstValueInInitializer_binary_dynamic() async { 4280 test_nonConstValueInInitializer_binary_dynamic() async {
3969 Source source = addSource(r''' 4281 Source source = addSource(r'''
3970 class A { 4282 class A {
3971 final v; 4283 final v;
3972 const A.a1(p) : v = p + 5; 4284 const A.a1(p) : v = p + 5;
3973 const A.a2(p) : v = 5 + p; 4285 const A.a2(p) : v = 5 + p;
3974 const A.b1(p) : v = p - 5; 4286 const A.b1(p) : v = p - 5;
3975 const A.b2(p) : v = 5 - p; 4287 const A.b2(p) : v = 5 - p;
3976 const A.c1(p) : v = p * 5; 4288 const A.c1(p) : v = p * 5;
3977 const A.c2(p) : v = 5 * p; 4289 const A.c2(p) : v = 5 * p;
3978 const A.d1(p) : v = p / 5; 4290 const A.d1(p) : v = p / 5;
3979 const A.d2(p) : v = 5 / p; 4291 const A.d2(p) : v = 5 / p;
3980 const A.e1(p) : v = p ~/ 5; 4292 const A.e1(p) : v = p ~/ 5;
3981 const A.e2(p) : v = 5 ~/ p; 4293 const A.e2(p) : v = 5 ~/ p;
3982 const A.f1(p) : v = p > 5; 4294 const A.f1(p) : v = p > 5;
3983 const A.f2(p) : v = 5 > p; 4295 const A.f2(p) : v = 5 > p;
3984 const A.g1(p) : v = p < 5; 4296 const A.g1(p) : v = p < 5;
3985 const A.g2(p) : v = 5 < p; 4297 const A.g2(p) : v = 5 < p;
3986 const A.h1(p) : v = p >= 5; 4298 const A.h1(p) : v = p >= 5;
3987 const A.h2(p) : v = 5 >= p; 4299 const A.h2(p) : v = 5 >= p;
3988 const A.i1(p) : v = p <= 5; 4300 const A.i1(p) : v = p <= 5;
3989 const A.i2(p) : v = 5 <= p; 4301 const A.i2(p) : v = 5 <= p;
3990 const A.j1(p) : v = p % 5; 4302 const A.j1(p) : v = p % 5;
3991 const A.j2(p) : v = 5 % p; 4303 const A.j2(p) : v = 5 % p;
3992 }'''); 4304 }''');
3993 await assertNoErrors(source); 4305 await computeAnalysisResult(source);
4306 assertNoErrors(source);
3994 // operations on "p" are not resolved 4307 // operations on "p" are not resolved
3995 } 4308 }
3996 4309
3997 test_nonConstValueInInitializer_binary_int() async { 4310 test_nonConstValueInInitializer_binary_int() async {
3998 Source source = addSource(r''' 4311 Source source = addSource(r'''
3999 class A { 4312 class A {
4000 final v; 4313 final v;
4001 const A.a1(int p) : v = p ^ 5; 4314 const A.a1(int p) : v = p ^ 5;
4002 const A.a2(int p) : v = 5 ^ p; 4315 const A.a2(int p) : v = 5 ^ p;
4003 const A.b1(int p) : v = p & 5; 4316 const A.b1(int p) : v = p & 5;
4004 const A.b2(int p) : v = 5 & p; 4317 const A.b2(int p) : v = 5 & p;
4005 const A.c1(int p) : v = p | 5; 4318 const A.c1(int p) : v = p | 5;
4006 const A.c2(int p) : v = 5 | p; 4319 const A.c2(int p) : v = 5 | p;
4007 const A.d1(int p) : v = p >> 5; 4320 const A.d1(int p) : v = p >> 5;
4008 const A.d2(int p) : v = 5 >> p; 4321 const A.d2(int p) : v = 5 >> p;
4009 const A.e1(int p) : v = p << 5; 4322 const A.e1(int p) : v = p << 5;
4010 const A.e2(int p) : v = 5 << p; 4323 const A.e2(int p) : v = 5 << p;
4011 }'''); 4324 }''');
4012 await assertNoErrors(source); 4325 await computeAnalysisResult(source);
4326 assertNoErrors(source);
4013 verify([source]); 4327 verify([source]);
4014 } 4328 }
4015 4329
4016 test_nonConstValueInInitializer_binary_num() async { 4330 test_nonConstValueInInitializer_binary_num() async {
4017 Source source = addSource(r''' 4331 Source source = addSource(r'''
4018 class A { 4332 class A {
4019 final v; 4333 final v;
4020 const A.a1(num p) : v = p + 5; 4334 const A.a1(num p) : v = p + 5;
4021 const A.a2(num p) : v = 5 + p; 4335 const A.a2(num p) : v = 5 + p;
4022 const A.b1(num p) : v = p - 5; 4336 const A.b1(num p) : v = p - 5;
4023 const A.b2(num p) : v = 5 - p; 4337 const A.b2(num p) : v = 5 - p;
4024 const A.c1(num p) : v = p * 5; 4338 const A.c1(num p) : v = p * 5;
4025 const A.c2(num p) : v = 5 * p; 4339 const A.c2(num p) : v = 5 * p;
4026 const A.d1(num p) : v = p / 5; 4340 const A.d1(num p) : v = p / 5;
4027 const A.d2(num p) : v = 5 / p; 4341 const A.d2(num p) : v = 5 / p;
4028 const A.e1(num p) : v = p ~/ 5; 4342 const A.e1(num p) : v = p ~/ 5;
4029 const A.e2(num p) : v = 5 ~/ p; 4343 const A.e2(num p) : v = 5 ~/ p;
4030 const A.f1(num p) : v = p > 5; 4344 const A.f1(num p) : v = p > 5;
4031 const A.f2(num p) : v = 5 > p; 4345 const A.f2(num p) : v = 5 > p;
4032 const A.g1(num p) : v = p < 5; 4346 const A.g1(num p) : v = p < 5;
4033 const A.g2(num p) : v = 5 < p; 4347 const A.g2(num p) : v = 5 < p;
4034 const A.h1(num p) : v = p >= 5; 4348 const A.h1(num p) : v = p >= 5;
4035 const A.h2(num p) : v = 5 >= p; 4349 const A.h2(num p) : v = 5 >= p;
4036 const A.i1(num p) : v = p <= 5; 4350 const A.i1(num p) : v = p <= 5;
4037 const A.i2(num p) : v = 5 <= p; 4351 const A.i2(num p) : v = 5 <= p;
4038 const A.j1(num p) : v = p % 5; 4352 const A.j1(num p) : v = p % 5;
4039 const A.j2(num p) : v = 5 % p; 4353 const A.j2(num p) : v = 5 % p;
4040 }'''); 4354 }''');
4041 await assertNoErrors(source); 4355 await computeAnalysisResult(source);
4356 assertNoErrors(source);
4042 verify([source]); 4357 verify([source]);
4043 } 4358 }
4044 4359
4045 test_nonConstValueInInitializer_field() async { 4360 test_nonConstValueInInitializer_field() async {
4046 Source source = addSource(r''' 4361 Source source = addSource(r'''
4047 class A { 4362 class A {
4048 final int a; 4363 final int a;
4049 const A() : a = 5; 4364 const A() : a = 5;
4050 }'''); 4365 }''');
4051 await assertNoErrors(source); 4366 await computeAnalysisResult(source);
4367 assertNoErrors(source);
4052 verify([source]); 4368 verify([source]);
4053 } 4369 }
4054 4370
4055 test_nonConstValueInInitializer_redirecting() async { 4371 test_nonConstValueInInitializer_redirecting() async {
4056 Source source = addSource(r''' 4372 Source source = addSource(r'''
4057 class A { 4373 class A {
4058 const A.named(p); 4374 const A.named(p);
4059 const A() : this.named(42); 4375 const A() : this.named(42);
4060 }'''); 4376 }''');
4061 await assertNoErrors(source); 4377 await computeAnalysisResult(source);
4378 assertNoErrors(source);
4062 verify([source]); 4379 verify([source]);
4063 } 4380 }
4064 4381
4065 test_nonConstValueInInitializer_super() async { 4382 test_nonConstValueInInitializer_super() async {
4066 Source source = addSource(r''' 4383 Source source = addSource(r'''
4067 class A { 4384 class A {
4068 const A(p); 4385 const A(p);
4069 } 4386 }
4070 class B extends A { 4387 class B extends A {
4071 const B() : super(42); 4388 const B() : super(42);
4072 }'''); 4389 }''');
4073 await assertNoErrors(source); 4390 await computeAnalysisResult(source);
4391 assertNoErrors(source);
4074 verify([source]); 4392 verify([source]);
4075 } 4393 }
4076 4394
4077 test_nonConstValueInInitializer_unary() async { 4395 test_nonConstValueInInitializer_unary() async {
4078 Source source = addSource(r''' 4396 Source source = addSource(r'''
4079 class A { 4397 class A {
4080 final v; 4398 final v;
4081 const A.a(bool p) : v = !p; 4399 const A.a(bool p) : v = !p;
4082 const A.b(int p) : v = ~p; 4400 const A.b(int p) : v = ~p;
4083 const A.c(num p) : v = -p; 4401 const A.c(num p) : v = -p;
4084 }'''); 4402 }''');
4085 await assertNoErrors(source); 4403 await computeAnalysisResult(source);
4404 assertNoErrors(source);
4086 verify([source]); 4405 verify([source]);
4087 } 4406 }
4088 4407
4089 test_nonGenerativeConstructor() async { 4408 test_nonGenerativeConstructor() async {
4090 Source source = addSource(r''' 4409 Source source = addSource(r'''
4091 class A { 4410 class A {
4092 A.named() {} 4411 A.named() {}
4093 factory A() => null; 4412 factory A() => null;
4094 } 4413 }
4095 class B extends A { 4414 class B extends A {
4096 B() : super.named(); 4415 B() : super.named();
4097 }'''); 4416 }''');
4098 await assertNoErrors(source); 4417 await computeAnalysisResult(source);
4418 assertNoErrors(source);
4099 verify([source]); 4419 verify([source]);
4100 } 4420 }
4101 4421
4102 test_nonTypeInCatchClause_isClass() async { 4422 test_nonTypeInCatchClause_isClass() async {
4103 Source source = addSource(r''' 4423 Source source = addSource(r'''
4104 f() { 4424 f() {
4105 try { 4425 try {
4106 } on String catch (e) { 4426 } on String catch (e) {
4107 } 4427 }
4108 }'''); 4428 }''');
4109 await assertNoErrors(source); 4429 await computeAnalysisResult(source);
4430 assertNoErrors(source);
4110 verify([source]); 4431 verify([source]);
4111 } 4432 }
4112 4433
4113 test_nonTypeInCatchClause_isFunctionTypeAlias() async { 4434 test_nonTypeInCatchClause_isFunctionTypeAlias() async {
4114 Source source = addSource(r''' 4435 Source source = addSource(r'''
4115 typedef F(); 4436 typedef F();
4116 f() { 4437 f() {
4117 try { 4438 try {
4118 } on F catch (e) { 4439 } on F catch (e) {
4119 } 4440 }
4120 }'''); 4441 }''');
4121 await assertNoErrors(source); 4442 await computeAnalysisResult(source);
4443 assertNoErrors(source);
4122 verify([source]); 4444 verify([source]);
4123 } 4445 }
4124 4446
4125 test_nonTypeInCatchClause_isTypeParameter() async { 4447 test_nonTypeInCatchClause_isTypeParameter() async {
4126 Source source = addSource(r''' 4448 Source source = addSource(r'''
4127 class A<T> { 4449 class A<T> {
4128 f() { 4450 f() {
4129 try { 4451 try {
4130 } on T catch (e) { 4452 } on T catch (e) {
4131 } 4453 }
4132 } 4454 }
4133 }'''); 4455 }''');
4134 await assertNoErrors(source); 4456 await computeAnalysisResult(source);
4457 assertNoErrors(source);
4135 verify([source]); 4458 verify([source]);
4136 } 4459 }
4137 4460
4138 test_nonTypeInCatchClause_noType() async { 4461 test_nonTypeInCatchClause_noType() async {
4139 Source source = addSource(r''' 4462 Source source = addSource(r'''
4140 f() { 4463 f() {
4141 try { 4464 try {
4142 } catch (e) { 4465 } catch (e) {
4143 } 4466 }
4144 }'''); 4467 }''');
4145 await assertNoErrors(source); 4468 await computeAnalysisResult(source);
4469 assertNoErrors(source);
4146 verify([source]); 4470 verify([source]);
4147 } 4471 }
4148 4472
4149 test_nonVoidReturnForOperator_no() async { 4473 test_nonVoidReturnForOperator_no() async {
4150 Source source = addSource(r''' 4474 Source source = addSource(r'''
4151 class A { 4475 class A {
4152 operator []=(a, b) {} 4476 operator []=(a, b) {}
4153 }'''); 4477 }''');
4154 await assertNoErrors(source); 4478 await computeAnalysisResult(source);
4479 assertNoErrors(source);
4155 verify([source]); 4480 verify([source]);
4156 } 4481 }
4157 4482
4158 test_nonVoidReturnForOperator_void() async { 4483 test_nonVoidReturnForOperator_void() async {
4159 Source source = addSource(r''' 4484 Source source = addSource(r'''
4160 class A { 4485 class A {
4161 void operator []=(a, b) {} 4486 void operator []=(a, b) {}
4162 }'''); 4487 }''');
4163 await assertNoErrors(source); 4488 await computeAnalysisResult(source);
4489 assertNoErrors(source);
4164 verify([source]); 4490 verify([source]);
4165 } 4491 }
4166 4492
4167 test_nonVoidReturnForSetter_function_no() async { 4493 test_nonVoidReturnForSetter_function_no() async {
4168 Source source = addSource("set x(v) {}"); 4494 Source source = addSource("set x(v) {}");
4169 await assertNoErrors(source); 4495 await computeAnalysisResult(source);
4496 assertNoErrors(source);
4170 verify([source]); 4497 verify([source]);
4171 } 4498 }
4172 4499
4173 test_nonVoidReturnForSetter_function_void() async { 4500 test_nonVoidReturnForSetter_function_void() async {
4174 Source source = addSource("void set x(v) {}"); 4501 Source source = addSource("void set x(v) {}");
4175 await assertNoErrors(source); 4502 await computeAnalysisResult(source);
4503 assertNoErrors(source);
4176 verify([source]); 4504 verify([source]);
4177 } 4505 }
4178 4506
4179 test_nonVoidReturnForSetter_method_no() async { 4507 test_nonVoidReturnForSetter_method_no() async {
4180 Source source = addSource(r''' 4508 Source source = addSource(r'''
4181 class A { 4509 class A {
4182 set x(v) {} 4510 set x(v) {}
4183 }'''); 4511 }''');
4184 await assertNoErrors(source); 4512 await computeAnalysisResult(source);
4513 assertNoErrors(source);
4185 verify([source]); 4514 verify([source]);
4186 } 4515 }
4187 4516
4188 test_nonVoidReturnForSetter_method_void() async { 4517 test_nonVoidReturnForSetter_method_void() async {
4189 Source source = addSource(r''' 4518 Source source = addSource(r'''
4190 class A { 4519 class A {
4191 void set x(v) {} 4520 void set x(v) {}
4192 }'''); 4521 }''');
4193 await assertNoErrors(source); 4522 await computeAnalysisResult(source);
4523 assertNoErrors(source);
4194 verify([source]); 4524 verify([source]);
4195 } 4525 }
4196 4526
4197 test_null_callMethod() async { 4527 test_null_callMethod() async {
4198 Source source = addSource(r''' 4528 Source source = addSource(r'''
4199 main() { 4529 main() {
4200 null.m(); 4530 null.m();
4201 }'''); 4531 }''');
4202 await assertNoErrors(source); 4532 await computeAnalysisResult(source);
4533 assertNoErrors(source);
4203 } 4534 }
4204 4535
4205 test_null_callOperator() async { 4536 test_null_callOperator() async {
4206 Source source = addSource(r''' 4537 Source source = addSource(r'''
4207 main() { 4538 main() {
4208 null + 5; 4539 null + 5;
4209 null == 5; 4540 null == 5;
4210 null[0]; 4541 null[0];
4211 }'''); 4542 }''');
4212 await assertNoErrors(source); 4543 await computeAnalysisResult(source);
4544 assertNoErrors(source);
4213 } 4545 }
4214 4546
4215 test_optionalParameterInOperator_required() async { 4547 test_optionalParameterInOperator_required() async {
4216 Source source = addSource(r''' 4548 Source source = addSource(r'''
4217 class A { 4549 class A {
4218 operator +(p) {} 4550 operator +(p) {}
4219 }'''); 4551 }''');
4220 await assertNoErrors(source); 4552 await computeAnalysisResult(source);
4553 assertNoErrors(source);
4221 verify([source]); 4554 verify([source]);
4222 } 4555 }
4223 4556
4224 test_parameterDefaultDoesNotReferToParameterName() async { 4557 test_parameterDefaultDoesNotReferToParameterName() async {
4225 // The final "f" should refer to the toplevel function "f", not to the 4558 // The final "f" should refer to the toplevel function "f", not to the
4226 // parameter called "f". See dartbug.com/13179. 4559 // parameter called "f". See dartbug.com/13179.
4227 Source source = addSource('void f([void f([x]) = f]) {}'); 4560 Source source = addSource('void f([void f([x]) = f]) {}');
4228 await assertNoErrors(source); 4561 await computeAnalysisResult(source);
4562 assertNoErrors(source);
4229 verify([source]); 4563 verify([source]);
4230 } 4564 }
4231 4565
4232 test_parameterScope_local() async { 4566 test_parameterScope_local() async {
4233 // Parameter names shouldn't conflict with the name of the function they 4567 // Parameter names shouldn't conflict with the name of the function they
4234 // are enclosed in. 4568 // are enclosed in.
4235 Source source = addSource(r''' 4569 Source source = addSource(r'''
4236 f() { 4570 f() {
4237 g(g) { 4571 g(g) {
4238 h(g); 4572 h(g);
4239 } 4573 }
4240 } 4574 }
4241 h(x) {} 4575 h(x) {}
4242 '''); 4576 ''');
4243 await assertNoErrors(source); 4577 await computeAnalysisResult(source);
4578 assertNoErrors(source);
4244 verify([source]); 4579 verify([source]);
4245 } 4580 }
4246 4581
4247 test_parameterScope_method() async { 4582 test_parameterScope_method() async {
4248 // Parameter names shouldn't conflict with the name of the function they 4583 // Parameter names shouldn't conflict with the name of the function they
4249 // are enclosed in. 4584 // are enclosed in.
4250 Source source = addSource(r''' 4585 Source source = addSource(r'''
4251 class C { 4586 class C {
4252 g(g) { 4587 g(g) {
4253 h(g); 4588 h(g);
4254 } 4589 }
4255 } 4590 }
4256 h(x) {} 4591 h(x) {}
4257 '''); 4592 ''');
4258 await assertNoErrors(source); 4593 await computeAnalysisResult(source);
4594 assertNoErrors(source);
4259 verify([source]); 4595 verify([source]);
4260 } 4596 }
4261 4597
4262 test_parameterScope_toplevel() async { 4598 test_parameterScope_toplevel() async {
4263 // Parameter names shouldn't conflict with the name of the function they 4599 // Parameter names shouldn't conflict with the name of the function they
4264 // are enclosed in. 4600 // are enclosed in.
4265 Source source = addSource(r''' 4601 Source source = addSource(r'''
4266 g(g) { 4602 g(g) {
4267 h(g); 4603 h(g);
4268 } 4604 }
4269 h(x) {} 4605 h(x) {}
4270 '''); 4606 ''');
4271 await assertNoErrors(source); 4607 await computeAnalysisResult(source);
4608 assertNoErrors(source);
4272 verify([source]); 4609 verify([source]);
4273 } 4610 }
4274 4611
4275 test_prefixCollidesWithTopLevelMembers() async { 4612 test_prefixCollidesWithTopLevelMembers() async {
4276 addNamedSource( 4613 addNamedSource(
4277 "/lib.dart", 4614 "/lib.dart",
4278 r''' 4615 r'''
4279 library lib; 4616 library lib;
4280 class A {}'''); 4617 class A {}''');
4281 Source source = addSource(r''' 4618 Source source = addSource(r'''
4282 import 'lib.dart' as p; 4619 import 'lib.dart' as p;
4283 typedef P(); 4620 typedef P();
4284 p2() {} 4621 p2() {}
4285 var p3; 4622 var p3;
4286 class p4 {} 4623 class p4 {}
4287 p.A a;'''); 4624 p.A a;''');
4288 await assertNoErrors(source); 4625 await computeAnalysisResult(source);
4626 assertNoErrors(source);
4289 verify([source]); 4627 verify([source]);
4290 } 4628 }
4291 4629
4292 test_propagateTypeArgs_intoBounds() async { 4630 test_propagateTypeArgs_intoBounds() async {
4293 Source source = addSource(r''' 4631 Source source = addSource(r'''
4294 abstract class A<E> {} 4632 abstract class A<E> {}
4295 abstract class B<F> implements A<F>{} 4633 abstract class B<F> implements A<F>{}
4296 abstract class C<G, H extends A<G>> {} 4634 abstract class C<G, H extends A<G>> {}
4297 class D<I> extends C<I, B<I>> {}'''); 4635 class D<I> extends C<I, B<I>> {}''');
4298 await assertNoErrors(source); 4636 await computeAnalysisResult(source);
4637 assertNoErrors(source);
4299 verify([source]); 4638 verify([source]);
4300 } 4639 }
4301 4640
4302 test_propagateTypeArgs_intoSupertype() async { 4641 test_propagateTypeArgs_intoSupertype() async {
4303 Source source = addSource(r''' 4642 Source source = addSource(r'''
4304 class A<T> { 4643 class A<T> {
4305 A(T p); 4644 A(T p);
4306 A.named(T p); 4645 A.named(T p);
4307 } 4646 }
4308 class B<S> extends A<S> { 4647 class B<S> extends A<S> {
4309 B(S p) : super(p); 4648 B(S p) : super(p);
4310 B.named(S p) : super.named(p); 4649 B.named(S p) : super.named(p);
4311 }'''); 4650 }''');
4312 await assertNoErrors(source); 4651 await computeAnalysisResult(source);
4652 assertNoErrors(source);
4313 verify([source]); 4653 verify([source]);
4314 } 4654 }
4315 4655
4316 test_proxy_annotation_prefixed() async { 4656 test_proxy_annotation_prefixed() async {
4317 Source source = addSource(r''' 4657 Source source = addSource(r'''
4318 library L; 4658 library L;
4319 @proxy 4659 @proxy
4320 class A {} 4660 class A {}
4321 f(A a) { 4661 f(A a) {
4322 a.m(); 4662 a.m();
4323 var x = a.g; 4663 var x = a.g;
4324 a.s = 1; 4664 a.s = 1;
4325 var y = a + a; 4665 var y = a + a;
4326 a++; 4666 a++;
4327 ++a; 4667 ++a;
4328 }'''); 4668 }''');
4329 await assertNoErrors(source); 4669 await computeAnalysisResult(source);
4670 assertNoErrors(source);
4330 } 4671 }
4331 4672
4332 test_proxy_annotation_prefixed2() async { 4673 test_proxy_annotation_prefixed2() async {
4333 Source source = addSource(r''' 4674 Source source = addSource(r'''
4334 library L; 4675 library L;
4335 @proxy 4676 @proxy
4336 class A {} 4677 class A {}
4337 class B { 4678 class B {
4338 f(A a) { 4679 f(A a) {
4339 a.m(); 4680 a.m();
4340 var x = a.g; 4681 var x = a.g;
4341 a.s = 1; 4682 a.s = 1;
4342 var y = a + a; 4683 var y = a + a;
4343 a++; 4684 a++;
4344 ++a; 4685 ++a;
4345 } 4686 }
4346 }'''); 4687 }''');
4347 await assertNoErrors(source); 4688 await computeAnalysisResult(source);
4689 assertNoErrors(source);
4348 } 4690 }
4349 4691
4350 test_proxy_annotation_prefixed3() async { 4692 test_proxy_annotation_prefixed3() async {
4351 Source source = addSource(r''' 4693 Source source = addSource(r'''
4352 library L; 4694 library L;
4353 class B { 4695 class B {
4354 f(A a) { 4696 f(A a) {
4355 a.m(); 4697 a.m();
4356 var x = a.g; 4698 var x = a.g;
4357 a.s = 1; 4699 a.s = 1;
4358 var y = a + a; 4700 var y = a + a;
4359 a++; 4701 a++;
4360 ++a; 4702 ++a;
4361 } 4703 }
4362 } 4704 }
4363 @proxy 4705 @proxy
4364 class A {}'''); 4706 class A {}''');
4365 await assertNoErrors(source); 4707 await computeAnalysisResult(source);
4708 assertNoErrors(source);
4366 } 4709 }
4367 4710
4368 test_proxy_annotation_proxyHasPrefixedIdentifier() async { 4711 test_proxy_annotation_proxyHasPrefixedIdentifier() async {
4369 Source source = addSource(r''' 4712 Source source = addSource(r'''
4370 library L; 4713 library L;
4371 import 'dart:core' as core; 4714 import 'dart:core' as core;
4372 @core.proxy class PrefixProxy {} 4715 @core.proxy class PrefixProxy {}
4373 main() { 4716 main() {
4374 new PrefixProxy().foo; 4717 new PrefixProxy().foo;
4375 new PrefixProxy().foo(); 4718 new PrefixProxy().foo();
4376 }'''); 4719 }''');
4377 await assertNoErrors(source); 4720 await computeAnalysisResult(source);
4721 assertNoErrors(source);
4378 } 4722 }
4379 4723
4380 test_proxy_annotation_simple() async { 4724 test_proxy_annotation_simple() async {
4381 Source source = addSource(r''' 4725 Source source = addSource(r'''
4382 library L; 4726 library L;
4383 @proxy 4727 @proxy
4384 class B { 4728 class B {
4385 m() { 4729 m() {
4386 n(); 4730 n();
4387 var x = g; 4731 var x = g;
4388 s = 1; 4732 s = 1;
4389 var y = this + this; 4733 var y = this + this;
4390 } 4734 }
4391 }'''); 4735 }''');
4392 await assertNoErrors(source); 4736 await computeAnalysisResult(source);
4737 assertNoErrors(source);
4393 } 4738 }
4394 4739
4395 test_proxy_annotation_superclass() async { 4740 test_proxy_annotation_superclass() async {
4396 Source source = addSource(r''' 4741 Source source = addSource(r'''
4397 library L; 4742 library L;
4398 class B extends A { 4743 class B extends A {
4399 m() { 4744 m() {
4400 n(); 4745 n();
4401 var x = g; 4746 var x = g;
4402 s = 1; 4747 s = 1;
4403 var y = this + this; 4748 var y = this + this;
4404 } 4749 }
4405 } 4750 }
4406 @proxy 4751 @proxy
4407 class A {}'''); 4752 class A {}''');
4408 await assertNoErrors(source); 4753 await computeAnalysisResult(source);
4754 assertNoErrors(source);
4409 } 4755 }
4410 4756
4411 test_proxy_annotation_superclass_mixin() async { 4757 test_proxy_annotation_superclass_mixin() async {
4412 Source source = addSource(r''' 4758 Source source = addSource(r'''
4413 library L; 4759 library L;
4414 class B extends Object with A { 4760 class B extends Object with A {
4415 m() { 4761 m() {
4416 n(); 4762 n();
4417 var x = g; 4763 var x = g;
4418 s = 1; 4764 s = 1;
4419 var y = this + this; 4765 var y = this + this;
4420 } 4766 }
4421 } 4767 }
4422 @proxy 4768 @proxy
4423 class A {}'''); 4769 class A {}''');
4424 await assertNoErrors(source); 4770 await computeAnalysisResult(source);
4771 assertNoErrors(source);
4425 } 4772 }
4426 4773
4427 test_proxy_annotation_superinterface() async { 4774 test_proxy_annotation_superinterface() async {
4428 Source source = addSource(r''' 4775 Source source = addSource(r'''
4429 library L; 4776 library L;
4430 class B implements A { 4777 class B implements A {
4431 m() { 4778 m() {
4432 n(); 4779 n();
4433 var x = g; 4780 var x = g;
4434 s = 1; 4781 s = 1;
4435 var y = this + this; 4782 var y = this + this;
4436 } 4783 }
4437 } 4784 }
4438 @proxy 4785 @proxy
4439 class A {}'''); 4786 class A {}''');
4440 await assertNoErrors(source); 4787 await computeAnalysisResult(source);
4788 assertNoErrors(source);
4441 } 4789 }
4442 4790
4443 test_proxy_annotation_superinterface_infiniteLoop() async { 4791 test_proxy_annotation_superinterface_infiniteLoop() async {
4444 addSource(r''' 4792 addSource(r'''
4445 library L; 4793 library L;
4446 class C implements A { 4794 class C implements A {
4447 m() { 4795 m() {
4448 n(); 4796 n();
4449 var x = g; 4797 var x = g;
4450 s = 1; 4798 s = 1;
4451 var y = this + this; 4799 var y = this + this;
4452 } 4800 }
4453 } 4801 }
4454 class B implements A{} 4802 class B implements A{}
4455 class A implements B{}'''); 4803 class A implements B{}''');
4456 // Test is that a stack overflow isn't reached in resolution 4804 // Test is that a stack overflow isn't reached in resolution
4457 // (previous line), no need to assert error set. 4805 // (previous line), no need to assert error set.
4458 } 4806 }
4459 4807
4460 test_recursiveConstructorRedirect() async { 4808 test_recursiveConstructorRedirect() async {
4461 Source source = addSource(r''' 4809 Source source = addSource(r'''
4462 class A { 4810 class A {
4463 A.a() : this.b(); 4811 A.a() : this.b();
4464 A.b() : this.c(); 4812 A.b() : this.c();
4465 A.c() {} 4813 A.c() {}
4466 }'''); 4814 }''');
4467 await assertNoErrors(source); 4815 await computeAnalysisResult(source);
4816 assertNoErrors(source);
4468 verify([source]); 4817 verify([source]);
4469 } 4818 }
4470 4819
4471 test_recursiveFactoryRedirect() async { 4820 test_recursiveFactoryRedirect() async {
4472 Source source = addSource(r''' 4821 Source source = addSource(r'''
4473 class A { 4822 class A {
4474 factory A() = B; 4823 factory A() = B;
4475 } 4824 }
4476 class B implements A { 4825 class B implements A {
4477 factory B() = C; 4826 factory B() = C;
4478 } 4827 }
4479 class C implements B { 4828 class C implements B {
4480 factory C() => null; 4829 factory C() => null;
4481 }'''); 4830 }''');
4482 await assertNoErrors(source); 4831 await computeAnalysisResult(source);
4832 assertNoErrors(source);
4483 verify([source]); 4833 verify([source]);
4484 } 4834 }
4485 4835
4486 test_redirectToInvalidFunctionType() async { 4836 test_redirectToInvalidFunctionType() async {
4487 Source source = addSource(r''' 4837 Source source = addSource(r'''
4488 class A implements B { 4838 class A implements B {
4489 A(int p) {} 4839 A(int p) {}
4490 } 4840 }
4491 class B { 4841 class B {
4492 factory B(int p) = A; 4842 factory B(int p) = A;
4493 }'''); 4843 }''');
4494 await assertNoErrors(source); 4844 await computeAnalysisResult(source);
4845 assertNoErrors(source);
4495 verify([source]); 4846 verify([source]);
4496 } 4847 }
4497 4848
4498 test_redirectToInvalidReturnType() async { 4849 test_redirectToInvalidReturnType() async {
4499 Source source = addSource(r''' 4850 Source source = addSource(r'''
4500 class A { 4851 class A {
4501 A() {} 4852 A() {}
4502 } 4853 }
4503 class B extends A { 4854 class B extends A {
4504 factory B() = A; 4855 factory B() = A;
4505 }'''); 4856 }''');
4506 await assertNoErrors(source); 4857 await computeAnalysisResult(source);
4858 assertNoErrors(source);
4507 verify([source]); 4859 verify([source]);
4508 } 4860 }
4509 4861
4510 test_redirectToNonConstConstructor() async { 4862 test_redirectToNonConstConstructor() async {
4511 Source source = addSource(r''' 4863 Source source = addSource(r'''
4512 class A { 4864 class A {
4513 const A.a(); 4865 const A.a();
4514 const factory A.b() = A.a; 4866 const factory A.b() = A.a;
4515 }'''); 4867 }''');
4516 await assertNoErrors(source); 4868 await computeAnalysisResult(source);
4869 assertNoErrors(source);
4517 verify([source]); 4870 verify([source]);
4518 } 4871 }
4519 4872
4520 test_referencedBeforeDeclaration_cascade() async { 4873 test_referencedBeforeDeclaration_cascade() async {
4521 Source source = addSource(r''' 4874 Source source = addSource(r'''
4522 testRequestHandler() {} 4875 testRequestHandler() {}
4523 4876
4524 main() { 4877 main() {
4525 var s1 = null; 4878 var s1 = null;
4526 testRequestHandler() 4879 testRequestHandler()
4527 ..stream(s1); 4880 ..stream(s1);
4528 var stream = 123; 4881 var stream = 123;
4529 print(stream); 4882 print(stream);
4530 }'''); 4883 }''');
4531 await assertNoErrors(source); 4884 await computeAnalysisResult(source);
4885 assertNoErrors(source);
4532 verify([source]); 4886 verify([source]);
4533 } 4887 }
4534 4888
4535 test_referenceToDeclaredVariableInInitializer_constructorName() async { 4889 test_referenceToDeclaredVariableInInitializer_constructorName() async {
4536 Source source = addSource(r''' 4890 Source source = addSource(r'''
4537 class A { 4891 class A {
4538 A.x() {} 4892 A.x() {}
4539 } 4893 }
4540 f() { 4894 f() {
4541 var x = new A.x(); 4895 var x = new A.x();
4542 }'''); 4896 }''');
4543 await assertNoErrors(source); 4897 await computeAnalysisResult(source);
4898 assertNoErrors(source);
4544 verify([source]); 4899 verify([source]);
4545 } 4900 }
4546 4901
4547 test_referenceToDeclaredVariableInInitializer_methodName() async { 4902 test_referenceToDeclaredVariableInInitializer_methodName() async {
4548 Source source = addSource(r''' 4903 Source source = addSource(r'''
4549 class A { 4904 class A {
4550 x() {} 4905 x() {}
4551 } 4906 }
4552 f(A a) { 4907 f(A a) {
4553 var x = a.x(); 4908 var x = a.x();
4554 }'''); 4909 }''');
4555 await assertNoErrors(source); 4910 await computeAnalysisResult(source);
4911 assertNoErrors(source);
4556 verify([source]); 4912 verify([source]);
4557 } 4913 }
4558 4914
4559 test_referenceToDeclaredVariableInInitializer_propertyName() async { 4915 test_referenceToDeclaredVariableInInitializer_propertyName() async {
4560 Source source = addSource(r''' 4916 Source source = addSource(r'''
4561 class A { 4917 class A {
4562 var x; 4918 var x;
4563 } 4919 }
4564 f(A a) { 4920 f(A a) {
4565 var x = a.x; 4921 var x = a.x;
4566 }'''); 4922 }''');
4567 await assertNoErrors(source); 4923 await computeAnalysisResult(source);
4924 assertNoErrors(source);
4568 verify([source]); 4925 verify([source]);
4569 } 4926 }
4570 4927
4571 test_rethrowOutsideCatch() async { 4928 test_rethrowOutsideCatch() async {
4572 Source source = addSource(r''' 4929 Source source = addSource(r'''
4573 class A { 4930 class A {
4574 void m() { 4931 void m() {
4575 try {} catch (e) {rethrow;} 4932 try {} catch (e) {rethrow;}
4576 } 4933 }
4577 }'''); 4934 }''');
4578 await assertNoErrors(source); 4935 await computeAnalysisResult(source);
4936 assertNoErrors(source);
4579 verify([source]); 4937 verify([source]);
4580 } 4938 }
4581 4939
4582 test_return_in_generator_async() async { 4940 test_return_in_generator_async() async {
4583 Source source = addSource(''' 4941 Source source = addSource('''
4584 import 'dart:async'; 4942 import 'dart:async';
4585 Stream<int> f() async* { 4943 Stream<int> f() async* {
4586 return; 4944 return;
4587 } 4945 }
4588 '''); 4946 ''');
4589 await assertNoErrors(source); 4947 await computeAnalysisResult(source);
4948 assertNoErrors(source);
4590 verify([source]); 4949 verify([source]);
4591 } 4950 }
4592 4951
4593 test_return_in_generator_sync() async { 4952 test_return_in_generator_sync() async {
4594 Source source = addSource(''' 4953 Source source = addSource('''
4595 Iterable<int> f() sync* { 4954 Iterable<int> f() sync* {
4596 return; 4955 return;
4597 } 4956 }
4598 '''); 4957 ''');
4599 await assertNoErrors(source); 4958 await computeAnalysisResult(source);
4959 assertNoErrors(source);
4600 verify([source]); 4960 verify([source]);
4601 } 4961 }
4602 4962
4603 test_returnInGenerativeConstructor() async { 4963 test_returnInGenerativeConstructor() async {
4604 Source source = addSource(r''' 4964 Source source = addSource(r'''
4605 class A { 4965 class A {
4606 A() { return; } 4966 A() { return; }
4607 }'''); 4967 }''');
4608 await assertNoErrors(source); 4968 await computeAnalysisResult(source);
4969 assertNoErrors(source);
4609 verify([source]); 4970 verify([source]);
4610 } 4971 }
4611 4972
4612 test_returnInGenerator_async() async { 4973 test_returnInGenerator_async() async {
4613 Source source = addSource(r''' 4974 Source source = addSource(r'''
4614 f() async { 4975 f() async {
4615 return 0; 4976 return 0;
4616 }'''); 4977 }''');
4617 await assertNoErrors(source); 4978 await computeAnalysisResult(source);
4979 assertNoErrors(source);
4618 verify([source]); 4980 verify([source]);
4619 } 4981 }
4620 4982
4621 test_returnInGenerator_sync() async { 4983 test_returnInGenerator_sync() async {
4622 Source source = addSource(r''' 4984 Source source = addSource(r'''
4623 f() { 4985 f() {
4624 return 0; 4986 return 0;
4625 }'''); 4987 }''');
4626 await assertNoErrors(source); 4988 await computeAnalysisResult(source);
4989 assertNoErrors(source);
4627 verify([source]); 4990 verify([source]);
4628 } 4991 }
4629 4992
4630 test_returnOfInvalidType_async() async { 4993 test_returnOfInvalidType_async() async {
4631 Source source = addSource(r''' 4994 Source source = addSource(r'''
4632 import 'dart:async'; 4995 import 'dart:async';
4633 class A { 4996 class A {
4634 Future<int> m() async { 4997 Future<int> m() async {
4635 return 0; 4998 return 0;
4636 } 4999 }
4637 }'''); 5000 }''');
4638 await assertNoErrors(source); 5001 await computeAnalysisResult(source);
5002 assertNoErrors(source);
4639 verify([source]); 5003 verify([source]);
4640 } 5004 }
4641 5005
4642 test_returnOfInvalidType_dynamic() async { 5006 test_returnOfInvalidType_dynamic() async {
4643 Source source = addSource(r''' 5007 Source source = addSource(r'''
4644 class TypeError {} 5008 class TypeError {}
4645 class A { 5009 class A {
4646 static void testLogicalOp() { 5010 static void testLogicalOp() {
4647 testOr(a, b, onTypeError) { 5011 testOr(a, b, onTypeError) {
4648 try { 5012 try {
4649 return a || b; 5013 return a || b;
4650 } on TypeError catch (t) { 5014 } on TypeError catch (t) {
4651 return onTypeError; 5015 return onTypeError;
4652 } 5016 }
4653 } 5017 }
4654 } 5018 }
4655 }'''); 5019 }''');
4656 await assertNoErrors(source); 5020 await computeAnalysisResult(source);
5021 assertNoErrors(source);
4657 verify([source]); 5022 verify([source]);
4658 } 5023 }
4659 5024
4660 test_returnOfInvalidType_dynamicAsTypeArgument() async { 5025 test_returnOfInvalidType_dynamicAsTypeArgument() async {
4661 Source source = addSource(r''' 5026 Source source = addSource(r'''
4662 class I<T> { 5027 class I<T> {
4663 factory I() => new A<T>(); 5028 factory I() => new A<T>();
4664 } 5029 }
4665 class A<T> implements I { 5030 class A<T> implements I {
4666 }'''); 5031 }''');
4667 await assertNoErrors(source); 5032 await computeAnalysisResult(source);
5033 assertNoErrors(source);
4668 verify([source]); 5034 verify([source]);
4669 } 5035 }
4670 5036
4671 test_returnOfInvalidType_subtype() async { 5037 test_returnOfInvalidType_subtype() async {
4672 Source source = addSource(r''' 5038 Source source = addSource(r'''
4673 class A {} 5039 class A {}
4674 class B extends A {} 5040 class B extends A {}
4675 A f(B b) { return b; }'''); 5041 A f(B b) { return b; }''');
4676 await assertNoErrors(source); 5042 await computeAnalysisResult(source);
5043 assertNoErrors(source);
4677 verify([source]); 5044 verify([source]);
4678 } 5045 }
4679 5046
4680 test_returnOfInvalidType_supertype() async { 5047 test_returnOfInvalidType_supertype() async {
4681 Source source = addSource(r''' 5048 Source source = addSource(r'''
4682 class A {} 5049 class A {}
4683 class B extends A {} 5050 class B extends A {}
4684 B f(A a) { return a; }'''); 5051 B f(A a) { return a; }''');
4685 await assertNoErrors(source); 5052 await computeAnalysisResult(source);
5053 assertNoErrors(source);
4686 verify([source]); 5054 verify([source]);
4687 } 5055 }
4688 5056
4689 test_returnOfInvalidType_typeParameter_18468() async { 5057 test_returnOfInvalidType_typeParameter_18468() async {
4690 // https://code.google.com/p/dart/issues/detail?id=18468 5058 // https://code.google.com/p/dart/issues/detail?id=18468
4691 // 5059 //
4692 // This test verifies that the type of T is more specific than Type, 5060 // This test verifies that the type of T is more specific than Type,
4693 // where T is a type parameter and Type is the type Type from 5061 // where T is a type parameter and Type is the type Type from
4694 // core, this particular test case comes from issue 18468. 5062 // core, this particular test case comes from issue 18468.
4695 // 5063 //
4696 // A test cannot be added to TypeParameterTypeImplTest since the types 5064 // A test cannot be added to TypeParameterTypeImplTest since the types
4697 // returned out of the TestTypeProvider don't have a mock 'dart.core' 5065 // returned out of the TestTypeProvider don't have a mock 'dart.core'
4698 // enclosing library element. 5066 // enclosing library element.
4699 // See TypeParameterTypeImpl.isMoreSpecificThan(). 5067 // See TypeParameterTypeImpl.isMoreSpecificThan().
4700 Source source = addSource(r''' 5068 Source source = addSource(r'''
4701 class Foo<T> { 5069 class Foo<T> {
4702 Type get t => T; 5070 Type get t => T;
4703 }'''); 5071 }''');
4704 await assertErrors(source); 5072 await computeAnalysisResult(source);
5073 assertErrors(source);
4705 verify([source]); 5074 verify([source]);
4706 } 5075 }
4707 5076
4708 test_returnOfInvalidType_void() async { 5077 test_returnOfInvalidType_void() async {
4709 Source source = addSource(r''' 5078 Source source = addSource(r'''
4710 void f1() {} 5079 void f1() {}
4711 void f2() { return; } 5080 void f2() { return; }
4712 void f3() { return null; } 5081 void f3() { return null; }
4713 void f4() { return g1(); } 5082 void f4() { return g1(); }
4714 void f5() { return g2(); } 5083 void f5() { return g2(); }
4715 g1() {} 5084 g1() {}
4716 void g2() {} 5085 void g2() {}
4717 '''); 5086 ''');
4718 await assertNoErrors(source); 5087 await computeAnalysisResult(source);
5088 assertNoErrors(source);
4719 verify([source]); 5089 verify([source]);
4720 } 5090 }
4721 5091
4722 test_returnWithoutValue_noReturnType() async { 5092 test_returnWithoutValue_noReturnType() async {
4723 Source source = addSource("f() { return; }"); 5093 Source source = addSource("f() { return; }");
4724 await assertNoErrors(source); 5094 await computeAnalysisResult(source);
5095 assertNoErrors(source);
4725 verify([source]); 5096 verify([source]);
4726 } 5097 }
4727 5098
4728 test_returnWithoutValue_void() async { 5099 test_returnWithoutValue_void() async {
4729 Source source = addSource("void f() { return; }"); 5100 Source source = addSource("void f() { return; }");
4730 await assertNoErrors(source); 5101 await computeAnalysisResult(source);
5102 assertNoErrors(source);
4731 verify([source]); 5103 verify([source]);
4732 } 5104 }
4733 5105
4734 test_reversedTypeArguments() async { 5106 test_reversedTypeArguments() async {
4735 Source source = addSource(r''' 5107 Source source = addSource(r'''
4736 class Codec<S1, T1> { 5108 class Codec<S1, T1> {
4737 Codec<T1, S1> get inverted => new _InvertedCodec<T1, S1>(this); 5109 Codec<T1, S1> get inverted => new _InvertedCodec<T1, S1>(this);
4738 } 5110 }
4739 class _InvertedCodec<T2, S2> extends Codec<T2, S2> { 5111 class _InvertedCodec<T2, S2> extends Codec<T2, S2> {
4740 _InvertedCodec(Codec<S2, T2> codec); 5112 _InvertedCodec(Codec<S2, T2> codec);
4741 }'''); 5113 }''');
4742 await assertNoErrors(source); 5114 await computeAnalysisResult(source);
5115 assertNoErrors(source);
4743 verify([source]); 5116 verify([source]);
4744 } 5117 }
4745 5118
4746 test_sharedDeferredPrefix() async { 5119 test_sharedDeferredPrefix() async {
4747 await resolveWithErrors(<String>[ 5120 await resolveWithErrors(<String>[
4748 r''' 5121 r'''
4749 library lib1; 5122 library lib1;
4750 f1() {}''', 5123 f1() {}''',
4751 r''' 5124 r'''
4752 library lib2; 5125 library lib2;
(...skipping 11 matching lines...) Expand all
4764 } 5137 }
4765 5138
4766 test_staticAccessToInstanceMember_annotation() async { 5139 test_staticAccessToInstanceMember_annotation() async {
4767 Source source = addSource(r''' 5140 Source source = addSource(r'''
4768 class A { 5141 class A {
4769 const A.name(); 5142 const A.name();
4770 } 5143 }
4771 @A.name() 5144 @A.name()
4772 main() { 5145 main() {
4773 }'''); 5146 }''');
4774 await assertNoErrors(source); 5147 await computeAnalysisResult(source);
5148 assertNoErrors(source);
4775 verify([source]); 5149 verify([source]);
4776 } 5150 }
4777 5151
4778 test_staticAccessToInstanceMember_method() async { 5152 test_staticAccessToInstanceMember_method() async {
4779 Source source = addSource(r''' 5153 Source source = addSource(r'''
4780 class A { 5154 class A {
4781 static m() {} 5155 static m() {}
4782 } 5156 }
4783 main() { 5157 main() {
4784 A.m; 5158 A.m;
4785 A.m(); 5159 A.m();
4786 }'''); 5160 }''');
4787 await assertNoErrors(source); 5161 await computeAnalysisResult(source);
5162 assertNoErrors(source);
4788 verify([source]); 5163 verify([source]);
4789 } 5164 }
4790 5165
4791 test_staticAccessToInstanceMember_propertyAccess_field() async { 5166 test_staticAccessToInstanceMember_propertyAccess_field() async {
4792 Source source = addSource(r''' 5167 Source source = addSource(r'''
4793 class A { 5168 class A {
4794 static var f; 5169 static var f;
4795 } 5170 }
4796 main() { 5171 main() {
4797 A.f; 5172 A.f;
4798 A.f = 1; 5173 A.f = 1;
4799 }'''); 5174 }''');
4800 await assertNoErrors(source); 5175 await computeAnalysisResult(source);
5176 assertNoErrors(source);
4801 verify([source]); 5177 verify([source]);
4802 } 5178 }
4803 5179
4804 test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() async { 5180 test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() async {
4805 Source source = addSource(r''' 5181 Source source = addSource(r'''
4806 class A { 5182 class A {
4807 static get f => 42; 5183 static get f => 42;
4808 static set f(x) {} 5184 static set f(x) {}
4809 } 5185 }
4810 main() { 5186 main() {
4811 A.f; 5187 A.f;
4812 A.f = 1; 5188 A.f = 1;
4813 }'''); 5189 }''');
4814 await assertNoErrors(source); 5190 await computeAnalysisResult(source);
5191 assertNoErrors(source);
4815 verify([source]); 5192 verify([source]);
4816 } 5193 }
4817 5194
4818 test_superInInvalidContext() async { 5195 test_superInInvalidContext() async {
4819 Source source = addSource(r''' 5196 Source source = addSource(r'''
4820 class A { 5197 class A {
4821 m() {} 5198 m() {}
4822 } 5199 }
4823 class B extends A { 5200 class B extends A {
4824 B() { 5201 B() {
4825 var v = super.m(); 5202 var v = super.m();
4826 } 5203 }
4827 n() { 5204 n() {
4828 var v = super.m(); 5205 var v = super.m();
4829 } 5206 }
4830 }'''); 5207 }''');
4831 await assertNoErrors(source); 5208 await computeAnalysisResult(source);
5209 assertNoErrors(source);
4832 verify([source]); 5210 verify([source]);
4833 } 5211 }
4834 5212
4835 test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() async { 5213 test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() async {
4836 Source source = addSource(r''' 5214 Source source = addSource(r'''
4837 typedef B A(); 5215 typedef B A();
4838 class B { 5216 class B {
4839 A a; 5217 A a;
4840 }'''); 5218 }''');
4841 await assertNoErrors(source); 5219 await computeAnalysisResult(source);
5220 assertNoErrors(source);
4842 verify([source]); 5221 verify([source]);
4843 } 5222 }
4844 5223
4845 test_typeArgumentNotMatchingBounds_const() async { 5224 test_typeArgumentNotMatchingBounds_const() async {
4846 Source source = addSource(r''' 5225 Source source = addSource(r'''
4847 class A {} 5226 class A {}
4848 class B extends A {} 5227 class B extends A {}
4849 class G<E extends A> { 5228 class G<E extends A> {
4850 const G(); 5229 const G();
4851 } 5230 }
4852 f() { return const G<B>(); }'''); 5231 f() { return const G<B>(); }''');
4853 await assertNoErrors(source); 5232 await computeAnalysisResult(source);
5233 assertNoErrors(source);
4854 verify([source]); 5234 verify([source]);
4855 } 5235 }
4856 5236
4857 test_typeArgumentNotMatchingBounds_new() async { 5237 test_typeArgumentNotMatchingBounds_new() async {
4858 Source source = addSource(r''' 5238 Source source = addSource(r'''
4859 class A {} 5239 class A {}
4860 class B extends A {} 5240 class B extends A {}
4861 class G<E extends A> {} 5241 class G<E extends A> {}
4862 f() { return new G<B>(); }'''); 5242 f() { return new G<B>(); }''');
4863 await assertNoErrors(source); 5243 await computeAnalysisResult(source);
5244 assertNoErrors(source);
4864 verify([source]); 5245 verify([source]);
4865 } 5246 }
4866 5247
4867 test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound() async { 5248 test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound() async {
4868 Source source = addSource(r''' 5249 Source source = addSource(r'''
4869 class A {} 5250 class A {}
4870 class B extends A {} 5251 class B extends A {}
4871 typedef F<T extends A>(); 5252 typedef F<T extends A>();
4872 F<A> fa; 5253 F<A> fa;
4873 F<B> fb; 5254 F<B> fb;
4874 '''); 5255 ''');
4875 await assertNoErrors(source); 5256 await computeAnalysisResult(source);
5257 assertNoErrors(source);
4876 verify([source]); 5258 verify([source]);
4877 } 5259 }
4878 5260
4879 test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound2() async { 5261 test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound2() async {
4880 Source source = addSource(r''' 5262 Source source = addSource(r'''
4881 class MyClass<T> {} 5263 class MyClass<T> {}
4882 typedef MyFunction<T, P extends MyClass<T>>(); 5264 typedef MyFunction<T, P extends MyClass<T>>();
4883 class A<T, P extends MyClass<T>> { 5265 class A<T, P extends MyClass<T>> {
4884 MyFunction<T, P> f; 5266 MyFunction<T, P> f;
4885 } 5267 }
4886 '''); 5268 ''');
4887 await assertNoErrors(source); 5269 await computeAnalysisResult(source);
5270 assertNoErrors(source);
4888 verify([source]); 5271 verify([source]);
4889 } 5272 }
4890 5273
4891 test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_noBound() async { 5274 test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_noBound() async {
4892 Source source = addSource(r''' 5275 Source source = addSource(r'''
4893 typedef F<T>(); 5276 typedef F<T>();
4894 F<int> f1; 5277 F<int> f1;
4895 F<String> f2; 5278 F<String> f2;
4896 '''); 5279 ''');
4897 await assertNoErrors(source); 5280 await computeAnalysisResult(source);
5281 assertNoErrors(source);
4898 verify([source]); 5282 verify([source]);
4899 } 5283 }
4900 5284
4901 test_typeArgumentNotMatchingBounds_typeArgumentList_0() async { 5285 test_typeArgumentNotMatchingBounds_typeArgumentList_0() async {
4902 Source source = addSource("abstract class A<T extends A>{}"); 5286 Source source = addSource("abstract class A<T extends A>{}");
4903 await assertNoErrors(source); 5287 await computeAnalysisResult(source);
5288 assertNoErrors(source);
4904 verify([source]); 5289 verify([source]);
4905 } 5290 }
4906 5291
4907 test_typeArgumentNotMatchingBounds_typeArgumentList_1() async { 5292 test_typeArgumentNotMatchingBounds_typeArgumentList_1() async {
4908 Source source = addSource("abstract class A<T extends A<A>>{}"); 5293 Source source = addSource("abstract class A<T extends A<A>>{}");
4909 await assertNoErrors(source); 5294 await computeAnalysisResult(source);
5295 assertNoErrors(source);
4910 verify([source]); 5296 verify([source]);
4911 } 5297 }
4912 5298
4913 test_typeArgumentNotMatchingBounds_typeArgumentList_20() async { 5299 test_typeArgumentNotMatchingBounds_typeArgumentList_20() async {
4914 Source source = addSource( 5300 Source source = addSource(
4915 "abstract class A<T extends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>> >>>>>>>>>>>>>>>>>>{}"); 5301 "abstract class A<T extends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>> >>>>>>>>>>>>>>>>>>{}");
4916 await assertNoErrors(source); 5302 await computeAnalysisResult(source);
5303 assertNoErrors(source);
4917 verify([source]); 5304 verify([source]);
4918 } 5305 }
4919 5306
4920 test_typePromotion_booleanAnd_useInRight() async { 5307 test_typePromotion_booleanAnd_useInRight() async {
4921 Source source = addSource(r''' 5308 Source source = addSource(r'''
4922 main(Object p) { 5309 main(Object p) {
4923 p is String && p.length != 0; 5310 p is String && p.length != 0;
4924 }'''); 5311 }''');
4925 await assertNoErrors(source); 5312 await computeAnalysisResult(source);
5313 assertNoErrors(source);
4926 verify([source]); 5314 verify([source]);
4927 } 5315 }
4928 5316
4929 test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignment() async { 5317 test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignment() async {
4930 Source source = addSource(r''' 5318 Source source = addSource(r'''
4931 callMe(f()) { f(); } 5319 callMe(f()) { f(); }
4932 main(Object p) { 5320 main(Object p) {
4933 (p is String) && callMe(() { p.length; }); 5321 (p is String) && callMe(() { p.length; });
4934 }'''); 5322 }''');
4935 await assertNoErrors(source); 5323 await computeAnalysisResult(source);
5324 assertNoErrors(source);
4936 verify([source]); 5325 verify([source]);
4937 } 5326 }
4938 5327
4939 test_typePromotion_conditional_issue14655() async { 5328 test_typePromotion_conditional_issue14655() async {
4940 Source source = addSource(r''' 5329 Source source = addSource(r'''
4941 class A {} 5330 class A {}
4942 class B extends A {} 5331 class B extends A {}
4943 class C extends B { 5332 class C extends B {
4944 mc() {} 5333 mc() {}
4945 } 5334 }
4946 print(_) {} 5335 print(_) {}
4947 main(A p) { 5336 main(A p) {
4948 (p is C) && (print(() => p) && (p is B)) ? p.mc() : p = null; 5337 (p is C) && (print(() => p) && (p is B)) ? p.mc() : p = null;
4949 }'''); 5338 }''');
4950 await assertNoErrors(source); 5339 await computeAnalysisResult(source);
5340 assertNoErrors(source);
4951 verify([source]); 5341 verify([source]);
4952 } 5342 }
4953 5343
4954 test_typePromotion_conditional_useInThen() async { 5344 test_typePromotion_conditional_useInThen() async {
4955 Source source = addSource(r''' 5345 Source source = addSource(r'''
4956 main(Object p) { 5346 main(Object p) {
4957 p is String ? p.length : 0; 5347 p is String ? p.length : 0;
4958 }'''); 5348 }''');
4959 await assertNoErrors(source); 5349 await computeAnalysisResult(source);
5350 assertNoErrors(source);
4960 verify([source]); 5351 verify([source]);
4961 } 5352 }
4962 5353
4963 test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() asyn c { 5354 test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() asyn c {
4964 Source source = addSource(r''' 5355 Source source = addSource(r'''
4965 callMe(f()) { f(); } 5356 callMe(f()) { f(); }
4966 main(Object p) { 5357 main(Object p) {
4967 p is String ? callMe(() { p.length; }) : 0; 5358 p is String ? callMe(() { p.length; }) : 0;
4968 }'''); 5359 }''');
4969 await assertNoErrors(source); 5360 await computeAnalysisResult(source);
5361 assertNoErrors(source);
4970 verify([source]); 5362 verify([source]);
4971 } 5363 }
4972 5364
4973 test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() async { 5365 test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() async {
4974 Source source = addSource(r''' 5366 Source source = addSource(r'''
4975 typedef FuncB(B b); 5367 typedef FuncB(B b);
4976 typedef FuncA(A a); 5368 typedef FuncA(A a);
4977 class A {} 5369 class A {}
4978 class B {} 5370 class B {}
4979 main(FuncA f) { 5371 main(FuncA f) {
4980 if (f is FuncB) { 5372 if (f is FuncB) {
4981 f(new A()); 5373 f(new A());
4982 } 5374 }
4983 }'''); 5375 }''');
4984 await assertNoErrors(source); 5376 await computeAnalysisResult(source);
5377 assertNoErrors(source);
4985 verify([source]); 5378 verify([source]);
4986 } 5379 }
4987 5380
4988 test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() async { 5381 test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() async {
4989 Source source = addSource(r''' 5382 Source source = addSource(r'''
4990 class A {} 5383 class A {}
4991 typedef FuncAtoDyn(A a); 5384 typedef FuncAtoDyn(A a);
4992 typedef FuncDynToDyn(x); 5385 typedef FuncDynToDyn(x);
4993 main(FuncAtoDyn f) { 5386 main(FuncAtoDyn f) {
4994 if (f is FuncDynToDyn) { 5387 if (f is FuncDynToDyn) {
4995 A a = f(new A()); 5388 A a = f(new A());
4996 } 5389 }
4997 }'''); 5390 }''');
4998 await assertNoErrors(source); 5391 await computeAnalysisResult(source);
5392 assertNoErrors(source);
4999 verify([source]); 5393 verify([source]);
5000 } 5394 }
5001 5395
5002 test_typePromotion_functionType_return_voidToDynamic() async { 5396 test_typePromotion_functionType_return_voidToDynamic() async {
5003 Source source = addSource(r''' 5397 Source source = addSource(r'''
5004 typedef FuncDynToDyn(x); 5398 typedef FuncDynToDyn(x);
5005 typedef void FuncDynToVoid(x); 5399 typedef void FuncDynToVoid(x);
5006 class A {} 5400 class A {}
5007 main(FuncDynToVoid f) { 5401 main(FuncDynToVoid f) {
5008 if (f is FuncDynToDyn) { 5402 if (f is FuncDynToDyn) {
5009 A a = f(null); 5403 A a = f(null);
5010 } 5404 }
5011 }'''); 5405 }''');
5012 await assertNoErrors(source); 5406 await computeAnalysisResult(source);
5407 assertNoErrors(source);
5013 verify([source]); 5408 verify([source]);
5014 } 5409 }
5015 5410
5016 test_typePromotion_if_accessedInClosure_noAssignment() async { 5411 test_typePromotion_if_accessedInClosure_noAssignment() async {
5017 Source source = addSource(r''' 5412 Source source = addSource(r'''
5018 callMe(f()) { f(); } 5413 callMe(f()) { f(); }
5019 main(Object p) { 5414 main(Object p) {
5020 if (p is String) { 5415 if (p is String) {
5021 callMe(() { 5416 callMe(() {
5022 p.length; 5417 p.length;
5023 }); 5418 });
5024 } 5419 }
5025 }'''); 5420 }''');
5026 await assertNoErrors(source); 5421 await computeAnalysisResult(source);
5422 assertNoErrors(source);
5027 verify([source]); 5423 verify([source]);
5028 } 5424 }
5029 5425
5030 test_typePromotion_if_extends_moreSpecific() async { 5426 test_typePromotion_if_extends_moreSpecific() async {
5031 Source source = addSource(r''' 5427 Source source = addSource(r'''
5032 class V {} 5428 class V {}
5033 class VP extends V {} 5429 class VP extends V {}
5034 class A<T> {} 5430 class A<T> {}
5035 class B<S> extends A<S> { 5431 class B<S> extends A<S> {
5036 var b; 5432 var b;
5037 } 5433 }
5038 5434
5039 main(A<V> p) { 5435 main(A<V> p) {
5040 if (p is B<VP>) { 5436 if (p is B<VP>) {
5041 p.b; 5437 p.b;
5042 } 5438 }
5043 }'''); 5439 }''');
5044 await assertNoErrors(source); 5440 await computeAnalysisResult(source);
5441 assertNoErrors(source);
5045 verify([source]); 5442 verify([source]);
5046 } 5443 }
5047 5444
5048 test_typePromotion_if_hasAssignment_outsideAfter() async { 5445 test_typePromotion_if_hasAssignment_outsideAfter() async {
5049 Source source = addSource(r''' 5446 Source source = addSource(r'''
5050 main(Object p) { 5447 main(Object p) {
5051 if (p is String) { 5448 if (p is String) {
5052 p.length; 5449 p.length;
5053 } 5450 }
5054 p = 0; 5451 p = 0;
5055 }'''); 5452 }''');
5056 await assertNoErrors(source); 5453 await computeAnalysisResult(source);
5454 assertNoErrors(source);
5057 verify([source]); 5455 verify([source]);
5058 } 5456 }
5059 5457
5060 test_typePromotion_if_hasAssignment_outsideBefore() async { 5458 test_typePromotion_if_hasAssignment_outsideBefore() async {
5061 Source source = addSource(r''' 5459 Source source = addSource(r'''
5062 main(Object p, Object p2) { 5460 main(Object p, Object p2) {
5063 p = p2; 5461 p = p2;
5064 if (p is String) { 5462 if (p is String) {
5065 p.length; 5463 p.length;
5066 } 5464 }
5067 }'''); 5465 }''');
5068 await assertNoErrors(source); 5466 await computeAnalysisResult(source);
5467 assertNoErrors(source);
5069 verify([source]); 5468 verify([source]);
5070 } 5469 }
5071 5470
5072 test_typePromotion_if_implements_moreSpecific() async { 5471 test_typePromotion_if_implements_moreSpecific() async {
5073 Source source = addSource(r''' 5472 Source source = addSource(r'''
5074 class V {} 5473 class V {}
5075 class VP extends V {} 5474 class VP extends V {}
5076 class A<T> {} 5475 class A<T> {}
5077 class B<S> implements A<S> { 5476 class B<S> implements A<S> {
5078 var b; 5477 var b;
5079 } 5478 }
5080 5479
5081 main(A<V> p) { 5480 main(A<V> p) {
5082 if (p is B<VP>) { 5481 if (p is B<VP>) {
5083 p.b; 5482 p.b;
5084 } 5483 }
5085 }'''); 5484 }''');
5086 await assertNoErrors(source); 5485 await computeAnalysisResult(source);
5486 assertNoErrors(source);
5087 verify([source]); 5487 verify([source]);
5088 } 5488 }
5089 5489
5090 test_typePromotion_if_inClosure_assignedAfter_inSameFunction() async { 5490 test_typePromotion_if_inClosure_assignedAfter_inSameFunction() async {
5091 Source source = addSource(r''' 5491 Source source = addSource(r'''
5092 main() { 5492 main() {
5093 f(Object p) { 5493 f(Object p) {
5094 if (p is String) { 5494 if (p is String) {
5095 p.length; 5495 p.length;
5096 } 5496 }
5097 p = 0; 5497 p = 0;
5098 }; 5498 };
5099 }'''); 5499 }''');
5100 await assertNoErrors(source); 5500 await computeAnalysisResult(source);
5501 assertNoErrors(source);
5101 verify([source]); 5502 verify([source]);
5102 } 5503 }
5103 5504
5104 test_typePromotion_if_is_and_left() async { 5505 test_typePromotion_if_is_and_left() async {
5105 Source source = addSource(r''' 5506 Source source = addSource(r'''
5106 bool tt() => true; 5507 bool tt() => true;
5107 main(Object p) { 5508 main(Object p) {
5108 if (p is String && tt()) { 5509 if (p is String && tt()) {
5109 p.length; 5510 p.length;
5110 } 5511 }
5111 }'''); 5512 }''');
5112 await assertNoErrors(source); 5513 await computeAnalysisResult(source);
5514 assertNoErrors(source);
5113 verify([source]); 5515 verify([source]);
5114 } 5516 }
5115 5517
5116 test_typePromotion_if_is_and_right() async { 5518 test_typePromotion_if_is_and_right() async {
5117 Source source = addSource(r''' 5519 Source source = addSource(r'''
5118 bool tt() => true; 5520 bool tt() => true;
5119 main(Object p) { 5521 main(Object p) {
5120 if (tt() && p is String) { 5522 if (tt() && p is String) {
5121 p.length; 5523 p.length;
5122 } 5524 }
5123 }'''); 5525 }''');
5124 await assertNoErrors(source); 5526 await computeAnalysisResult(source);
5527 assertNoErrors(source);
5125 verify([source]); 5528 verify([source]);
5126 } 5529 }
5127 5530
5128 test_typePromotion_if_is_and_subThenSuper() async { 5531 test_typePromotion_if_is_and_subThenSuper() async {
5129 Source source = addSource(r''' 5532 Source source = addSource(r'''
5130 class A { 5533 class A {
5131 var a; 5534 var a;
5132 } 5535 }
5133 class B extends A { 5536 class B extends A {
5134 var b; 5537 var b;
5135 } 5538 }
5136 main(Object p) { 5539 main(Object p) {
5137 if (p is B && p is A) { 5540 if (p is B && p is A) {
5138 p.a; 5541 p.a;
5139 p.b; 5542 p.b;
5140 } 5543 }
5141 }'''); 5544 }''');
5142 await assertNoErrors(source); 5545 await computeAnalysisResult(source);
5546 assertNoErrors(source);
5143 verify([source]); 5547 verify([source]);
5144 } 5548 }
5145 5549
5146 test_typePromotion_if_is_parenthesized() async { 5550 test_typePromotion_if_is_parenthesized() async {
5147 Source source = addSource(r''' 5551 Source source = addSource(r'''
5148 main(Object p) { 5552 main(Object p) {
5149 if ((p is String)) { 5553 if ((p is String)) {
5150 p.length; 5554 p.length;
5151 } 5555 }
5152 }'''); 5556 }''');
5153 await assertNoErrors(source); 5557 await computeAnalysisResult(source);
5558 assertNoErrors(source);
5154 verify([source]); 5559 verify([source]);
5155 } 5560 }
5156 5561
5157 test_typePromotion_if_is_single() async { 5562 test_typePromotion_if_is_single() async {
5158 Source source = addSource(r''' 5563 Source source = addSource(r'''
5159 main(Object p) { 5564 main(Object p) {
5160 if (p is String) { 5565 if (p is String) {
5161 p.length; 5566 p.length;
5162 } 5567 }
5163 }'''); 5568 }''');
5164 await assertNoErrors(source); 5569 await computeAnalysisResult(source);
5570 assertNoErrors(source);
5165 verify([source]); 5571 verify([source]);
5166 } 5572 }
5167 5573
5168 test_typePromotion_parentheses() async { 5574 test_typePromotion_parentheses() async {
5169 Source source = addSource(r''' 5575 Source source = addSource(r'''
5170 main(Object p) { 5576 main(Object p) {
5171 (p is String) ? p.length : 0; 5577 (p is String) ? p.length : 0;
5172 (p) is String ? p.length : 0; 5578 (p) is String ? p.length : 0;
5173 ((p)) is String ? p.length : 0; 5579 ((p)) is String ? p.length : 0;
5174 ((p) is String) ? p.length : 0; 5580 ((p) is String) ? p.length : 0;
5175 }'''); 5581 }''');
5176 await assertNoErrors(source); 5582 await computeAnalysisResult(source);
5583 assertNoErrors(source);
5177 verify([source]); 5584 verify([source]);
5178 } 5585 }
5179 5586
5180 test_typeType_class() async { 5587 test_typeType_class() async {
5181 Source source = addSource(r''' 5588 Source source = addSource(r'''
5182 class C {} 5589 class C {}
5183 f(Type t) {} 5590 f(Type t) {}
5184 main() { 5591 main() {
5185 f(C); 5592 f(C);
5186 }'''); 5593 }''');
5187 await assertNoErrors(source); 5594 await computeAnalysisResult(source);
5595 assertNoErrors(source);
5188 verify([source]); 5596 verify([source]);
5189 } 5597 }
5190 5598
5191 test_typeType_class_prefixed() async { 5599 test_typeType_class_prefixed() async {
5192 addNamedSource( 5600 addNamedSource(
5193 "/lib.dart", 5601 "/lib.dart",
5194 r''' 5602 r'''
5195 library lib; 5603 library lib;
5196 class C {}'''); 5604 class C {}''');
5197 Source source = addSource(r''' 5605 Source source = addSource(r'''
5198 import 'lib.dart' as p; 5606 import 'lib.dart' as p;
5199 f(Type t) {} 5607 f(Type t) {}
5200 main() { 5608 main() {
5201 f(p.C); 5609 f(p.C);
5202 }'''); 5610 }''');
5203 await assertNoErrors(source); 5611 await computeAnalysisResult(source);
5612 assertNoErrors(source);
5204 verify([source]); 5613 verify([source]);
5205 } 5614 }
5206 5615
5207 test_typeType_functionTypeAlias() async { 5616 test_typeType_functionTypeAlias() async {
5208 Source source = addSource(r''' 5617 Source source = addSource(r'''
5209 typedef F(); 5618 typedef F();
5210 f(Type t) {} 5619 f(Type t) {}
5211 main() { 5620 main() {
5212 f(F); 5621 f(F);
5213 }'''); 5622 }''');
5214 await assertNoErrors(source); 5623 await computeAnalysisResult(source);
5624 assertNoErrors(source);
5215 verify([source]); 5625 verify([source]);
5216 } 5626 }
5217 5627
5218 test_typeType_functionTypeAlias_prefixed() async { 5628 test_typeType_functionTypeAlias_prefixed() async {
5219 addNamedSource( 5629 addNamedSource(
5220 "/lib.dart", 5630 "/lib.dart",
5221 r''' 5631 r'''
5222 library lib; 5632 library lib;
5223 typedef F();'''); 5633 typedef F();''');
5224 Source source = addSource(r''' 5634 Source source = addSource(r'''
5225 import 'lib.dart' as p; 5635 import 'lib.dart' as p;
5226 f(Type t) {} 5636 f(Type t) {}
5227 main() { 5637 main() {
5228 f(p.F); 5638 f(p.F);
5229 }'''); 5639 }''');
5230 await assertNoErrors(source); 5640 await computeAnalysisResult(source);
5641 assertNoErrors(source);
5231 verify([source]); 5642 verify([source]);
5232 } 5643 }
5233 5644
5234 test_undefinedConstructorInInitializer_explicit_named() async { 5645 test_undefinedConstructorInInitializer_explicit_named() async {
5235 Source source = addSource(r''' 5646 Source source = addSource(r'''
5236 class A { 5647 class A {
5237 A.named() {} 5648 A.named() {}
5238 } 5649 }
5239 class B extends A { 5650 class B extends A {
5240 B() : super.named(); 5651 B() : super.named();
5241 }'''); 5652 }''');
5242 await assertNoErrors(source); 5653 await computeAnalysisResult(source);
5654 assertNoErrors(source);
5243 verify([source]); 5655 verify([source]);
5244 } 5656 }
5245 5657
5246 test_undefinedConstructorInInitializer_explicit_unnamed() async { 5658 test_undefinedConstructorInInitializer_explicit_unnamed() async {
5247 Source source = addSource(r''' 5659 Source source = addSource(r'''
5248 class A { 5660 class A {
5249 A() {} 5661 A() {}
5250 } 5662 }
5251 class B extends A { 5663 class B extends A {
5252 B() : super(); 5664 B() : super();
5253 }'''); 5665 }''');
5254 await assertNoErrors(source); 5666 await computeAnalysisResult(source);
5667 assertNoErrors(source);
5255 verify([source]); 5668 verify([source]);
5256 } 5669 }
5257 5670
5258 test_undefinedConstructorInInitializer_hasOptionalParameters() async { 5671 test_undefinedConstructorInInitializer_hasOptionalParameters() async {
5259 Source source = addSource(r''' 5672 Source source = addSource(r'''
5260 class A { 5673 class A {
5261 A([p]) {} 5674 A([p]) {}
5262 } 5675 }
5263 class B extends A { 5676 class B extends A {
5264 B(); 5677 B();
5265 }'''); 5678 }''');
5266 await assertNoErrors(source); 5679 await computeAnalysisResult(source);
5680 assertNoErrors(source);
5267 verify([source]); 5681 verify([source]);
5268 } 5682 }
5269 5683
5270 test_undefinedConstructorInInitializer_implicit() async { 5684 test_undefinedConstructorInInitializer_implicit() async {
5271 Source source = addSource(r''' 5685 Source source = addSource(r'''
5272 class A { 5686 class A {
5273 A() {} 5687 A() {}
5274 } 5688 }
5275 class B extends A { 5689 class B extends A {
5276 B(); 5690 B();
5277 }'''); 5691 }''');
5278 await assertNoErrors(source); 5692 await computeAnalysisResult(source);
5693 assertNoErrors(source);
5279 verify([source]); 5694 verify([source]);
5280 } 5695 }
5281 5696
5282 test_undefinedConstructorInInitializer_implicit_typeAlias() async { 5697 test_undefinedConstructorInInitializer_implicit_typeAlias() async {
5283 Source source = addSource(r''' 5698 Source source = addSource(r'''
5284 class M {} 5699 class M {}
5285 class A = Object with M; 5700 class A = Object with M;
5286 class B extends A { 5701 class B extends A {
5287 B(); 5702 B();
5288 }'''); 5703 }''');
5289 await assertNoErrors(source); 5704 await computeAnalysisResult(source);
5705 assertNoErrors(source);
5290 verify([source]); 5706 verify([source]);
5291 } 5707 }
5292 5708
5293 test_undefinedConstructorInInitializer_redirecting() async { 5709 test_undefinedConstructorInInitializer_redirecting() async {
5294 Source source = addSource(r''' 5710 Source source = addSource(r'''
5295 class Foo { 5711 class Foo {
5296 Foo.ctor(); 5712 Foo.ctor();
5297 } 5713 }
5298 class Bar extends Foo { 5714 class Bar extends Foo {
5299 Bar() : this.ctor(); 5715 Bar() : this.ctor();
5300 Bar.ctor() : super.ctor(); 5716 Bar.ctor() : super.ctor();
5301 }'''); 5717 }''');
5302 await assertNoErrors(source); 5718 await computeAnalysisResult(source);
5719 assertNoErrors(source);
5303 verify([source]); 5720 verify([source]);
5304 } 5721 }
5305 5722
5306 test_undefinedGetter_static_conditionalAccess() async { 5723 test_undefinedGetter_static_conditionalAccess() async {
5307 // The conditional access operator '?.' can be used to access static 5724 // The conditional access operator '?.' can be used to access static
5308 // fields. 5725 // fields.
5309 Source source = addSource(''' 5726 Source source = addSource('''
5310 class A { 5727 class A {
5311 static var x; 5728 static var x;
5312 } 5729 }
5313 var a = A?.x; 5730 var a = A?.x;
5314 '''); 5731 ''');
5315 await assertNoErrors(source); 5732 await computeAnalysisResult(source);
5733 assertNoErrors(source);
5316 verify([source]); 5734 verify([source]);
5317 } 5735 }
5318 5736
5319 test_undefinedGetter_typeSubstitution() async { 5737 test_undefinedGetter_typeSubstitution() async {
5320 Source source = addSource(r''' 5738 Source source = addSource(r'''
5321 class A<E> { 5739 class A<E> {
5322 E element; 5740 E element;
5323 } 5741 }
5324 class B extends A<List> { 5742 class B extends A<List> {
5325 m() { 5743 m() {
5326 element.last; 5744 element.last;
5327 } 5745 }
5328 }'''); 5746 }''');
5329 await assertNoErrors(source); 5747 await computeAnalysisResult(source);
5748 assertNoErrors(source);
5330 verify([source]); 5749 verify([source]);
5331 } 5750 }
5332 5751
5333 test_undefinedIdentifier_synthetic_whenExpression() async { 5752 test_undefinedIdentifier_synthetic_whenExpression() async {
5334 Source source = addSource(r''' 5753 Source source = addSource(r'''
5335 print(x) {} 5754 print(x) {}
5336 main() { 5755 main() {
5337 print(is String); 5756 print(is String);
5338 }'''); 5757 }''');
5339 await assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]); 5758 await computeAnalysisResult(source);
5759 assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]);
5340 } 5760 }
5341 5761
5342 test_undefinedIdentifier_synthetic_whenMethodName() async { 5762 test_undefinedIdentifier_synthetic_whenMethodName() async {
5343 Source source = addSource(r''' 5763 Source source = addSource(r'''
5344 print(x) {} 5764 print(x) {}
5345 main(int p) { 5765 main(int p) {
5346 p.(); 5766 p.();
5347 }'''); 5767 }''');
5348 await assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]); 5768 await computeAnalysisResult(source);
5769 assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]);
5349 } 5770 }
5350 5771
5351 test_undefinedMethod_functionExpression_callMethod() async { 5772 test_undefinedMethod_functionExpression_callMethod() async {
5352 Source source = addSource(r''' 5773 Source source = addSource(r'''
5353 main() { 5774 main() {
5354 (() => null).call(); 5775 (() => null).call();
5355 }'''); 5776 }''');
5356 await assertNoErrors(source); 5777 await computeAnalysisResult(source);
5778 assertNoErrors(source);
5357 // A call to verify(source) fails as '.call()' isn't resolved. 5779 // A call to verify(source) fails as '.call()' isn't resolved.
5358 } 5780 }
5359 5781
5360 test_undefinedMethod_functionExpression_directCall() async { 5782 test_undefinedMethod_functionExpression_directCall() async {
5361 Source source = addSource(r''' 5783 Source source = addSource(r'''
5362 main() { 5784 main() {
5363 (() => null)(); 5785 (() => null)();
5364 }'''); 5786 }''');
5365 await assertNoErrors(source); 5787 await computeAnalysisResult(source);
5788 assertNoErrors(source);
5366 // A call to verify(source) fails as '(() => null)()' isn't resolved. 5789 // A call to verify(source) fails as '(() => null)()' isn't resolved.
5367 } 5790 }
5368 5791
5369 test_undefinedMethod_static_conditionalAccess() async { 5792 test_undefinedMethod_static_conditionalAccess() async {
5370 // The conditional access operator '?.' can be used to access static 5793 // The conditional access operator '?.' can be used to access static
5371 // methods. 5794 // methods.
5372 Source source = addSource(''' 5795 Source source = addSource('''
5373 class A { 5796 class A {
5374 static void m() {} 5797 static void m() {}
5375 } 5798 }
5376 f() { A?.m(); } 5799 f() { A?.m(); }
5377 '''); 5800 ''');
5378 await assertNoErrors(source); 5801 await computeAnalysisResult(source);
5802 assertNoErrors(source);
5379 verify([source]); 5803 verify([source]);
5380 } 5804 }
5381 5805
5382 test_undefinedOperator_index() async { 5806 test_undefinedOperator_index() async {
5383 Source source = addSource(r''' 5807 Source source = addSource(r'''
5384 class A { 5808 class A {
5385 operator [](a) {} 5809 operator [](a) {}
5386 operator []=(a, b) {} 5810 operator []=(a, b) {}
5387 } 5811 }
5388 f(A a) { 5812 f(A a) {
5389 a[0]; 5813 a[0];
5390 a[0] = 1; 5814 a[0] = 1;
5391 }'''); 5815 }''');
5392 await assertNoErrors(source); 5816 await computeAnalysisResult(source);
5817 assertNoErrors(source);
5393 verify([source]); 5818 verify([source]);
5394 } 5819 }
5395 5820
5396 test_undefinedOperator_tilde() async { 5821 test_undefinedOperator_tilde() async {
5397 Source source = addSource(r''' 5822 Source source = addSource(r'''
5398 const A = 3; 5823 const A = 3;
5399 const B = ~((1 << A) - 1);'''); 5824 const B = ~((1 << A) - 1);''');
5400 await assertNoErrors(source); 5825 await computeAnalysisResult(source);
5826 assertNoErrors(source);
5401 verify([source]); 5827 verify([source]);
5402 } 5828 }
5403 5829
5404 test_undefinedSetter_importWithPrefix() async { 5830 test_undefinedSetter_importWithPrefix() async {
5405 addNamedSource( 5831 addNamedSource(
5406 "/lib.dart", 5832 "/lib.dart",
5407 r''' 5833 r'''
5408 library lib; 5834 library lib;
5409 set y(int value) {}'''); 5835 set y(int value) {}''');
5410 Source source = addSource(r''' 5836 Source source = addSource(r'''
5411 import 'lib.dart' as x; 5837 import 'lib.dart' as x;
5412 main() { 5838 main() {
5413 x.y = 0; 5839 x.y = 0;
5414 }'''); 5840 }''');
5415 await assertNoErrors(source); 5841 await computeAnalysisResult(source);
5842 assertNoErrors(source);
5416 verify([source]); 5843 verify([source]);
5417 } 5844 }
5418 5845
5419 test_undefinedSetter_static_conditionalAccess() async { 5846 test_undefinedSetter_static_conditionalAccess() async {
5420 // The conditional access operator '?.' can be used to access static 5847 // The conditional access operator '?.' can be used to access static
5421 // fields. 5848 // fields.
5422 Source source = addSource(''' 5849 Source source = addSource('''
5423 class A { 5850 class A {
5424 static var x; 5851 static var x;
5425 } 5852 }
5426 f() { A?.x = 1; } 5853 f() { A?.x = 1; }
5427 '''); 5854 ''');
5428 await assertNoErrors(source); 5855 await computeAnalysisResult(source);
5856 assertNoErrors(source);
5429 verify([source]); 5857 verify([source]);
5430 } 5858 }
5431 5859
5432 test_undefinedSuperMethod_field() async { 5860 test_undefinedSuperMethod_field() async {
5433 Source source = addSource(r''' 5861 Source source = addSource(r'''
5434 class A { 5862 class A {
5435 var m; 5863 var m;
5436 } 5864 }
5437 class B extends A { 5865 class B extends A {
5438 f() { 5866 f() {
5439 super.m(); 5867 super.m();
5440 } 5868 }
5441 }'''); 5869 }''');
5442 await assertNoErrors(source); 5870 await computeAnalysisResult(source);
5871 assertNoErrors(source);
5443 verify([source]); 5872 verify([source]);
5444 } 5873 }
5445 5874
5446 test_undefinedSuperMethod_method() async { 5875 test_undefinedSuperMethod_method() async {
5447 Source source = addSource(r''' 5876 Source source = addSource(r'''
5448 class A { 5877 class A {
5449 m() {} 5878 m() {}
5450 } 5879 }
5451 class B extends A { 5880 class B extends A {
5452 f() { 5881 f() {
5453 super.m(); 5882 super.m();
5454 } 5883 }
5455 }'''); 5884 }''');
5456 await assertNoErrors(source); 5885 await computeAnalysisResult(source);
5886 assertNoErrors(source);
5457 verify([source]); 5887 verify([source]);
5458 } 5888 }
5459 5889
5460 test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() async { 5890 test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() async {
5461 Source source = addSource(r''' 5891 Source source = addSource(r'''
5462 class A { 5892 class A {
5463 A() {} 5893 A() {}
5464 A.named() {} 5894 A.named() {}
5465 } 5895 }
5466 /// [new A] or [new A.named] 5896 /// [new A] or [new A.named]
5467 main() { 5897 main() {
5468 }'''); 5898 }''');
5469 await assertNoErrors(source); 5899 await computeAnalysisResult(source);
5900 assertNoErrors(source);
5470 verify([source]); 5901 verify([source]);
5471 } 5902 }
5472 5903
5473 test_unusedShownName_unresolved() async { 5904 test_unusedShownName_unresolved() async {
5474 Source source = addSource(r''' 5905 Source source = addSource(r'''
5475 import 'dart:math' show max, FooBar; 5906 import 'dart:math' show max, FooBar;
5476 main() { 5907 main() {
5477 print(max(1, 2)); 5908 print(max(1, 2));
5478 } 5909 }
5479 '''); 5910 ''');
5480 await assertErrors(source, [HintCode.UNDEFINED_SHOWN_NAME]); 5911 await computeAnalysisResult(source);
5912 assertErrors(source, [HintCode.UNDEFINED_SHOWN_NAME]);
5481 } 5913 }
5482 5914
5483 test_uriDoesNotExist_dll() async { 5915 test_uriDoesNotExist_dll() async {
5484 addNamedSource("/lib.dll", ""); 5916 addNamedSource("/lib.dll", "");
5485 Source source = addSource("import 'dart-ext:lib';"); 5917 Source source = addSource("import 'dart-ext:lib';");
5486 await assertNoErrors(source); 5918 await computeAnalysisResult(source);
5919 assertNoErrors(source);
5487 } 5920 }
5488 5921
5489 test_uriDoesNotExist_dylib() async { 5922 test_uriDoesNotExist_dylib() async {
5490 addNamedSource("/lib.dylib", ""); 5923 addNamedSource("/lib.dylib", "");
5491 Source source = addSource("import 'dart-ext:lib';"); 5924 Source source = addSource("import 'dart-ext:lib';");
5492 await assertNoErrors(source); 5925 await computeAnalysisResult(source);
5926 assertNoErrors(source);
5493 } 5927 }
5494 5928
5495 test_uriDoesNotExist_so() async { 5929 test_uriDoesNotExist_so() async {
5496 addNamedSource("/lib.so", ""); 5930 addNamedSource("/lib.so", "");
5497 Source source = addSource("import 'dart-ext:lib';"); 5931 Source source = addSource("import 'dart-ext:lib';");
5498 await assertNoErrors(source); 5932 await computeAnalysisResult(source);
5933 assertNoErrors(source);
5499 } 5934 }
5500 5935
5501 test_wrongNumberOfParametersForOperator1() async { 5936 test_wrongNumberOfParametersForOperator1() async {
5502 await _check_wrongNumberOfParametersForOperator1("<"); 5937 await _check_wrongNumberOfParametersForOperator1("<");
5503 await _check_wrongNumberOfParametersForOperator1(">"); 5938 await _check_wrongNumberOfParametersForOperator1(">");
5504 await _check_wrongNumberOfParametersForOperator1("<="); 5939 await _check_wrongNumberOfParametersForOperator1("<=");
5505 await _check_wrongNumberOfParametersForOperator1(">="); 5940 await _check_wrongNumberOfParametersForOperator1(">=");
5506 await _check_wrongNumberOfParametersForOperator1("+"); 5941 await _check_wrongNumberOfParametersForOperator1("+");
5507 await _check_wrongNumberOfParametersForOperator1("/"); 5942 await _check_wrongNumberOfParametersForOperator1("/");
5508 await _check_wrongNumberOfParametersForOperator1("~/"); 5943 await _check_wrongNumberOfParametersForOperator1("~/");
5509 await _check_wrongNumberOfParametersForOperator1("*"); 5944 await _check_wrongNumberOfParametersForOperator1("*");
5510 await _check_wrongNumberOfParametersForOperator1("%"); 5945 await _check_wrongNumberOfParametersForOperator1("%");
5511 await _check_wrongNumberOfParametersForOperator1("|"); 5946 await _check_wrongNumberOfParametersForOperator1("|");
5512 await _check_wrongNumberOfParametersForOperator1("^"); 5947 await _check_wrongNumberOfParametersForOperator1("^");
5513 await _check_wrongNumberOfParametersForOperator1("&"); 5948 await _check_wrongNumberOfParametersForOperator1("&");
5514 await _check_wrongNumberOfParametersForOperator1("<<"); 5949 await _check_wrongNumberOfParametersForOperator1("<<");
5515 await _check_wrongNumberOfParametersForOperator1(">>"); 5950 await _check_wrongNumberOfParametersForOperator1(">>");
5516 await _check_wrongNumberOfParametersForOperator1("[]"); 5951 await _check_wrongNumberOfParametersForOperator1("[]");
5517 } 5952 }
5518 5953
5519 test_wrongNumberOfParametersForOperator_index() async { 5954 test_wrongNumberOfParametersForOperator_index() async {
5520 Source source = addSource(r''' 5955 Source source = addSource(r'''
5521 class A { 5956 class A {
5522 operator []=(a, b) {} 5957 operator []=(a, b) {}
5523 }'''); 5958 }''');
5524 await assertNoErrors(source); 5959 await computeAnalysisResult(source);
5960 assertNoErrors(source);
5525 verify([source]); 5961 verify([source]);
5526 } 5962 }
5527 5963
5528 test_wrongNumberOfParametersForOperator_minus() async { 5964 test_wrongNumberOfParametersForOperator_minus() async {
5529 await _check_wrongNumberOfParametersForOperator("-", ""); 5965 await _check_wrongNumberOfParametersForOperator("-", "");
5530 await _check_wrongNumberOfParametersForOperator("-", "a"); 5966 await _check_wrongNumberOfParametersForOperator("-", "a");
5531 } 5967 }
5532 5968
5533 test_wrongNumberOfParametersForSetter() async { 5969 test_wrongNumberOfParametersForSetter() async {
5534 Source source = addSource(r''' 5970 Source source = addSource(r'''
5535 class A { 5971 class A {
5536 set x(a) {} 5972 set x(a) {}
5537 }'''); 5973 }''');
5538 await assertNoErrors(source); 5974 await computeAnalysisResult(source);
5975 assertNoErrors(source);
5539 verify([source]); 5976 verify([source]);
5540 } 5977 }
5541 5978
5542 test_yield_async_to_dynamic_type() async { 5979 test_yield_async_to_dynamic_type() async {
5543 Source source = addSource(''' 5980 Source source = addSource('''
5544 dynamic f() async* { 5981 dynamic f() async* {
5545 yield 3; 5982 yield 3;
5546 } 5983 }
5547 '''); 5984 ''');
5548 await assertNoErrors(source); 5985 await computeAnalysisResult(source);
5986 assertNoErrors(source);
5549 verify([source]); 5987 verify([source]);
5550 } 5988 }
5551 5989
5552 test_yield_async_to_generic_type() async { 5990 test_yield_async_to_generic_type() async {
5553 Source source = addSource(''' 5991 Source source = addSource('''
5554 import 'dart:async'; 5992 import 'dart:async';
5555 Stream f() async* { 5993 Stream f() async* {
5556 yield 3; 5994 yield 3;
5557 } 5995 }
5558 '''); 5996 ''');
5559 await assertNoErrors(source); 5997 await computeAnalysisResult(source);
5998 assertNoErrors(source);
5560 verify([source]); 5999 verify([source]);
5561 } 6000 }
5562 6001
5563 test_yield_async_to_parameterized_type() async { 6002 test_yield_async_to_parameterized_type() async {
5564 Source source = addSource(''' 6003 Source source = addSource('''
5565 import 'dart:async'; 6004 import 'dart:async';
5566 Stream<int> f() async* { 6005 Stream<int> f() async* {
5567 yield 3; 6006 yield 3;
5568 } 6007 }
5569 '''); 6008 ''');
5570 await assertNoErrors(source); 6009 await computeAnalysisResult(source);
6010 assertNoErrors(source);
5571 verify([source]); 6011 verify([source]);
5572 } 6012 }
5573 6013
5574 test_yield_async_to_untyped() async { 6014 test_yield_async_to_untyped() async {
5575 Source source = addSource(''' 6015 Source source = addSource('''
5576 f() async* { 6016 f() async* {
5577 yield 3; 6017 yield 3;
5578 } 6018 }
5579 '''); 6019 ''');
5580 await assertNoErrors(source); 6020 await computeAnalysisResult(source);
6021 assertNoErrors(source);
5581 verify([source]); 6022 verify([source]);
5582 } 6023 }
5583 6024
5584 test_yield_each_async_dynamic_to_dynamic() async { 6025 test_yield_each_async_dynamic_to_dynamic() async {
5585 Source source = addSource(''' 6026 Source source = addSource('''
5586 f() async* { 6027 f() async* {
5587 yield* g(); 6028 yield* g();
5588 } 6029 }
5589 g() => null; 6030 g() => null;
5590 '''); 6031 ''');
5591 await assertNoErrors(source); 6032 await computeAnalysisResult(source);
6033 assertNoErrors(source);
5592 verify([source]); 6034 verify([source]);
5593 } 6035 }
5594 6036
5595 test_yield_each_async_dynamic_to_stream() async { 6037 test_yield_each_async_dynamic_to_stream() async {
5596 Source source = addSource(''' 6038 Source source = addSource('''
5597 import 'dart:async'; 6039 import 'dart:async';
5598 Stream f() async* { 6040 Stream f() async* {
5599 yield* g(); 6041 yield* g();
5600 } 6042 }
5601 g() => null; 6043 g() => null;
5602 '''); 6044 ''');
5603 await assertNoErrors(source); 6045 await computeAnalysisResult(source);
6046 assertNoErrors(source);
5604 verify([source]); 6047 verify([source]);
5605 } 6048 }
5606 6049
5607 test_yield_each_async_dynamic_to_typed_stream() async { 6050 test_yield_each_async_dynamic_to_typed_stream() async {
5608 Source source = addSource(''' 6051 Source source = addSource('''
5609 import 'dart:async'; 6052 import 'dart:async';
5610 Stream<int> f() async* { 6053 Stream<int> f() async* {
5611 yield* g(); 6054 yield* g();
5612 } 6055 }
5613 g() => null; 6056 g() => null;
5614 '''); 6057 ''');
5615 await assertNoErrors(source); 6058 await computeAnalysisResult(source);
6059 assertNoErrors(source);
5616 verify([source]); 6060 verify([source]);
5617 } 6061 }
5618 6062
5619 test_yield_each_async_stream_to_dynamic() async { 6063 test_yield_each_async_stream_to_dynamic() async {
5620 Source source = addSource(''' 6064 Source source = addSource('''
5621 import 'dart:async'; 6065 import 'dart:async';
5622 f() async* { 6066 f() async* {
5623 yield* g(); 6067 yield* g();
5624 } 6068 }
5625 Stream g() => null; 6069 Stream g() => null;
5626 '''); 6070 ''');
5627 await assertNoErrors(source); 6071 await computeAnalysisResult(source);
6072 assertNoErrors(source);
5628 verify([source]); 6073 verify([source]);
5629 } 6074 }
5630 6075
5631 test_yield_each_async_typed_stream_to_dynamic() async { 6076 test_yield_each_async_typed_stream_to_dynamic() async {
5632 Source source = addSource(''' 6077 Source source = addSource('''
5633 import 'dart:async'; 6078 import 'dart:async';
5634 f() async* { 6079 f() async* {
5635 yield* g(); 6080 yield* g();
5636 } 6081 }
5637 Stream<int> g() => null; 6082 Stream<int> g() => null;
5638 '''); 6083 ''');
5639 await assertNoErrors(source); 6084 await computeAnalysisResult(source);
6085 assertNoErrors(source);
5640 verify([source]); 6086 verify([source]);
5641 } 6087 }
5642 6088
5643 test_yield_each_async_typed_stream_to_typed_stream() async { 6089 test_yield_each_async_typed_stream_to_typed_stream() async {
5644 Source source = addSource(''' 6090 Source source = addSource('''
5645 import 'dart:async'; 6091 import 'dart:async';
5646 Stream<int> f() async* { 6092 Stream<int> f() async* {
5647 yield* g(); 6093 yield* g();
5648 } 6094 }
5649 Stream<int> g() => null; 6095 Stream<int> g() => null;
5650 '''); 6096 ''');
5651 await assertNoErrors(source); 6097 await computeAnalysisResult(source);
6098 assertNoErrors(source);
5652 verify([source]); 6099 verify([source]);
5653 } 6100 }
5654 6101
5655 test_yield_each_sync_dynamic_to_dynamic() async { 6102 test_yield_each_sync_dynamic_to_dynamic() async {
5656 Source source = addSource(''' 6103 Source source = addSource('''
5657 f() sync* { 6104 f() sync* {
5658 yield* g(); 6105 yield* g();
5659 } 6106 }
5660 g() => null; 6107 g() => null;
5661 '''); 6108 ''');
5662 await assertNoErrors(source); 6109 await computeAnalysisResult(source);
6110 assertNoErrors(source);
5663 verify([source]); 6111 verify([source]);
5664 } 6112 }
5665 6113
5666 test_yield_each_sync_dynamic_to_iterable() async { 6114 test_yield_each_sync_dynamic_to_iterable() async {
5667 Source source = addSource(''' 6115 Source source = addSource('''
5668 Iterable f() sync* { 6116 Iterable f() sync* {
5669 yield* g(); 6117 yield* g();
5670 } 6118 }
5671 g() => null; 6119 g() => null;
5672 '''); 6120 ''');
5673 await assertNoErrors(source); 6121 await computeAnalysisResult(source);
6122 assertNoErrors(source);
5674 verify([source]); 6123 verify([source]);
5675 } 6124 }
5676 6125
5677 test_yield_each_sync_dynamic_to_typed_iterable() async { 6126 test_yield_each_sync_dynamic_to_typed_iterable() async {
5678 Source source = addSource(''' 6127 Source source = addSource('''
5679 Iterable<int> f() sync* { 6128 Iterable<int> f() sync* {
5680 yield* g(); 6129 yield* g();
5681 } 6130 }
5682 g() => null; 6131 g() => null;
5683 '''); 6132 ''');
5684 await assertNoErrors(source); 6133 await computeAnalysisResult(source);
6134 assertNoErrors(source);
5685 verify([source]); 6135 verify([source]);
5686 } 6136 }
5687 6137
5688 test_yield_each_sync_iterable_to_dynamic() async { 6138 test_yield_each_sync_iterable_to_dynamic() async {
5689 Source source = addSource(''' 6139 Source source = addSource('''
5690 f() sync* { 6140 f() sync* {
5691 yield* g(); 6141 yield* g();
5692 } 6142 }
5693 Iterable g() => null; 6143 Iterable g() => null;
5694 '''); 6144 ''');
5695 await assertNoErrors(source); 6145 await computeAnalysisResult(source);
6146 assertNoErrors(source);
5696 verify([source]); 6147 verify([source]);
5697 } 6148 }
5698 6149
5699 test_yield_each_sync_typed_iterable_to_dynamic() async { 6150 test_yield_each_sync_typed_iterable_to_dynamic() async {
5700 Source source = addSource(''' 6151 Source source = addSource('''
5701 f() sync* { 6152 f() sync* {
5702 yield* g(); 6153 yield* g();
5703 } 6154 }
5704 Iterable<int> g() => null; 6155 Iterable<int> g() => null;
5705 '''); 6156 ''');
5706 await assertNoErrors(source); 6157 await computeAnalysisResult(source);
6158 assertNoErrors(source);
5707 verify([source]); 6159 verify([source]);
5708 } 6160 }
5709 6161
5710 test_yield_each_sync_typed_iterable_to_typed_iterable() async { 6162 test_yield_each_sync_typed_iterable_to_typed_iterable() async {
5711 Source source = addSource(''' 6163 Source source = addSource('''
5712 Iterable<int> f() sync* { 6164 Iterable<int> f() sync* {
5713 yield* g(); 6165 yield* g();
5714 } 6166 }
5715 Iterable<int> g() => null; 6167 Iterable<int> g() => null;
5716 '''); 6168 ''');
5717 await assertNoErrors(source); 6169 await computeAnalysisResult(source);
6170 assertNoErrors(source);
5718 verify([source]); 6171 verify([source]);
5719 } 6172 }
5720 6173
5721 test_yield_sync_to_dynamic_type() async { 6174 test_yield_sync_to_dynamic_type() async {
5722 Source source = addSource(''' 6175 Source source = addSource('''
5723 dynamic f() sync* { 6176 dynamic f() sync* {
5724 yield 3; 6177 yield 3;
5725 } 6178 }
5726 '''); 6179 ''');
5727 await assertNoErrors(source); 6180 await computeAnalysisResult(source);
6181 assertNoErrors(source);
5728 verify([source]); 6182 verify([source]);
5729 } 6183 }
5730 6184
5731 test_yield_sync_to_generic_type() async { 6185 test_yield_sync_to_generic_type() async {
5732 Source source = addSource(''' 6186 Source source = addSource('''
5733 Iterable f() sync* { 6187 Iterable f() sync* {
5734 yield 3; 6188 yield 3;
5735 } 6189 }
5736 '''); 6190 ''');
5737 await assertNoErrors(source); 6191 await computeAnalysisResult(source);
6192 assertNoErrors(source);
5738 verify([source]); 6193 verify([source]);
5739 } 6194 }
5740 6195
5741 test_yield_sync_to_parameterized_type() async { 6196 test_yield_sync_to_parameterized_type() async {
5742 Source source = addSource(''' 6197 Source source = addSource('''
5743 Iterable<int> f() sync* { 6198 Iterable<int> f() sync* {
5744 yield 3; 6199 yield 3;
5745 } 6200 }
5746 '''); 6201 ''');
5747 await assertNoErrors(source); 6202 await computeAnalysisResult(source);
6203 assertNoErrors(source);
5748 verify([source]); 6204 verify([source]);
5749 } 6205 }
5750 6206
5751 test_yield_sync_to_untyped() async { 6207 test_yield_sync_to_untyped() async {
5752 Source source = addSource(''' 6208 Source source = addSource('''
5753 f() sync* { 6209 f() sync* {
5754 yield 3; 6210 yield 3;
5755 } 6211 }
5756 '''); 6212 ''');
5757 await assertNoErrors(source); 6213 await computeAnalysisResult(source);
6214 assertNoErrors(source);
5758 verify([source]); 6215 verify([source]);
5759 } 6216 }
5760 6217
5761 test_yieldInNonGenerator_asyncStar() async { 6218 test_yieldInNonGenerator_asyncStar() async {
5762 Source source = addSource(r''' 6219 Source source = addSource(r'''
5763 f() async* { 6220 f() async* {
5764 yield 0; 6221 yield 0;
5765 }'''); 6222 }''');
5766 await assertNoErrors(source); 6223 await computeAnalysisResult(source);
6224 assertNoErrors(source);
5767 verify([source]); 6225 verify([source]);
5768 } 6226 }
5769 6227
5770 test_yieldInNonGenerator_syncStar() async { 6228 test_yieldInNonGenerator_syncStar() async {
5771 Source source = addSource(r''' 6229 Source source = addSource(r'''
5772 f() sync* { 6230 f() sync* {
5773 yield 0; 6231 yield 0;
5774 }'''); 6232 }''');
5775 await assertNoErrors(source); 6233 await computeAnalysisResult(source);
6234 assertNoErrors(source);
5776 verify([source]); 6235 verify([source]);
5777 } 6236 }
5778 6237
5779 Future<Null> _check_wrongNumberOfParametersForOperator( 6238 Future<Null> _check_wrongNumberOfParametersForOperator(
5780 String name, String parameters) async { 6239 String name, String parameters) async {
5781 Source source = addSource(""" 6240 Source source = addSource("""
5782 class A { 6241 class A {
5783 operator $name($parameters) {} 6242 operator $name($parameters) {}
5784 }"""); 6243 }""");
5785 await assertNoErrors(source); 6244 await computeAnalysisResult(source);
6245 assertNoErrors(source);
5786 verify([source]); 6246 verify([source]);
5787 reset(); 6247 reset();
5788 } 6248 }
5789 6249
5790 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { 6250 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async {
5791 await _check_wrongNumberOfParametersForOperator(name, "a"); 6251 await _check_wrongNumberOfParametersForOperator(name, "a");
5792 } 6252 }
5793 6253
5794 Future<CompilationUnit> _getResolvedLibraryUnit(Source source) async { 6254 Future<CompilationUnit> _getResolvedLibraryUnit(Source source) async {
5795 return analysisContext.getResolvedCompilationUnit2(source, source); 6255 return analysisContext.getResolvedCompilationUnit2(source, source);
5796 } 6256 }
5797 } 6257 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/hint_code_test.dart ('k') | pkg/analyzer/test/generated/non_hint_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698