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

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

Powered by Google App Engine
This is Rietveld 408576698