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

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

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

Powered by Google App Engine
This is Rietveld 408576698