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

Side by Side Diff: pkg/analyzer/test/generated/compile_time_error_code_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.compile_time_error_code_test; 5 library analyzer.test.generated.compile_time_error_code_test;
6 6
7 import 'dart:async';
8
7 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart'; 10 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 12 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
11 import 'package:analyzer/src/generated/source_io.dart'; 13 import 'package:analyzer/src/generated/source_io.dart';
12 import 'package:test/test.dart' show expect; 14 import 'package:test/test.dart' show expect;
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; 15 import 'package:test_reflective_loader/test_reflective_loader.dart';
14 16
15 import 'resolver_test_case.dart'; 17 import 'resolver_test_case.dart';
16 18
17 main() { 19 main() {
18 defineReflectiveSuite(() { 20 defineReflectiveSuite(() {
19 defineReflectiveTests(CompileTimeErrorCodeTest); 21 defineReflectiveTests(CompileTimeErrorCodeTest);
20 }); 22 });
21 } 23 }
22 24
23 @reflectiveTest 25 @reflectiveTest
24 class CompileTimeErrorCodeTest extends ResolverTestCase { 26 class CompileTimeErrorCodeTest extends ResolverTestCase {
25 void fail_awaitInWrongContext_sync() { 27 fail_awaitInWrongContext_sync() async {
26 // This test requires better error recovery than we currently have. In 28 // This test requires better error recovery than we currently have. In
27 // particular, we need to be able to distinguish between an await expression 29 // particular, we need to be able to distinguish between an await expression
28 // in the wrong context, and the use of 'await' as an identifier. 30 // in the wrong context, and the use of 'await' as an identifier.
29 Source source = addSource(r''' 31 Source source = addSource(r'''
30 f(x) { 32 f(x) {
31 return await x; 33 return await x;
32 }'''); 34 }''');
33 assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]); 35 await assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
34 verify([source]); 36 verify([source]);
35 } 37 }
36 38
37 void fail_awaitInWrongContext_syncStar() { 39 fail_awaitInWrongContext_syncStar() async {
38 // This test requires better error recovery than we currently have. In 40 // This test requires better error recovery than we currently have. In
39 // particular, we need to be able to distinguish between an await expression 41 // particular, we need to be able to distinguish between an await expression
40 // in the wrong context, and the use of 'await' as an identifier. 42 // in the wrong context, and the use of 'await' as an identifier.
41 Source source = addSource(r''' 43 Source source = addSource(r'''
42 f(x) sync* { 44 f(x) sync* {
43 yield await x; 45 yield await x;
44 }'''); 46 }''');
45 assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]); 47 await assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
46 verify([source]); 48 verify([source]);
47 } 49 }
48 50
49 void fail_constEvalThrowsException() { 51 fail_constEvalThrowsException() async {
50 Source source = addSource(r''' 52 Source source = addSource(r'''
51 class C { 53 class C {
52 const C(); 54 const C();
53 } 55 }
54 f() { return const C(); }'''); 56 f() { return const C(); }''');
55 assertErrors( 57 await assertErrors(
56 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION]); 58 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION]);
57 verify([source]); 59 verify([source]);
58 } 60 }
59 61
60 void fail_invalidIdentifierInAsync_async() { 62 fail_invalidIdentifierInAsync_async() async {
61 // TODO(brianwilkerson) Report this error. 63 // TODO(brianwilkerson) Report this error.
62 Source source = addSource(r''' 64 Source source = addSource(r'''
63 class A { 65 class A {
64 m() async { 66 m() async {
65 int async; 67 int async;
66 } 68 }
67 }'''); 69 }''');
68 assertErrors(source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]); 70 await assertErrors(
71 source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]);
69 verify([source]); 72 verify([source]);
70 } 73 }
71 74
72 void fail_invalidIdentifierInAsync_await() { 75 fail_invalidIdentifierInAsync_await() async {
73 // TODO(brianwilkerson) Report this error. 76 // TODO(brianwilkerson) Report this error.
74 Source source = addSource(r''' 77 Source source = addSource(r'''
75 class A { 78 class A {
76 m() async { 79 m() async {
77 int await; 80 int await;
78 } 81 }
79 }'''); 82 }''');
80 assertErrors(source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]); 83 await assertErrors(
84 source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]);
81 verify([source]); 85 verify([source]);
82 } 86 }
83 87
84 void fail_invalidIdentifierInAsync_yield() { 88 fail_invalidIdentifierInAsync_yield() async {
85 // TODO(brianwilkerson) Report this error. 89 // TODO(brianwilkerson) Report this error.
86 Source source = addSource(r''' 90 Source source = addSource(r'''
87 class A { 91 class A {
88 m() async { 92 m() async {
89 int yield; 93 int yield;
90 } 94 }
91 }'''); 95 }''');
92 assertErrors(source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]); 96 await assertErrors(
97 source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]);
93 verify([source]); 98 verify([source]);
94 } 99 }
95 100
96 void fail_mixinDeclaresConstructor() { 101 fail_mixinDeclaresConstructor() async {
97 Source source = addSource(r''' 102 Source source = addSource(r'''
98 class A { 103 class A {
99 A() {} 104 A() {}
100 } 105 }
101 class B extends Object mixin A {}'''); 106 class B extends Object mixin A {}''');
102 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 107 await assertErrors(
108 source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
103 verify([source]); 109 verify([source]);
104 } 110 }
105 111
106 void fail_mixinOfNonClass() { 112 fail_mixinOfNonClass() async {
107 // TODO(brianwilkerson) Compare with MIXIN_WITH_NON_CLASS_SUPERCLASS. 113 // TODO(brianwilkerson) Compare with MIXIN_WITH_NON_CLASS_SUPERCLASS.
108 Source source = addSource(r''' 114 Source source = addSource(r'''
109 var A; 115 var A;
110 class B extends Object mixin A {}'''); 116 class B extends Object mixin A {}''');
111 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 117 await assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
112 verify([source]); 118 verify([source]);
113 } 119 }
114 120
115 void fail_objectCannotExtendAnotherClass() { 121 fail_objectCannotExtendAnotherClass() async {
116 Source source = addSource(r''' 122 Source source = addSource(r'''
117 '''); 123 ''');
118 assertErrors( 124 await assertErrors(
119 source, [CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]); 125 source, [CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]);
120 verify([source]); 126 verify([source]);
121 } 127 }
122 128
123 void fail_superInitializerInObject() { 129 fail_superInitializerInObject() async {
124 Source source = addSource(r''' 130 Source source = addSource(r'''
125 '''); 131 ''');
126 assertErrors(source, [CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); 132 await assertErrors(
133 source, [CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]);
127 verify([source]); 134 verify([source]);
128 } 135 }
129 136
130 void fail_yieldEachInNonGenerator_async() { 137 fail_yieldEachInNonGenerator_async() async {
131 // TODO(brianwilkerson) We are currently parsing the yield statement as a 138 // TODO(brianwilkerson) We are currently parsing the yield statement as a
132 // binary expression. 139 // binary expression.
133 Source source = addSource(r''' 140 Source source = addSource(r'''
134 f() async { 141 f() async {
135 yield* 0; 142 yield* 0;
136 }'''); 143 }''');
137 assertErrors(source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]); 144 await assertErrors(
145 source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]);
138 verify([source]); 146 verify([source]);
139 } 147 }
140 148
141 void fail_yieldEachInNonGenerator_sync() { 149 fail_yieldEachInNonGenerator_sync() async {
142 // TODO(brianwilkerson) We are currently parsing the yield statement as a 150 // TODO(brianwilkerson) We are currently parsing the yield statement as a
143 // binary expression. 151 // binary expression.
144 Source source = addSource(r''' 152 Source source = addSource(r'''
145 f() { 153 f() {
146 yield* 0; 154 yield* 0;
147 }'''); 155 }''');
148 assertErrors(source, [CompileTimeErrorCode.YIELD_IN_NON_GENERATOR]); 156 await assertErrors(source, [CompileTimeErrorCode.YIELD_IN_NON_GENERATOR]);
149 verify([source]); 157 verify([source]);
150 } 158 }
151 159
152 void fail_yieldInNonGenerator_async() { 160 fail_yieldInNonGenerator_async() async {
153 // TODO(brianwilkerson) We are currently trying to parse the yield statement 161 // TODO(brianwilkerson) We are currently trying to parse the yield statement
154 // as a binary expression. 162 // as a binary expression.
155 Source source = addSource(r''' 163 Source source = addSource(r'''
156 f() async { 164 f() async {
157 yield 0; 165 yield 0;
158 }'''); 166 }''');
159 assertErrors(source, [CompileTimeErrorCode.YIELD_IN_NON_GENERATOR]); 167 await assertErrors(source, [CompileTimeErrorCode.YIELD_IN_NON_GENERATOR]);
160 verify([source]); 168 verify([source]);
161 } 169 }
162 170
163 void fail_yieldInNonGenerator_sync() { 171 fail_yieldInNonGenerator_sync() async {
164 // TODO(brianwilkerson) We are currently trying to parse the yield statement 172 // TODO(brianwilkerson) We are currently trying to parse the yield statement
165 // as a binary expression. 173 // as a binary expression.
166 Source source = addSource(r''' 174 Source source = addSource(r'''
167 f() { 175 f() {
168 yield 0; 176 yield 0;
169 }'''); 177 }''');
170 assertErrors(source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]); 178 await assertErrors(
179 source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]);
171 verify([source]); 180 verify([source]);
172 } 181 }
173 182
174 void test_accessPrivateEnumField() { 183 test_accessPrivateEnumField() async {
175 Source source = addSource(r''' 184 Source source = addSource(r'''
176 enum E { ONE } 185 enum E { ONE }
177 String name(E e) { 186 String name(E e) {
178 return e._name; 187 return e._name;
179 }'''); 188 }''');
180 assertErrors(source, [CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD]); 189 await assertErrors(
190 source, [CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD]);
181 // Cannot verify because "_name" cannot be resolved. 191 // Cannot verify because "_name" cannot be resolved.
182 } 192 }
183 193
184 void test_ambiguousExport() { 194 test_ambiguousExport() async {
185 Source source = addSource(r''' 195 Source source = addSource(r'''
186 library L; 196 library L;
187 export 'lib1.dart'; 197 export 'lib1.dart';
188 export 'lib2.dart';'''); 198 export 'lib2.dart';''');
189 addNamedSource( 199 addNamedSource(
190 "/lib1.dart", 200 "/lib1.dart",
191 r''' 201 r'''
192 library lib1; 202 library lib1;
193 class N {}'''); 203 class N {}''');
194 addNamedSource( 204 addNamedSource(
195 "/lib2.dart", 205 "/lib2.dart",
196 r''' 206 r'''
197 library lib2; 207 library lib2;
198 class N {}'''); 208 class N {}''');
199 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); 209 await assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]);
200 verify([source]); 210 verify([source]);
201 } 211 }
202 212
203 void test_annotationWithNotClass() { 213 test_annotationWithNotClass() async {
204 Source source = addSource(''' 214 Source source = addSource('''
205 class Property { 215 class Property {
206 final int value; 216 final int value;
207 const Property(this.value); 217 const Property(this.value);
208 } 218 }
209 219
210 const Property property = const Property(42); 220 const Property property = const Property(42);
211 221
212 @property(123) 222 @property(123)
213 main() { 223 main() {
214 } 224 }
215 '''); 225 ''');
216 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); 226 await assertErrors(
227 source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]);
217 verify([source]); 228 verify([source]);
218 } 229 }
219 230
220 void test_annotationWithNotClass_prefixed() { 231 test_annotationWithNotClass_prefixed() async {
221 addNamedSource( 232 addNamedSource(
222 "/annotations.dart", 233 "/annotations.dart",
223 r''' 234 r'''
224 class Property { 235 class Property {
225 final int value; 236 final int value;
226 const Property(this.value); 237 const Property(this.value);
227 } 238 }
228 239
229 const Property property = const Property(42); 240 const Property property = const Property(42);
230 '''); 241 ''');
231 Source source = addSource(''' 242 Source source = addSource('''
232 import 'annotations.dart' as pref; 243 import 'annotations.dart' as pref;
233 @pref.property(123) 244 @pref.property(123)
234 main() { 245 main() {
235 } 246 }
236 '''); 247 ''');
237 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); 248 await assertErrors(
249 source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]);
238 verify([source]); 250 verify([source]);
239 } 251 }
240 252
241 void test_async_used_as_identifier_in_annotation() { 253 test_async_used_as_identifier_in_annotation() async {
242 Source source = addSource(''' 254 Source source = addSource('''
243 const int async = 0; 255 const int async = 0;
244 f() async { 256 f() async {
245 g(@async x) {} 257 g(@async x) {}
246 g(0); 258 g(0);
247 } 259 }
248 '''); 260 ''');
249 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 261 await assertErrors(
262 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
250 verify([source]); 263 verify([source]);
251 } 264 }
252 265
253 void test_async_used_as_identifier_in_argument_label() { 266 test_async_used_as_identifier_in_argument_label() async {
254 Source source = addSource(''' 267 Source source = addSource('''
255 @proxy 268 @proxy
256 class C {} 269 class C {}
257 f() async { 270 f() async {
258 new C().g(async: 0); 271 new C().g(async: 0);
259 } 272 }
260 '''); 273 ''');
261 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 274 await assertErrors(
275 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
262 // Note: we don't call verify([source]) because verify() doesn't understand 276 // Note: we don't call verify([source]) because verify() doesn't understand
263 // about @proxy. 277 // about @proxy.
264 } 278 }
265 279
266 void test_async_used_as_identifier_in_async_method() { 280 test_async_used_as_identifier_in_async_method() async {
267 Source source = addSource(''' 281 Source source = addSource('''
268 f() async { 282 f() async {
269 var async = 1; 283 var async = 1;
270 } 284 }
271 '''); 285 ''');
272 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 286 await assertErrors(
287 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
273 verify([source]); 288 verify([source]);
274 } 289 }
275 290
276 void test_async_used_as_identifier_in_async_star_method() { 291 test_async_used_as_identifier_in_async_star_method() async {
277 Source source = addSource(''' 292 Source source = addSource('''
278 f() async* { 293 f() async* {
279 var async = 1; 294 var async = 1;
280 } 295 }
281 '''); 296 ''');
282 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 297 await assertErrors(
298 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
283 verify([source]); 299 verify([source]);
284 } 300 }
285 301
286 void test_async_used_as_identifier_in_break_statement() { 302 test_async_used_as_identifier_in_break_statement() async {
287 Source source = addSource(''' 303 Source source = addSource('''
288 f() async { 304 f() async {
289 while (true) { 305 while (true) {
290 break async; 306 break async;
291 } 307 }
292 } 308 }
293 '''); 309 ''');
294 assertErrors(source, [ 310 await assertErrors(source, [
295 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER, 311 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
296 CompileTimeErrorCode.LABEL_UNDEFINED 312 CompileTimeErrorCode.LABEL_UNDEFINED
297 ]); 313 ]);
298 // Note: we don't call verify([source]) because the reference to the 314 // Note: we don't call verify([source]) because the reference to the
299 // "async" label is unresolved. 315 // "async" label is unresolved.
300 } 316 }
301 317
302 void test_async_used_as_identifier_in_cascaded_invocation() { 318 test_async_used_as_identifier_in_cascaded_invocation() async {
303 Source source = addSource(''' 319 Source source = addSource('''
304 class C { 320 class C {
305 int async() => 1; 321 int async() => 1;
306 } 322 }
307 f() async { 323 f() async {
308 return new C()..async(); 324 return new C()..async();
309 } 325 }
310 '''); 326 ''');
311 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 327 await assertErrors(
328 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
312 verify([source]); 329 verify([source]);
313 } 330 }
314 331
315 void test_async_used_as_identifier_in_cascaded_setter_invocation() { 332 test_async_used_as_identifier_in_cascaded_setter_invocation() async {
316 Source source = addSource(''' 333 Source source = addSource('''
317 class C { 334 class C {
318 void set async(int i) {} 335 void set async(int i) {}
319 } 336 }
320 f() async { 337 f() async {
321 return new C()..async = 1; 338 return new C()..async = 1;
322 } 339 }
323 '''); 340 ''');
324 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 341 await assertErrors(
342 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
325 verify([source]); 343 verify([source]);
326 } 344 }
327 345
328 void test_async_used_as_identifier_in_catch_exception_argument() { 346 test_async_used_as_identifier_in_catch_exception_argument() async {
329 Source source = addSource(''' 347 Source source = addSource('''
330 g() {} 348 g() {}
331 f() async { 349 f() async {
332 try { 350 try {
333 g(); 351 g();
334 } catch (async) { } 352 } catch (async) { }
335 } 353 }
336 '''); 354 ''');
337 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 355 await assertErrors(
356 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
338 verify([source]); 357 verify([source]);
339 } 358 }
340 359
341 void test_async_used_as_identifier_in_catch_stacktrace_argument() { 360 test_async_used_as_identifier_in_catch_stacktrace_argument() async {
342 Source source = addSource(''' 361 Source source = addSource('''
343 g() {} 362 g() {}
344 f() async { 363 f() async {
345 try { 364 try {
346 g(); 365 g();
347 } catch (e, async) { } 366 } catch (e, async) { }
348 } 367 }
349 '''); 368 ''');
350 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 369 await assertErrors(
370 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
351 verify([source]); 371 verify([source]);
352 } 372 }
353 373
354 void test_async_used_as_identifier_in_continue_statement() { 374 test_async_used_as_identifier_in_continue_statement() async {
355 Source source = addSource(''' 375 Source source = addSource('''
356 f() async { 376 f() async {
357 while (true) { 377 while (true) {
358 continue async; 378 continue async;
359 } 379 }
360 } 380 }
361 '''); 381 ''');
362 assertErrors(source, [ 382 await assertErrors(source, [
363 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER, 383 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
364 CompileTimeErrorCode.LABEL_UNDEFINED 384 CompileTimeErrorCode.LABEL_UNDEFINED
365 ]); 385 ]);
366 // Note: we don't call verify([source]) because the reference to the 386 // Note: we don't call verify([source]) because the reference to the
367 // "async" label is unresolved. 387 // "async" label is unresolved.
368 } 388 }
369 389
370 void test_async_used_as_identifier_in_for_statement() { 390 test_async_used_as_identifier_in_for_statement() async {
371 Source source = addSource(''' 391 Source source = addSource('''
372 var async; 392 var async;
373 f() async { 393 f() async {
374 for (async in []) {} 394 for (async in []) {}
375 } 395 }
376 '''); 396 ''');
377 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 397 await assertErrors(
398 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
378 verify([source]); 399 verify([source]);
379 } 400 }
380 401
381 void test_async_used_as_identifier_in_formal_parameter_name() { 402 test_async_used_as_identifier_in_formal_parameter_name() async {
382 Source source = addSource(''' 403 Source source = addSource('''
383 f() async { 404 f() async {
384 g(int async) {} 405 g(int async) {}
385 g(0); 406 g(0);
386 } 407 }
387 '''); 408 ''');
388 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 409 await assertErrors(
410 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
389 verify([source]); 411 verify([source]);
390 } 412 }
391 413
392 void test_async_used_as_identifier_in_getter_name() { 414 test_async_used_as_identifier_in_getter_name() async {
393 Source source = addSource(''' 415 Source source = addSource('''
394 class C { 416 class C {
395 int get async => 1; 417 int get async => 1;
396 } 418 }
397 f() async { 419 f() async {
398 return new C().async; 420 return new C().async;
399 } 421 }
400 '''); 422 ''');
401 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 423 await assertErrors(
424 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
402 verify([source]); 425 verify([source]);
403 } 426 }
404 427
405 void test_async_used_as_identifier_in_invocation() { 428 test_async_used_as_identifier_in_invocation() async {
406 Source source = addSource(''' 429 Source source = addSource('''
407 class C { 430 class C {
408 int async() => 1; 431 int async() => 1;
409 } 432 }
410 f() async { 433 f() async {
411 return new C().async(); 434 return new C().async();
412 } 435 }
413 '''); 436 ''');
414 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 437 await assertErrors(
438 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
415 verify([source]); 439 verify([source]);
416 } 440 }
417 441
418 void test_async_used_as_identifier_in_local_function_name() { 442 test_async_used_as_identifier_in_local_function_name() async {
419 Source source = addSource(''' 443 Source source = addSource('''
420 f() async { 444 f() async {
421 int async() => null; 445 int async() => null;
422 } 446 }
423 '''); 447 ''');
424 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 448 await assertErrors(
449 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
425 verify([source]); 450 verify([source]);
426 } 451 }
427 452
428 void test_async_used_as_identifier_in_prefix() { 453 test_async_used_as_identifier_in_prefix() async {
429 Source source = addSource(''' 454 Source source = addSource('''
430 import 'dart:async' as async; 455 import 'dart:async' as async;
431 f() async { 456 f() async {
432 return new async.Future.value(0); 457 return new async.Future.value(0);
433 } 458 }
434 '''); 459 ''');
435 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 460 await assertErrors(
461 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
436 verify([source]); 462 verify([source]);
437 } 463 }
438 464
439 void test_async_used_as_identifier_in_setter_name() { 465 test_async_used_as_identifier_in_setter_name() async {
440 Source source = addSource(''' 466 Source source = addSource('''
441 class C { 467 class C {
442 void set async(int i) {} 468 void set async(int i) {}
443 } 469 }
444 f() async { 470 f() async {
445 new C().async = 1; 471 new C().async = 1;
446 } 472 }
447 '''); 473 ''');
448 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 474 await assertErrors(
475 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
449 verify([source]); 476 verify([source]);
450 } 477 }
451 478
452 void test_async_used_as_identifier_in_statement_label() { 479 test_async_used_as_identifier_in_statement_label() async {
453 Source source = addSource(''' 480 Source source = addSource('''
454 f() async { 481 f() async {
455 async: g(); 482 async: g();
456 } 483 }
457 g() {} 484 g() {}
458 '''); 485 ''');
459 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 486 await assertErrors(
487 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
460 verify([source]); 488 verify([source]);
461 } 489 }
462 490
463 void test_async_used_as_identifier_in_string_interpolation() { 491 test_async_used_as_identifier_in_string_interpolation() async {
464 Source source = addSource(r''' 492 Source source = addSource(r'''
465 int async = 1; 493 int async = 1;
466 f() async { 494 f() async {
467 return "$async"; 495 return "$async";
468 } 496 }
469 '''); 497 ''');
470 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 498 await assertErrors(
499 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
471 verify([source]); 500 verify([source]);
472 } 501 }
473 502
474 void test_async_used_as_identifier_in_suffix() { 503 test_async_used_as_identifier_in_suffix() async {
475 addNamedSource( 504 addNamedSource(
476 "/lib1.dart", 505 "/lib1.dart",
477 r''' 506 r'''
478 library lib1; 507 library lib1;
479 int async; 508 int async;
480 '''); 509 ''');
481 Source source = addSource(''' 510 Source source = addSource('''
482 import 'lib1.dart' as l; 511 import 'lib1.dart' as l;
483 f() async { 512 f() async {
484 return l.async; 513 return l.async;
485 } 514 }
486 '''); 515 ''');
487 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 516 await assertErrors(
517 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
488 verify([source]); 518 verify([source]);
489 } 519 }
490 520
491 void test_async_used_as_identifier_in_switch_label() { 521 test_async_used_as_identifier_in_switch_label() async {
492 Source source = addSource(''' 522 Source source = addSource('''
493 f() async { 523 f() async {
494 switch (0) { 524 switch (0) {
495 async: case 0: break; 525 async: case 0: break;
496 } 526 }
497 } 527 }
498 '''); 528 ''');
499 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 529 await assertErrors(
530 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
500 verify([source]); 531 verify([source]);
501 } 532 }
502 533
503 void test_async_used_as_identifier_in_sync_star_method() { 534 test_async_used_as_identifier_in_sync_star_method() async {
504 Source source = addSource(''' 535 Source source = addSource('''
505 f() sync* { 536 f() sync* {
506 var async = 1; 537 var async = 1;
507 } 538 }
508 '''); 539 ''');
509 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 540 await assertErrors(
541 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
510 verify([source]); 542 verify([source]);
511 } 543 }
512 544
513 void test_asyncForInWrongContext() { 545 test_asyncForInWrongContext() async {
514 Source source = addSource(r''' 546 Source source = addSource(r'''
515 f(list) { 547 f(list) {
516 await for (var e in list) { 548 await for (var e in list) {
517 } 549 }
518 }'''); 550 }''');
519 assertErrors(source, [CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT]); 551 await assertErrors(
552 source, [CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT]);
520 verify([source]); 553 verify([source]);
521 } 554 }
522 555
523 void test_await_used_as_identifier_in_async_method() { 556 test_await_used_as_identifier_in_async_method() async {
524 Source source = addSource(''' 557 Source source = addSource('''
525 f() async { 558 f() async {
526 var await = 1; 559 var await = 1;
527 } 560 }
528 '''); 561 ''');
529 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 562 await assertErrors(
563 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
530 verify([source]); 564 verify([source]);
531 } 565 }
532 566
533 void test_await_used_as_identifier_in_async_star_method() { 567 test_await_used_as_identifier_in_async_star_method() async {
534 Source source = addSource(''' 568 Source source = addSource('''
535 f() async* { 569 f() async* {
536 var await = 1; 570 var await = 1;
537 } 571 }
538 '''); 572 ''');
539 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 573 await assertErrors(
574 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
540 verify([source]); 575 verify([source]);
541 } 576 }
542 577
543 void test_await_used_as_identifier_in_sync_star_method() { 578 test_await_used_as_identifier_in_sync_star_method() async {
544 Source source = addSource(''' 579 Source source = addSource('''
545 f() sync* { 580 f() sync* {
546 var await = 1; 581 var await = 1;
547 } 582 }
548 '''); 583 ''');
549 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 584 await assertErrors(
585 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
550 verify([source]); 586 verify([source]);
551 } 587 }
552 588
553 void test_bug_23176() { 589 test_bug_23176() async {
554 Source source = addSource(''' 590 Source source = addSource('''
555 class A { 591 class A {
556 const A([x]); 592 const A([x]);
557 } 593 }
558 class B { 594 class B {
559 dynamic @A(const A()) x; 595 dynamic @A(const A()) x;
560 } 596 }
561 '''); 597 ''');
562 assertErrors(source, [ 598 await assertErrors(source, [
563 ParserErrorCode.EXPECTED_CLASS_MEMBER, 599 ParserErrorCode.EXPECTED_CLASS_MEMBER,
564 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE 600 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
565 ]); 601 ]);
566 verify([source]); 602 verify([source]);
567 } 603 }
568 604
569 void test_builtInIdentifierAsMixinName_classTypeAlias() { 605 test_builtInIdentifierAsMixinName_classTypeAlias() async {
570 Source source = addSource(r''' 606 Source source = addSource(r'''
571 class A {} 607 class A {}
572 class B {} 608 class B {}
573 class as = A with B;'''); 609 class as = A with B;''');
574 assertErrors( 610 await assertErrors(
575 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]); 611 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
576 verify([source]); 612 verify([source]);
577 } 613 }
578 614
579 void test_builtInIdentifierAsType_formalParameter_field() { 615 test_builtInIdentifierAsType_formalParameter_field() async {
580 Source source = addSource(r''' 616 Source source = addSource(r'''
581 class A { 617 class A {
582 var x; 618 var x;
583 A(static this.x); 619 A(static this.x);
584 }'''); 620 }''');
585 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); 621 await assertErrors(
622 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
586 verify([source]); 623 verify([source]);
587 } 624 }
588 625
589 void test_builtInIdentifierAsType_formalParameter_simple() { 626 test_builtInIdentifierAsType_formalParameter_simple() async {
590 Source source = addSource(r''' 627 Source source = addSource(r'''
591 f(static x) { 628 f(static x) {
592 }'''); 629 }''');
593 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); 630 await assertErrors(
631 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
594 verify([source]); 632 verify([source]);
595 } 633 }
596 634
597 void test_builtInIdentifierAsType_variableDeclaration() { 635 test_builtInIdentifierAsType_variableDeclaration() async {
598 Source source = addSource(r''' 636 Source source = addSource(r'''
599 f() { 637 f() {
600 typedef x; 638 typedef x;
601 }'''); 639 }''');
602 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); 640 await assertErrors(
641 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
603 verify([source]); 642 verify([source]);
604 } 643 }
605 644
606 void test_builtInIdentifierAsTypedefName_functionTypeAlias() { 645 test_builtInIdentifierAsTypedefName_functionTypeAlias() async {
607 Source source = addSource("typedef bool as();"); 646 Source source = addSource("typedef bool as();");
608 assertErrors( 647 await assertErrors(
609 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]); 648 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
610 verify([source]); 649 verify([source]);
611 } 650 }
612 651
613 void test_builtInIdentifierAsTypeName() { 652 test_builtInIdentifierAsTypeName() async {
614 Source source = addSource("class as {}"); 653 Source source = addSource("class as {}");
615 assertErrors( 654 await assertErrors(
616 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]); 655 source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]);
617 verify([source]); 656 verify([source]);
618 } 657 }
619 658
620 void test_builtInIdentifierAsTypeParameterName() { 659 test_builtInIdentifierAsTypeParameterName() async {
621 Source source = addSource("class A<as> {}"); 660 Source source = addSource("class A<as> {}");
622 assertErrors(source, 661 await assertErrors(source,
623 [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME]); 662 [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME]);
624 verify([source]); 663 verify([source]);
625 } 664 }
626 665
627 void test_caseExpressionTypeImplementsEquals() { 666 test_caseExpressionTypeImplementsEquals() async {
628 Source source = addSource(r''' 667 Source source = addSource(r'''
629 class IntWrapper { 668 class IntWrapper {
630 final int value; 669 final int value;
631 const IntWrapper(this.value); 670 const IntWrapper(this.value);
632 bool operator ==(IntWrapper x) { 671 bool operator ==(IntWrapper x) {
633 return value == x.value; 672 return value == x.value;
634 } 673 }
635 get hashCode => value; 674 get hashCode => value;
636 } 675 }
637 676
638 f(var a) { 677 f(var a) {
639 switch(a) { 678 switch(a) {
640 case(const IntWrapper(1)) : return 1; 679 case(const IntWrapper(1)) : return 1;
641 default: return 0; 680 default: return 0;
642 } 681 }
643 }'''); 682 }''');
644 assertErrors( 683 await assertErrors(
645 source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 684 source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
646 verify([source]); 685 verify([source]);
647 } 686 }
648 687
649 void test_conflictingConstructorNameAndMember_field() { 688 test_conflictingConstructorNameAndMember_field() async {
650 Source source = addSource(r''' 689 Source source = addSource(r'''
651 class A { 690 class A {
652 int x; 691 int x;
653 A.x() {} 692 A.x() {}
654 }'''); 693 }''');
655 assertErrors( 694 await assertErrors(
656 source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]); 695 source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]);
657 verify([source]); 696 verify([source]);
658 } 697 }
659 698
660 void test_conflictingConstructorNameAndMember_method() { 699 test_conflictingConstructorNameAndMember_method() async {
661 Source source = addSource(r''' 700 Source source = addSource(r'''
662 class A { 701 class A {
663 const A.x(); 702 const A.x();
664 void x() {} 703 void x() {}
665 }'''); 704 }''');
666 assertErrors( 705 await assertErrors(
667 source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]); 706 source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]);
668 verify([source]); 707 verify([source]);
669 } 708 }
670 709
671 void test_conflictingGetterAndMethod_field_method() { 710 test_conflictingGetterAndMethod_field_method() async {
672 Source source = addSource(r''' 711 Source source = addSource(r'''
673 class A { 712 class A {
674 final int m = 0; 713 final int m = 0;
675 } 714 }
676 class B extends A { 715 class B extends A {
677 m() {} 716 m() {}
678 }'''); 717 }''');
679 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); 718 await assertErrors(
719 source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
680 verify([source]); 720 verify([source]);
681 } 721 }
682 722
683 void test_conflictingGetterAndMethod_getter_method() { 723 test_conflictingGetterAndMethod_getter_method() async {
684 Source source = addSource(r''' 724 Source source = addSource(r'''
685 class A { 725 class A {
686 get m => 0; 726 get m => 0;
687 } 727 }
688 class B extends A { 728 class B extends A {
689 m() {} 729 m() {}
690 }'''); 730 }''');
691 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); 731 await assertErrors(
732 source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
692 verify([source]); 733 verify([source]);
693 } 734 }
694 735
695 void test_conflictingGetterAndMethod_method_field() { 736 test_conflictingGetterAndMethod_method_field() async {
696 Source source = addSource(r''' 737 Source source = addSource(r'''
697 class A { 738 class A {
698 m() {} 739 m() {}
699 } 740 }
700 class B extends A { 741 class B extends A {
701 int m; 742 int m;
702 }'''); 743 }''');
703 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); 744 await assertErrors(
745 source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
704 verify([source]); 746 verify([source]);
705 } 747 }
706 748
707 void test_conflictingGetterAndMethod_method_getter() { 749 test_conflictingGetterAndMethod_method_getter() async {
708 Source source = addSource(r''' 750 Source source = addSource(r'''
709 class A { 751 class A {
710 m() {} 752 m() {}
711 } 753 }
712 class B extends A { 754 class B extends A {
713 get m => 0; 755 get m => 0;
714 }'''); 756 }''');
715 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); 757 await assertErrors(
758 source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
716 verify([source]); 759 verify([source]);
717 } 760 }
718 761
719 void test_conflictingTypeVariableAndClass() { 762 test_conflictingTypeVariableAndClass() async {
720 Source source = addSource(r''' 763 Source source = addSource(r'''
721 class T<T> { 764 class T<T> {
722 }'''); 765 }''');
723 assertErrors( 766 await assertErrors(
724 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLASS]); 767 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLASS]);
725 verify([source]); 768 verify([source]);
726 } 769 }
727 770
728 void test_conflictingTypeVariableAndMember_field() { 771 test_conflictingTypeVariableAndMember_field() async {
729 Source source = addSource(r''' 772 Source source = addSource(r'''
730 class A<T> { 773 class A<T> {
731 var T; 774 var T;
732 }'''); 775 }''');
733 assertErrors( 776 await assertErrors(
734 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]); 777 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
735 verify([source]); 778 verify([source]);
736 } 779 }
737 780
738 void test_conflictingTypeVariableAndMember_getter() { 781 test_conflictingTypeVariableAndMember_getter() async {
739 Source source = addSource(r''' 782 Source source = addSource(r'''
740 class A<T> { 783 class A<T> {
741 get T => null; 784 get T => null;
742 }'''); 785 }''');
743 assertErrors( 786 await assertErrors(
744 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]); 787 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
745 verify([source]); 788 verify([source]);
746 } 789 }
747 790
748 void test_conflictingTypeVariableAndMember_method() { 791 test_conflictingTypeVariableAndMember_method() async {
749 Source source = addSource(r''' 792 Source source = addSource(r'''
750 class A<T> { 793 class A<T> {
751 T() {} 794 T() {}
752 }'''); 795 }''');
753 assertErrors( 796 await assertErrors(
754 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]); 797 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
755 verify([source]); 798 verify([source]);
756 } 799 }
757 800
758 void test_conflictingTypeVariableAndMember_method_static() { 801 test_conflictingTypeVariableAndMember_method_static() async {
759 Source source = addSource(r''' 802 Source source = addSource(r'''
760 class A<T> { 803 class A<T> {
761 static T() {} 804 static T() {}
762 }'''); 805 }''');
763 assertErrors( 806 await assertErrors(
764 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]); 807 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
765 verify([source]); 808 verify([source]);
766 } 809 }
767 810
768 void test_conflictingTypeVariableAndMember_setter() { 811 test_conflictingTypeVariableAndMember_setter() async {
769 Source source = addSource(r''' 812 Source source = addSource(r'''
770 class A<T> { 813 class A<T> {
771 set T(x) {} 814 set T(x) {}
772 }'''); 815 }''');
773 assertErrors( 816 await assertErrors(
774 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]); 817 source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
775 verify([source]); 818 verify([source]);
776 } 819 }
777 820
778 void test_consistentCaseExpressionTypes_dynamic() { 821 test_consistentCaseExpressionTypes_dynamic() async {
779 // Even though A.S and S have a static type of "dynamic", we should see 822 // Even though A.S and S have a static type of "dynamic", we should see
780 // that they match 'abc', because they are constant strings. 823 // that they match 'abc', because they are constant strings.
781 Source source = addSource(r''' 824 Source source = addSource(r'''
782 class A { 825 class A {
783 static const S = 'A.S'; 826 static const S = 'A.S';
784 } 827 }
785 828
786 const S = 'S'; 829 const S = 'S';
787 830
788 foo(var p) { 831 foo(var p) {
789 switch (p) { 832 switch (p) {
790 case S: 833 case S:
791 break; 834 break;
792 case A.S: 835 case A.S:
793 break; 836 break;
794 case 'abc': 837 case 'abc':
795 break; 838 break;
796 } 839 }
797 }'''); 840 }''');
798 assertNoErrors(source); 841 await assertNoErrors(source);
799 verify([source]); 842 verify([source]);
800 } 843 }
801 844
802 void test_constConstructorWithFieldInitializedByNonConst() { 845 test_constConstructorWithFieldInitializedByNonConst() async {
803 Source source = addSource(r''' 846 Source source = addSource(r'''
804 class A { 847 class A {
805 final int i = f(); 848 final int i = f();
806 const A(); 849 const A();
807 } 850 }
808 int f() { 851 int f() {
809 return 3; 852 return 3;
810 }'''); 853 }''');
811 // TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is 854 // TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is
812 // redundant and ought to be suppressed. 855 // redundant and ought to be suppressed.
813 assertErrors(source, [ 856 await assertErrors(source, [
814 CompileTimeErrorCode 857 CompileTimeErrorCode
815 .CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST, 858 .CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
816 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 859 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
817 ]); 860 ]);
818 verify([source]); 861 verify([source]);
819 } 862 }
820 863
821 void test_constConstructorWithFieldInitializedByNonConst_static() { 864 test_constConstructorWithFieldInitializedByNonConst_static() async {
822 Source source = addSource(r''' 865 Source source = addSource(r'''
823 class A { 866 class A {
824 static final int i = f(); 867 static final int i = f();
825 const A(); 868 const A();
826 } 869 }
827 int f() { 870 int f() {
828 return 3; 871 return 3;
829 }'''); 872 }''');
830 assertNoErrors(source); 873 await assertNoErrors(source);
831 verify([source]); 874 verify([source]);
832 } 875 }
833 876
834 void test_constConstructorWithMixin() { 877 test_constConstructorWithMixin() async {
835 Source source = addSource(r''' 878 Source source = addSource(r'''
836 class M { 879 class M {
837 } 880 }
838 class A extends Object with M { 881 class A extends Object with M {
839 const A(); 882 const A();
840 }'''); 883 }''');
841 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]); 884 await assertErrors(
885 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]);
842 verify([source]); 886 verify([source]);
843 } 887 }
844 888
845 void test_constConstructorWithNonConstSuper_explicit() { 889 test_constConstructorWithNonConstSuper_explicit() async {
846 Source source = addSource(r''' 890 Source source = addSource(r'''
847 class A { 891 class A {
848 A(); 892 A();
849 } 893 }
850 class B extends A { 894 class B extends A {
851 const B(): super(); 895 const B(): super();
852 }'''); 896 }''');
853 assertErrors( 897 await assertErrors(
854 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); 898 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]);
855 verify([source]); 899 verify([source]);
856 } 900 }
857 901
858 void test_constConstructorWithNonConstSuper_implicit() { 902 test_constConstructorWithNonConstSuper_implicit() async {
859 Source source = addSource(r''' 903 Source source = addSource(r'''
860 class A { 904 class A {
861 A(); 905 A();
862 } 906 }
863 class B extends A { 907 class B extends A {
864 const B(); 908 const B();
865 }'''); 909 }''');
866 assertErrors( 910 await assertErrors(
867 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); 911 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]);
868 verify([source]); 912 verify([source]);
869 } 913 }
870 914
871 void test_constConstructorWithNonFinalField_mixin() { 915 test_constConstructorWithNonFinalField_mixin() async {
872 Source source = addSource(r''' 916 Source source = addSource(r'''
873 class A { 917 class A {
874 var a; 918 var a;
875 } 919 }
876 class B extends Object with A { 920 class B extends Object with A {
877 const B(); 921 const B();
878 }'''); 922 }''');
879 assertErrors(source, [ 923 await assertErrors(source, [
880 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN, 924 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN,
881 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD 925 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
882 ]); 926 ]);
883 verify([source]); 927 verify([source]);
884 } 928 }
885 929
886 void test_constConstructorWithNonFinalField_super() { 930 test_constConstructorWithNonFinalField_super() async {
887 Source source = addSource(r''' 931 Source source = addSource(r'''
888 class A { 932 class A {
889 var a; 933 var a;
890 } 934 }
891 class B extends A { 935 class B extends A {
892 const B(); 936 const B();
893 }'''); 937 }''');
894 assertErrors(source, [ 938 await assertErrors(source, [
895 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, 939 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD,
896 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER 940 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
897 ]); 941 ]);
898 verify([source]); 942 verify([source]);
899 } 943 }
900 944
901 void test_constConstructorWithNonFinalField_this() { 945 test_constConstructorWithNonFinalField_this() async {
902 Source source = addSource(r''' 946 Source source = addSource(r'''
903 class A { 947 class A {
904 int x; 948 int x;
905 const A(); 949 const A();
906 }'''); 950 }''');
907 assertErrors( 951 await assertErrors(
908 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); 952 source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
909 verify([source]); 953 verify([source]);
910 } 954 }
911 955
912 void test_constDeferredClass() { 956 test_constDeferredClass() async {
913 resolveWithErrors(<String>[ 957 await resolveWithErrors(<String>[
914 r''' 958 r'''
915 library lib1; 959 library lib1;
916 class A { 960 class A {
917 const A(); 961 const A();
918 }''', 962 }''',
919 r''' 963 r'''
920 library root; 964 library root;
921 import 'lib1.dart' deferred as a; 965 import 'lib1.dart' deferred as a;
922 main() { 966 main() {
923 const a.A(); 967 const a.A();
924 }''' 968 }'''
925 ], <ErrorCode>[ 969 ], <ErrorCode>[
926 CompileTimeErrorCode.CONST_DEFERRED_CLASS 970 CompileTimeErrorCode.CONST_DEFERRED_CLASS
927 ]); 971 ]);
928 } 972 }
929 973
930 void test_constDeferredClass_namedConstructor() { 974 test_constDeferredClass_namedConstructor() async {
931 resolveWithErrors(<String>[ 975 await resolveWithErrors(<String>[
932 r''' 976 r'''
933 library lib1; 977 library lib1;
934 class A { 978 class A {
935 const A.b(); 979 const A.b();
936 }''', 980 }''',
937 r''' 981 r'''
938 library root; 982 library root;
939 import 'lib1.dart' deferred as a; 983 import 'lib1.dart' deferred as a;
940 main() { 984 main() {
941 const a.A.b(); 985 const a.A.b();
942 }''' 986 }'''
943 ], <ErrorCode>[ 987 ], <ErrorCode>[
944 CompileTimeErrorCode.CONST_DEFERRED_CLASS 988 CompileTimeErrorCode.CONST_DEFERRED_CLASS
945 ]); 989 ]);
946 } 990 }
947 991
948 void test_constEval_newInstance_constConstructor() { 992 test_constEval_newInstance_constConstructor() async {
949 Source source = addSource(r''' 993 Source source = addSource(r'''
950 class A { 994 class A {
951 const A(); 995 const A();
952 } 996 }
953 const a = new A();'''); 997 const a = new A();''');
954 assertErrors(source, 998 await assertErrors(source,
955 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 999 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
956 verify([source]); 1000 verify([source]);
957 } 1001 }
958 1002
959 void test_constEval_newInstance_externalFactoryConstConstructor() { 1003 test_constEval_newInstance_externalFactoryConstConstructor() async {
960 // We can't evaluate "const A()" because its constructor is external. But 1004 // We can't evaluate "const A()" because its constructor is external. But
961 // the code is correct--we shouldn't report an error. 1005 // the code is correct--we shouldn't report an error.
962 Source source = addSource(r''' 1006 Source source = addSource(r'''
963 class A { 1007 class A {
964 external factory const A(); 1008 external factory const A();
965 } 1009 }
966 const x = const A();'''); 1010 const x = const A();''');
967 assertNoErrors(source); 1011 await assertNoErrors(source);
968 verify([source]); 1012 verify([source]);
969 } 1013 }
970 1014
971 void test_constEval_nonStaticField_inGenericClass() { 1015 test_constEval_nonStaticField_inGenericClass() async {
972 Source source = addSource(''' 1016 Source source = addSource('''
973 class C<T> { 1017 class C<T> {
974 const C(); 1018 const C();
975 T get t => null; 1019 T get t => null;
976 } 1020 }
977 1021
978 const x = const C().t;'''); 1022 const x = const C().t;''');
979 assertErrors(source, 1023 await assertErrors(source,
980 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 1024 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
981 verify([source]); 1025 verify([source]);
982 } 1026 }
983 1027
984 void test_constEval_propertyExtraction_targetNotConst() { 1028 test_constEval_propertyExtraction_targetNotConst() async {
985 Source source = addSource(r''' 1029 Source source = addSource(r'''
986 class A { 1030 class A {
987 const A(); 1031 const A();
988 m() {} 1032 m() {}
989 } 1033 }
990 final a = const A(); 1034 final a = const A();
991 const C = a.m;'''); 1035 const C = a.m;''');
992 assertErrors(source, 1036 await assertErrors(source,
993 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 1037 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
994 verify([source]); 1038 verify([source]);
995 } 1039 }
996 1040
997 void test_constEvalThrowsException_binaryMinus_null() { 1041 test_constEvalThrowsException_binaryMinus_null() async {
998 _check_constEvalThrowsException_binary_null("null - 5", false); 1042 await _check_constEvalThrowsException_binary_null("null - 5", false);
999 _check_constEvalThrowsException_binary_null("5 - null", true); 1043 await _check_constEvalThrowsException_binary_null("5 - null", true);
1000 } 1044 }
1001 1045
1002 void test_constEvalThrowsException_binaryPlus_null() { 1046 test_constEvalThrowsException_binaryPlus_null() async {
1003 _check_constEvalThrowsException_binary_null("null + 5", false); 1047 await _check_constEvalThrowsException_binary_null("null + 5", false);
1004 _check_constEvalThrowsException_binary_null("5 + null", true); 1048 await _check_constEvalThrowsException_binary_null("5 + null", true);
1005 } 1049 }
1006 1050
1007 void test_constEvalThrowsException_divisionByZero() { 1051 test_constEvalThrowsException_divisionByZero() async {
1008 Source source = addSource("const C = 1 ~/ 0;"); 1052 Source source = addSource("const C = 1 ~/ 0;");
1009 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]); 1053 await assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]);
1010 verify([source]); 1054 verify([source]);
1011 } 1055 }
1012 1056
1013 void test_constEvalThrowsException_finalAlreadySet_initializer() { 1057 test_constEvalThrowsException_finalAlreadySet_initializer() async {
1014 // If a final variable has an initializer at the site of its declaration, 1058 // If a final variable has an initializer at the site of its declaration,
1015 // and at the site of the constructor, then invoking that constructor would 1059 // and at the site of the constructor, then invoking that constructor would
1016 // produce a runtime error; hence invoking that constructor via the "const" 1060 // produce a runtime error; hence invoking that constructor via the "const"
1017 // keyword results in a compile-time error. 1061 // keyword results in a compile-time error.
1018 Source source = addSource(''' 1062 Source source = addSource('''
1019 class C { 1063 class C {
1020 final x = 1; 1064 final x = 1;
1021 const C() : x = 2; 1065 const C() : x = 2;
1022 } 1066 }
1023 var x = const C(); 1067 var x = const C();
1024 '''); 1068 ''');
1025 assertErrors(source, [ 1069 await assertErrors(source, [
1026 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 1070 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
1027 StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION 1071 StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION
1028 ]); 1072 ]);
1029 verify([source]); 1073 verify([source]);
1030 } 1074 }
1031 1075
1032 void test_constEvalThrowsException_finalAlreadySet_initializing_formal() { 1076 test_constEvalThrowsException_finalAlreadySet_initializing_formal() async {
1033 // If a final variable has an initializer at the site of its declaration, 1077 // If a final variable has an initializer at the site of its declaration,
1034 // and it is initialized using an initializing formal at the site of the 1078 // and it is initialized using an initializing formal at the site of the
1035 // constructor, then invoking that constructor would produce a runtime 1079 // constructor, then invoking that constructor would produce a runtime
1036 // error; hence invoking that constructor via the "const" keyword results 1080 // error; hence invoking that constructor via the "const" keyword results
1037 // in a compile-time error. 1081 // in a compile-time error.
1038 Source source = addSource(''' 1082 Source source = addSource('''
1039 class C { 1083 class C {
1040 final x = 1; 1084 final x = 1;
1041 const C(this.x); 1085 const C(this.x);
1042 } 1086 }
1043 var x = const C(2); 1087 var x = const C(2);
1044 '''); 1088 ''');
1045 assertErrors(source, [ 1089 await assertErrors(source, [
1046 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 1090 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
1047 StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR 1091 StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
1048 ]); 1092 ]);
1049 verify([source]); 1093 verify([source]);
1050 } 1094 }
1051 1095
1052 void test_constEvalThrowsException_unaryBitNot_null() { 1096 test_constEvalThrowsException_unaryBitNot_null() async {
1053 Source source = addSource("const C = ~null;"); 1097 Source source = addSource("const C = ~null;");
1054 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); 1098 await assertErrors(
1099 source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
1055 // no verify(), '~null' is not resolved 1100 // no verify(), '~null' is not resolved
1056 } 1101 }
1057 1102
1058 void test_constEvalThrowsException_unaryNegated_null() { 1103 test_constEvalThrowsException_unaryNegated_null() async {
1059 Source source = addSource("const C = -null;"); 1104 Source source = addSource("const C = -null;");
1060 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); 1105 await assertErrors(
1106 source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
1061 // no verify(), '-null' is not resolved 1107 // no verify(), '-null' is not resolved
1062 } 1108 }
1063 1109
1064 void test_constEvalThrowsException_unaryNot_null() { 1110 test_constEvalThrowsException_unaryNot_null() async {
1065 Source source = addSource("const C = !null;"); 1111 Source source = addSource("const C = !null;");
1066 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); 1112 await assertErrors(
1113 source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
1067 verify([source]); 1114 verify([source]);
1068 } 1115 }
1069 1116
1070 void test_constEvalTypeBool_binary() { 1117 test_constEvalTypeBool_binary() async {
1071 _check_constEvalTypeBool_withParameter_binary("p && ''"); 1118 await _check_constEvalTypeBool_withParameter_binary("p && ''");
1072 _check_constEvalTypeBool_withParameter_binary("p || ''"); 1119 await _check_constEvalTypeBool_withParameter_binary("p || ''");
1073 } 1120 }
1074 1121
1075 void test_constEvalTypeBool_binary_leftTrue() { 1122 test_constEvalTypeBool_binary_leftTrue() async {
1076 Source source = addSource("const C = (true || 0);"); 1123 Source source = addSource("const C = (true || 0);");
1077 assertErrors(source, [ 1124 await assertErrors(source, [
1078 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, 1125 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
1079 StaticTypeWarningCode.NON_BOOL_OPERAND, 1126 StaticTypeWarningCode.NON_BOOL_OPERAND,
1080 HintCode.DEAD_CODE 1127 HintCode.DEAD_CODE
1081 ]); 1128 ]);
1082 verify([source]); 1129 verify([source]);
1083 } 1130 }
1084 1131
1085 void test_constEvalTypeBoolNumString_equal() { 1132 test_constEvalTypeBoolNumString_equal() async {
1086 Source source = addSource(r''' 1133 Source source = addSource(r'''
1087 class A { 1134 class A {
1088 const A(); 1135 const A();
1089 } 1136 }
1090 class B { 1137 class B {
1091 final a; 1138 final a;
1092 const B(num p) : a = p == const A(); 1139 const B(num p) : a = p == const A();
1093 }'''); 1140 }''');
1094 assertErrors( 1141 await assertErrors(
1095 source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]); 1142 source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
1096 verify([source]); 1143 verify([source]);
1097 } 1144 }
1098 1145
1099 void test_constEvalTypeBoolNumString_notEqual() { 1146 test_constEvalTypeBoolNumString_notEqual() async {
1100 Source source = addSource(r''' 1147 Source source = addSource(r'''
1101 class A { 1148 class A {
1102 const A(); 1149 const A();
1103 } 1150 }
1104 class B { 1151 class B {
1105 final a; 1152 final a;
1106 const B(String p) : a = p != const A(); 1153 const B(String p) : a = p != const A();
1107 }'''); 1154 }''');
1108 assertErrors( 1155 await assertErrors(
1109 source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]); 1156 source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
1110 verify([source]); 1157 verify([source]);
1111 } 1158 }
1112 1159
1113 void test_constEvalTypeInt_binary() { 1160 test_constEvalTypeInt_binary() async {
1114 _check_constEvalTypeInt_withParameter_binary("p ^ ''"); 1161 await _check_constEvalTypeInt_withParameter_binary("p ^ ''");
1115 _check_constEvalTypeInt_withParameter_binary("p & ''"); 1162 await _check_constEvalTypeInt_withParameter_binary("p & ''");
1116 _check_constEvalTypeInt_withParameter_binary("p | ''"); 1163 await _check_constEvalTypeInt_withParameter_binary("p | ''");
1117 _check_constEvalTypeInt_withParameter_binary("p >> ''"); 1164 await _check_constEvalTypeInt_withParameter_binary("p >> ''");
1118 _check_constEvalTypeInt_withParameter_binary("p << ''"); 1165 await _check_constEvalTypeInt_withParameter_binary("p << ''");
1119 } 1166 }
1120 1167
1121 void test_constEvalTypeNum_binary() { 1168 test_constEvalTypeNum_binary() async {
1122 _check_constEvalTypeNum_withParameter_binary("p + ''"); 1169 await _check_constEvalTypeNum_withParameter_binary("p + ''");
1123 _check_constEvalTypeNum_withParameter_binary("p - ''"); 1170 await _check_constEvalTypeNum_withParameter_binary("p - ''");
1124 _check_constEvalTypeNum_withParameter_binary("p * ''"); 1171 await _check_constEvalTypeNum_withParameter_binary("p * ''");
1125 _check_constEvalTypeNum_withParameter_binary("p / ''"); 1172 await _check_constEvalTypeNum_withParameter_binary("p / ''");
1126 _check_constEvalTypeNum_withParameter_binary("p ~/ ''"); 1173 await _check_constEvalTypeNum_withParameter_binary("p ~/ ''");
1127 _check_constEvalTypeNum_withParameter_binary("p > ''"); 1174 await _check_constEvalTypeNum_withParameter_binary("p > ''");
1128 _check_constEvalTypeNum_withParameter_binary("p < ''"); 1175 await _check_constEvalTypeNum_withParameter_binary("p < ''");
1129 _check_constEvalTypeNum_withParameter_binary("p >= ''"); 1176 await _check_constEvalTypeNum_withParameter_binary("p >= ''");
1130 _check_constEvalTypeNum_withParameter_binary("p <= ''"); 1177 await _check_constEvalTypeNum_withParameter_binary("p <= ''");
1131 _check_constEvalTypeNum_withParameter_binary("p % ''"); 1178 await _check_constEvalTypeNum_withParameter_binary("p % ''");
1132 } 1179 }
1133 1180
1134 void test_constFormalParameter_fieldFormalParameter() { 1181 test_constFormalParameter_fieldFormalParameter() async {
1135 Source source = addSource(r''' 1182 Source source = addSource(r'''
1136 class A { 1183 class A {
1137 var x; 1184 var x;
1138 A(const this.x) {} 1185 A(const this.x) {}
1139 }'''); 1186 }''');
1140 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 1187 await assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
1141 verify([source]); 1188 verify([source]);
1142 } 1189 }
1143 1190
1144 void test_constFormalParameter_simpleFormalParameter() { 1191 test_constFormalParameter_simpleFormalParameter() async {
1145 Source source = addSource("f(const x) {}"); 1192 Source source = addSource("f(const x) {}");
1146 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 1193 await assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
1147 verify([source]); 1194 verify([source]);
1148 } 1195 }
1149 1196
1150 void test_constInitializedWithNonConstValue() { 1197 test_constInitializedWithNonConstValue() async {
1151 Source source = addSource(r''' 1198 Source source = addSource(r'''
1152 f(p) { 1199 f(p) {
1153 const C = p; 1200 const C = p;
1154 }'''); 1201 }''');
1155 assertErrors(source, 1202 await assertErrors(source,
1156 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 1203 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
1157 verify([source]); 1204 verify([source]);
1158 } 1205 }
1159 1206
1160 void test_constInitializedWithNonConstValue_finalField() { 1207 test_constInitializedWithNonConstValue_finalField() async {
1161 // Regression test for bug #25526 which previously 1208 // Regression test for bug #25526 which previously
1162 // caused two errors to be reported. 1209 // caused two errors to be reported.
1163 Source source = addSource(r''' 1210 Source source = addSource(r'''
1164 class Foo { 1211 class Foo {
1165 final field = []; 1212 final field = [];
1166 foo([int x = field]) {} 1213 foo([int x = field]) {}
1167 } 1214 }
1168 '''); 1215 ''');
1169 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 1216 await assertErrors(
1217 source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
1170 verify([source]); 1218 verify([source]);
1171 } 1219 }
1172 1220
1173 void test_constInitializedWithNonConstValue_missingConstInListLiteral() { 1221 test_constInitializedWithNonConstValue_missingConstInListLiteral() async {
1174 Source source = addSource("const List L = [0];"); 1222 Source source = addSource("const List L = [0];");
1175 assertErrors(source, 1223 await assertErrors(source,
1176 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 1224 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
1177 verify([source]); 1225 verify([source]);
1178 } 1226 }
1179 1227
1180 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { 1228 test_constInitializedWithNonConstValue_missingConstInMapLiteral() async {
1181 Source source = addSource("const Map M = {'a' : 0};"); 1229 Source source = addSource("const Map M = {'a' : 0};");
1182 assertErrors(source, 1230 await assertErrors(source,
1183 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 1231 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
1184 verify([source]); 1232 verify([source]);
1185 } 1233 }
1186 1234
1187 void test_constInitializedWithNonConstValueFromDeferredClass() { 1235 test_constInitializedWithNonConstValueFromDeferredClass() async {
1188 resolveWithErrors(<String>[ 1236 await resolveWithErrors(<String>[
1189 r''' 1237 r'''
1190 library lib1; 1238 library lib1;
1191 const V = 1;''', 1239 const V = 1;''',
1192 r''' 1240 r'''
1193 library root; 1241 library root;
1194 import 'lib1.dart' deferred as a; 1242 import 'lib1.dart' deferred as a;
1195 const B = a.V;''' 1243 const B = a.V;'''
1196 ], <ErrorCode>[ 1244 ], <ErrorCode>[
1197 CompileTimeErrorCode 1245 CompileTimeErrorCode
1198 .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY 1246 .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
1199 ]); 1247 ]);
1200 } 1248 }
1201 1249
1202 void test_constInitializedWithNonConstValueFromDeferredClass_nested() { 1250 test_constInitializedWithNonConstValueFromDeferredClass_nested() async {
1203 resolveWithErrors(<String>[ 1251 await resolveWithErrors(<String>[
1204 r''' 1252 r'''
1205 library lib1; 1253 library lib1;
1206 const V = 1;''', 1254 const V = 1;''',
1207 r''' 1255 r'''
1208 library root; 1256 library root;
1209 import 'lib1.dart' deferred as a; 1257 import 'lib1.dart' deferred as a;
1210 const B = a.V + 1;''' 1258 const B = a.V + 1;'''
1211 ], <ErrorCode>[ 1259 ], <ErrorCode>[
1212 CompileTimeErrorCode 1260 CompileTimeErrorCode
1213 .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY 1261 .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
1214 ]); 1262 ]);
1215 } 1263 }
1216 1264
1217 void test_constInstanceField() { 1265 test_constInstanceField() async {
1218 Source source = addSource(r''' 1266 Source source = addSource(r'''
1219 class C { 1267 class C {
1220 const int f = 0; 1268 const int f = 0;
1221 }'''); 1269 }''');
1222 assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]); 1270 await assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]);
1223 verify([source]); 1271 verify([source]);
1224 } 1272 }
1225 1273
1226 void test_constMapKeyTypeImplementsEquals_direct() { 1274 test_constMapKeyTypeImplementsEquals_direct() async {
1227 Source source = addSource(r''' 1275 Source source = addSource(r'''
1228 class A { 1276 class A {
1229 const A(); 1277 const A();
1230 operator ==(other) => false; 1278 operator ==(other) => false;
1231 } 1279 }
1232 main() { 1280 main() {
1233 const {const A() : 0}; 1281 const {const A() : 0};
1234 }'''); 1282 }''');
1235 assertErrors(source, 1283 await assertErrors(source,
1236 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 1284 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
1237 verify([source]); 1285 verify([source]);
1238 } 1286 }
1239 1287
1240 void test_constMapKeyTypeImplementsEquals_dynamic() { 1288 test_constMapKeyTypeImplementsEquals_dynamic() async {
1241 // Note: static type of B.a is "dynamic", but actual type of the const 1289 // Note: static type of B.a is "dynamic", but actual type of the const
1242 // object is A. We need to make sure we examine the actual type when 1290 // object is A. We need to make sure we examine the actual type when
1243 // deciding whether there is a problem with operator==. 1291 // deciding whether there is a problem with operator==.
1244 Source source = addSource(r''' 1292 Source source = addSource(r'''
1245 class A { 1293 class A {
1246 const A(); 1294 const A();
1247 operator ==(other) => false; 1295 operator ==(other) => false;
1248 } 1296 }
1249 class B { 1297 class B {
1250 static const a = const A(); 1298 static const a = const A();
1251 } 1299 }
1252 main() { 1300 main() {
1253 const {B.a : 0}; 1301 const {B.a : 0};
1254 }'''); 1302 }''');
1255 assertErrors(source, 1303 await assertErrors(source,
1256 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 1304 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
1257 verify([source]); 1305 verify([source]);
1258 } 1306 }
1259 1307
1260 void test_constMapKeyTypeImplementsEquals_factory() { 1308 test_constMapKeyTypeImplementsEquals_factory() async {
1261 Source source = addSource(r''' 1309 Source source = addSource(r'''
1262 class A { const factory A() = B; } 1310 class A { const factory A() = B; }
1263 1311
1264 class B implements A { 1312 class B implements A {
1265 const B(); 1313 const B();
1266 1314
1267 operator ==(o) => true; 1315 operator ==(o) => true;
1268 } 1316 }
1269 1317
1270 main() { 1318 main() {
1271 var m = const { const A(): 42 }; 1319 var m = const { const A(): 42 };
1272 }'''); 1320 }''');
1273 assertErrors(source, 1321 await assertErrors(source,
1274 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 1322 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
1275 verify([source]); 1323 verify([source]);
1276 } 1324 }
1277 1325
1278 void test_constMapKeyTypeImplementsEquals_super() { 1326 test_constMapKeyTypeImplementsEquals_super() async {
1279 Source source = addSource(r''' 1327 Source source = addSource(r'''
1280 class A { 1328 class A {
1281 const A(); 1329 const A();
1282 operator ==(other) => false; 1330 operator ==(other) => false;
1283 } 1331 }
1284 class B extends A { 1332 class B extends A {
1285 const B(); 1333 const B();
1286 } 1334 }
1287 main() { 1335 main() {
1288 const {const B() : 0}; 1336 const {const B() : 0};
1289 }'''); 1337 }''');
1290 assertErrors(source, 1338 await assertErrors(source,
1291 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 1339 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
1292 verify([source]); 1340 verify([source]);
1293 } 1341 }
1294 1342
1295 void test_constWithInvalidTypeParameters() { 1343 test_constWithInvalidTypeParameters() async {
1296 Source source = addSource(r''' 1344 Source source = addSource(r'''
1297 class A { 1345 class A {
1298 const A(); 1346 const A();
1299 } 1347 }
1300 f() { return const A<A>(); }'''); 1348 f() { return const A<A>(); }''');
1301 assertErrors( 1349 await assertErrors(
1302 source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); 1350 source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
1303 verify([source]); 1351 verify([source]);
1304 } 1352 }
1305 1353
1306 void test_constWithInvalidTypeParameters_tooFew() { 1354 test_constWithInvalidTypeParameters_tooFew() async {
1307 Source source = addSource(r''' 1355 Source source = addSource(r'''
1308 class A {} 1356 class A {}
1309 class C<K, V> { 1357 class C<K, V> {
1310 const C(); 1358 const C();
1311 } 1359 }
1312 f(p) { 1360 f(p) {
1313 return const C<A>(); 1361 return const C<A>();
1314 }'''); 1362 }''');
1315 assertErrors( 1363 await assertErrors(
1316 source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); 1364 source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
1317 verify([source]); 1365 verify([source]);
1318 } 1366 }
1319 1367
1320 void test_constWithInvalidTypeParameters_tooMany() { 1368 test_constWithInvalidTypeParameters_tooMany() async {
1321 Source source = addSource(r''' 1369 Source source = addSource(r'''
1322 class A {} 1370 class A {}
1323 class C<E> { 1371 class C<E> {
1324 const C(); 1372 const C();
1325 } 1373 }
1326 f(p) { 1374 f(p) {
1327 return const C<A, A>(); 1375 return const C<A, A>();
1328 }'''); 1376 }''');
1329 assertErrors( 1377 await assertErrors(
1330 source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); 1378 source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
1331 verify([source]); 1379 verify([source]);
1332 } 1380 }
1333 1381
1334 void test_constWithNonConst() { 1382 test_constWithNonConst() async {
1335 Source source = addSource(r''' 1383 Source source = addSource(r'''
1336 class T { 1384 class T {
1337 T(a, b, {c, d}) {} 1385 T(a, b, {c, d}) {}
1338 } 1386 }
1339 f() { return const T(0, 1, c: 2, d: 3); }'''); 1387 f() { return const T(0, 1, c: 2, d: 3); }''');
1340 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); 1388 await assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]);
1341 verify([source]); 1389 verify([source]);
1342 } 1390 }
1343 1391
1344 void test_constWithNonConst_with() { 1392 test_constWithNonConst_with() async {
1345 Source source = addSource(r''' 1393 Source source = addSource(r'''
1346 class B { 1394 class B {
1347 const B(); 1395 const B();
1348 } 1396 }
1349 class C = B with M; 1397 class C = B with M;
1350 class M {} 1398 class M {}
1351 const x = const C(); 1399 const x = const C();
1352 main() { 1400 main() {
1353 print(x); 1401 print(x);
1354 } 1402 }
1355 '''); 1403 ''');
1356 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); 1404 await assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]);
1357 verify([source]); 1405 verify([source]);
1358 } 1406 }
1359 1407
1360 void test_constWithNonConstantArgument_annotation() { 1408 test_constWithNonConstantArgument_annotation() async {
1361 Source source = addSource(r''' 1409 Source source = addSource(r'''
1362 class A { 1410 class A {
1363 const A(int p); 1411 const A(int p);
1364 } 1412 }
1365 var v = 42; 1413 var v = 42;
1366 @A(v) 1414 @A(v)
1367 main() { 1415 main() {
1368 }'''); 1416 }''');
1369 assertErrors( 1417 await assertErrors(
1370 source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]); 1418 source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]);
1371 verify([source]); 1419 verify([source]);
1372 } 1420 }
1373 1421
1374 void test_constWithNonConstantArgument_instanceCreation() { 1422 test_constWithNonConstantArgument_instanceCreation() async {
1375 Source source = addSource(r''' 1423 Source source = addSource(r'''
1376 class A { 1424 class A {
1377 const A(a); 1425 const A(a);
1378 } 1426 }
1379 f(p) { return const A(p); }'''); 1427 f(p) { return const A(p); }''');
1380 // TODO(paulberry): the error INVALID_CONSTAT is redundant and ought to be 1428 // TODO(paulberry): the error INVALID_CONSTAT is redundant and ought to be
1381 // suppressed. 1429 // suppressed.
1382 assertErrors(source, [ 1430 await assertErrors(source, [
1383 CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT, 1431 CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT,
1384 CompileTimeErrorCode.INVALID_CONSTANT 1432 CompileTimeErrorCode.INVALID_CONSTANT
1385 ]); 1433 ]);
1386 verify([source]); 1434 verify([source]);
1387 } 1435 }
1388 1436
1389 void test_constWithNonType() { 1437 test_constWithNonType() async {
1390 Source source = addSource(r''' 1438 Source source = addSource(r'''
1391 int A; 1439 int A;
1392 f() { 1440 f() {
1393 return const A(); 1441 return const A();
1394 }'''); 1442 }''');
1395 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); 1443 await assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
1396 verify([source]); 1444 verify([source]);
1397 } 1445 }
1398 1446
1399 void test_constWithNonType_fromLibrary() { 1447 test_constWithNonType_fromLibrary() async {
1400 Source source1 = addNamedSource("/lib.dart", ""); 1448 Source source1 = addNamedSource("/lib.dart", "");
1401 Source source2 = addNamedSource( 1449 Source source2 = addNamedSource(
1402 "/lib2.dart", 1450 "/lib2.dart",
1403 r''' 1451 r'''
1404 import 'lib.dart' as lib; 1452 import 'lib.dart' as lib;
1405 void f() { 1453 void f() {
1406 const lib.A(); 1454 const lib.A();
1407 }'''); 1455 }''');
1408 assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); 1456 await assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
1409 verify([source1]); 1457 verify([source1]);
1410 } 1458 }
1411 1459
1412 void test_constWithTypeParameters_direct() { 1460 test_constWithTypeParameters_direct() async {
1413 Source source = addSource(r''' 1461 Source source = addSource(r'''
1414 class A<T> { 1462 class A<T> {
1415 static const V = const A<T>(); 1463 static const V = const A<T>();
1416 const A(); 1464 const A();
1417 }'''); 1465 }''');
1418 assertErrors(source, [ 1466 await assertErrors(source, [
1419 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, 1467 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
1420 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC 1468 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC
1421 ]); 1469 ]);
1422 verify([source]); 1470 verify([source]);
1423 } 1471 }
1424 1472
1425 void test_constWithTypeParameters_indirect() { 1473 test_constWithTypeParameters_indirect() async {
1426 Source source = addSource(r''' 1474 Source source = addSource(r'''
1427 class A<T> { 1475 class A<T> {
1428 static const V = const A<List<T>>(); 1476 static const V = const A<List<T>>();
1429 const A(); 1477 const A();
1430 }'''); 1478 }''');
1431 assertErrors(source, [ 1479 await assertErrors(source, [
1432 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, 1480 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
1433 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC 1481 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC
1434 ]); 1482 ]);
1435 verify([source]); 1483 verify([source]);
1436 } 1484 }
1437 1485
1438 void test_constWithUndefinedConstructor() { 1486 test_constWithUndefinedConstructor() async {
1439 Source source = addSource(r''' 1487 Source source = addSource(r'''
1440 class A { 1488 class A {
1441 const A(); 1489 const A();
1442 } 1490 }
1443 f() { 1491 f() {
1444 return const A.noSuchConstructor(); 1492 return const A.noSuchConstructor();
1445 }'''); 1493 }''');
1446 assertErrors( 1494 await assertErrors(
1447 source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]); 1495 source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
1448 // no verify(), 'noSuchConstructor' is not resolved 1496 // no verify(), 'noSuchConstructor' is not resolved
1449 } 1497 }
1450 1498
1451 void test_constWithUndefinedConstructorDefault() { 1499 test_constWithUndefinedConstructorDefault() async {
1452 Source source = addSource(r''' 1500 Source source = addSource(r'''
1453 class A { 1501 class A {
1454 const A.name(); 1502 const A.name();
1455 } 1503 }
1456 f() { 1504 f() {
1457 return const A(); 1505 return const A();
1458 }'''); 1506 }''');
1459 assertErrors(source, 1507 await assertErrors(source,
1460 [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]); 1508 [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]);
1461 verify([source]); 1509 verify([source]);
1462 } 1510 }
1463 1511
1464 void test_defaultValueInFunctionTypeAlias() { 1512 test_defaultValueInFunctionTypeAlias() async {
1465 Source source = addSource("typedef F([x = 0]);"); 1513 Source source = addSource("typedef F([x = 0]);");
1466 assertErrors( 1514 await assertErrors(
1467 source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]); 1515 source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]);
1468 verify([source]); 1516 verify([source]);
1469 } 1517 }
1470 1518
1471 void test_defaultValueInFunctionTypedParameter_named() { 1519 test_defaultValueInFunctionTypedParameter_named() async {
1472 Source source = addSource("f(g({p: null})) {}"); 1520 Source source = addSource("f(g({p: null})) {}");
1473 assertErrors(source, 1521 await assertErrors(source,
1474 [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER]); 1522 [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER]);
1475 verify([source]); 1523 verify([source]);
1476 } 1524 }
1477 1525
1478 void test_defaultValueInFunctionTypedParameter_optional() { 1526 test_defaultValueInFunctionTypedParameter_optional() async {
1479 Source source = addSource("f(g([p = null])) {}"); 1527 Source source = addSource("f(g([p = null])) {}");
1480 assertErrors(source, 1528 await assertErrors(source,
1481 [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER]); 1529 [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER]);
1482 verify([source]); 1530 verify([source]);
1483 } 1531 }
1484 1532
1485 void test_defaultValueInRedirectingFactoryConstructor() { 1533 test_defaultValueInRedirectingFactoryConstructor() async {
1486 Source source = addSource(r''' 1534 Source source = addSource(r'''
1487 class A { 1535 class A {
1488 factory A([int x = 0]) = B; 1536 factory A([int x = 0]) = B;
1489 } 1537 }
1490 1538
1491 class B implements A { 1539 class B implements A {
1492 B([int x = 1]) {} 1540 B([int x = 1]) {}
1493 }'''); 1541 }''');
1494 assertErrors(source, [ 1542 await assertErrors(source, [
1495 CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR 1543 CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
1496 ]); 1544 ]);
1497 verify([source]); 1545 verify([source]);
1498 } 1546 }
1499 1547
1500 void test_duplicateConstructorName_named() { 1548 test_duplicateConstructorName_named() async {
1501 Source source = addSource(r''' 1549 Source source = addSource(r'''
1502 class A { 1550 class A {
1503 A.a() {} 1551 A.a() {}
1504 A.a() {} 1552 A.a() {}
1505 }'''); 1553 }''');
1506 assertErrors(source, [ 1554 await assertErrors(source, [
1507 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, 1555 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME,
1508 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME 1556 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME
1509 ]); 1557 ]);
1510 verify([source]); 1558 verify([source]);
1511 } 1559 }
1512 1560
1513 void test_duplicateConstructorName_unnamed() { 1561 test_duplicateConstructorName_unnamed() async {
1514 Source source = addSource(r''' 1562 Source source = addSource(r'''
1515 class A { 1563 class A {
1516 A() {} 1564 A() {}
1517 A() {} 1565 A() {}
1518 }'''); 1566 }''');
1519 assertErrors(source, [ 1567 await assertErrors(source, [
1520 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, 1568 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT,
1521 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT 1569 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT
1522 ]); 1570 ]);
1523 verify([source]); 1571 verify([source]);
1524 } 1572 }
1525 1573
1526 void test_duplicateDefinition_acrossLibraries() { 1574 test_duplicateDefinition_acrossLibraries() async {
1527 Source librarySource = addNamedSource( 1575 Source librarySource = addNamedSource(
1528 "/lib.dart", 1576 "/lib.dart",
1529 r''' 1577 r'''
1530 library lib; 1578 library lib;
1531 1579
1532 part 'a.dart'; 1580 part 'a.dart';
1533 part 'b.dart';'''); 1581 part 'b.dart';''');
1534 Source sourceA = addNamedSource( 1582 Source sourceA = addNamedSource(
1535 "/a.dart", 1583 "/a.dart",
1536 r''' 1584 r'''
1537 part of lib; 1585 part of lib;
1538 1586
1539 class A {}'''); 1587 class A {}''');
1540 Source sourceB = addNamedSource( 1588 Source sourceB = addNamedSource(
1541 "/b.dart", 1589 "/b.dart",
1542 r''' 1590 r'''
1543 part of lib; 1591 part of lib;
1544 1592
1545 class A {}'''); 1593 class A {}''');
1546 assertNoErrors(librarySource); 1594 await assertNoErrors(librarySource);
1547 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1595 await assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1548 verify([librarySource, sourceA, sourceB]); 1596 verify([librarySource, sourceA, sourceB]);
1549 } 1597 }
1550 1598
1551 void test_duplicateDefinition_catch() { 1599 test_duplicateDefinition_catch() async {
1552 Source source = addSource(r''' 1600 Source source = addSource(r'''
1553 main() { 1601 main() {
1554 try {} catch (e, e) {} 1602 try {} catch (e, e) {}
1555 }'''); 1603 }''');
1556 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1604 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1557 verify([source]); 1605 verify([source]);
1558 } 1606 }
1559 1607
1560 void test_duplicateDefinition_classMembers_fields() { 1608 test_duplicateDefinition_classMembers_fields() async {
1561 Source source = addSource(r''' 1609 Source source = addSource(r'''
1562 class A { 1610 class A {
1563 int a; 1611 int a;
1564 int a; 1612 int a;
1565 }'''); 1613 }''');
1566 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1614 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1567 verify([source]); 1615 verify([source]);
1568 } 1616 }
1569 1617
1570 void test_duplicateDefinition_classMembers_fields_oneStatic() { 1618 test_duplicateDefinition_classMembers_fields_oneStatic() async {
1571 Source source = addSource(r''' 1619 Source source = addSource(r'''
1572 class A { 1620 class A {
1573 int x; 1621 int x;
1574 static int x; 1622 static int x;
1575 }'''); 1623 }''');
1576 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1624 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1577 verify([source]); 1625 verify([source]);
1578 } 1626 }
1579 1627
1580 void test_duplicateDefinition_classMembers_methods() { 1628 test_duplicateDefinition_classMembers_methods() async {
1581 Source source = addSource(r''' 1629 Source source = addSource(r'''
1582 class A { 1630 class A {
1583 m() {} 1631 m() {}
1584 m() {} 1632 m() {}
1585 }'''); 1633 }''');
1586 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1634 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1587 verify([source]); 1635 verify([source]);
1588 } 1636 }
1589 1637
1590 void test_duplicateDefinition_inPart() { 1638 test_duplicateDefinition_inPart() async {
1591 Source librarySource = addNamedSource( 1639 Source librarySource = addNamedSource(
1592 "/lib.dart", 1640 "/lib.dart",
1593 r''' 1641 r'''
1594 library test; 1642 library test;
1595 part 'a.dart'; 1643 part 'a.dart';
1596 class A {}'''); 1644 class A {}''');
1597 Source sourceA = addNamedSource( 1645 Source sourceA = addNamedSource(
1598 "/a.dart", 1646 "/a.dart",
1599 r''' 1647 r'''
1600 part of test; 1648 part of test;
1601 class A {}'''); 1649 class A {}''');
1602 assertNoErrors(librarySource); 1650 await assertNoErrors(librarySource);
1603 assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1651 await assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1604 verify([librarySource, sourceA]); 1652 verify([librarySource, sourceA]);
1605 } 1653 }
1606 1654
1607 void test_duplicateDefinition_locals_inCase() { 1655 test_duplicateDefinition_locals_inCase() async {
1608 Source source = addSource(r''' 1656 Source source = addSource(r'''
1609 main() { 1657 main() {
1610 switch(1) { 1658 switch(1) {
1611 case 1: 1659 case 1:
1612 var a; 1660 var a;
1613 var a; 1661 var a;
1614 } 1662 }
1615 }'''); 1663 }''');
1616 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1664 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1617 verify([source]); 1665 verify([source]);
1618 } 1666 }
1619 1667
1620 void test_duplicateDefinition_locals_inFunctionBlock() { 1668 test_duplicateDefinition_locals_inFunctionBlock() async {
1621 Source source = addSource(r''' 1669 Source source = addSource(r'''
1622 main() { 1670 main() {
1623 int m = 0; 1671 int m = 0;
1624 m(a) {} 1672 m(a) {}
1625 }'''); 1673 }''');
1626 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1674 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1627 verify([source]); 1675 verify([source]);
1628 } 1676 }
1629 1677
1630 void test_duplicateDefinition_locals_inIf() { 1678 test_duplicateDefinition_locals_inIf() async {
1631 Source source = addSource(r''' 1679 Source source = addSource(r'''
1632 main(int p) { 1680 main(int p) {
1633 if (p != 0) { 1681 if (p != 0) {
1634 var a; 1682 var a;
1635 var a; 1683 var a;
1636 } 1684 }
1637 }'''); 1685 }''');
1638 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1686 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1639 verify([source]); 1687 verify([source]);
1640 } 1688 }
1641 1689
1642 void test_duplicateDefinition_locals_inMethodBlock() { 1690 test_duplicateDefinition_locals_inMethodBlock() async {
1643 Source source = addSource(r''' 1691 Source source = addSource(r'''
1644 class A { 1692 class A {
1645 m() { 1693 m() {
1646 int a; 1694 int a;
1647 int a; 1695 int a;
1648 } 1696 }
1649 }'''); 1697 }''');
1650 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1698 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1651 verify([source]); 1699 verify([source]);
1652 } 1700 }
1653 1701
1654 void test_duplicateDefinition_parameters_inConstructor() { 1702 test_duplicateDefinition_parameters_inConstructor() async {
1655 Source source = addSource(r''' 1703 Source source = addSource(r'''
1656 class A { 1704 class A {
1657 int a; 1705 int a;
1658 A(int a, this.a); 1706 A(int a, this.a);
1659 }'''); 1707 }''');
1660 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1708 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1661 verify([source]); 1709 verify([source]);
1662 } 1710 }
1663 1711
1664 void test_duplicateDefinition_parameters_inFunctionTypeAlias() { 1712 test_duplicateDefinition_parameters_inFunctionTypeAlias() async {
1665 Source source = addSource(r''' 1713 Source source = addSource(r'''
1666 typedef F(int a, double a); 1714 typedef F(int a, double a);
1667 '''); 1715 ''');
1668 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1716 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1669 verify([source]); 1717 verify([source]);
1670 } 1718 }
1671 1719
1672 void test_duplicateDefinition_parameters_inLocalFunction() { 1720 test_duplicateDefinition_parameters_inLocalFunction() async {
1673 Source source = addSource(r''' 1721 Source source = addSource(r'''
1674 main() { 1722 main() {
1675 f(int a, double a) { 1723 f(int a, double a) {
1676 }; 1724 };
1677 }'''); 1725 }''');
1678 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1726 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1679 verify([source]); 1727 verify([source]);
1680 } 1728 }
1681 1729
1682 void test_duplicateDefinition_parameters_inMethod() { 1730 test_duplicateDefinition_parameters_inMethod() async {
1683 Source source = addSource(r''' 1731 Source source = addSource(r'''
1684 class A { 1732 class A {
1685 m(int a, double a) { 1733 m(int a, double a) {
1686 } 1734 }
1687 }'''); 1735 }''');
1688 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1736 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1689 verify([source]); 1737 verify([source]);
1690 } 1738 }
1691 1739
1692 void test_duplicateDefinition_parameters_inTopLevelFunction() { 1740 test_duplicateDefinition_parameters_inTopLevelFunction() async {
1693 Source source = addSource(r''' 1741 Source source = addSource(r'''
1694 f(int a, double a) { 1742 f(int a, double a) {
1695 }'''); 1743 }''');
1696 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1744 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1697 verify([source]); 1745 verify([source]);
1698 } 1746 }
1699 1747
1700 void test_duplicateDefinition_typeParameters() { 1748 test_duplicateDefinition_typeParameters() async {
1701 Source source = addSource(r''' 1749 Source source = addSource(r'''
1702 class A<T, T> { 1750 class A<T, T> {
1703 }'''); 1751 }''');
1704 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1752 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1705 verify([source]); 1753 verify([source]);
1706 } 1754 }
1707 1755
1708 void test_duplicateDefinitionInheritance_instanceGetter_staticGetter() { 1756 test_duplicateDefinitionInheritance_instanceGetter_staticGetter() async {
1709 Source source = addSource(r''' 1757 Source source = addSource(r'''
1710 class A { 1758 class A {
1711 int get x => 0; 1759 int get x => 0;
1712 } 1760 }
1713 class B extends A { 1761 class B extends A {
1714 static int get x => 0; 1762 static int get x => 0;
1715 }'''); 1763 }''');
1716 assertErrors( 1764 await assertErrors(
1717 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); 1765 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
1718 verify([source]); 1766 verify([source]);
1719 } 1767 }
1720 1768
1721 void 1769 test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() asyn c {
1722 test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() {
1723 Source source = addSource(r''' 1770 Source source = addSource(r'''
1724 abstract class A { 1771 abstract class A {
1725 int get x; 1772 int get x;
1726 } 1773 }
1727 class B extends A { 1774 class B extends A {
1728 static int get x => 0; 1775 static int get x => 0;
1729 }'''); 1776 }''');
1730 assertErrors( 1777 await assertErrors(
1731 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); 1778 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
1732 verify([source]); 1779 verify([source]);
1733 } 1780 }
1734 1781
1735 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() { 1782 test_duplicateDefinitionInheritance_instanceMethod_staticMethod() async {
1736 Source source = addSource(r''' 1783 Source source = addSource(r'''
1737 class A { 1784 class A {
1738 x() {} 1785 x() {}
1739 } 1786 }
1740 class B extends A { 1787 class B extends A {
1741 static x() {} 1788 static x() {}
1742 }'''); 1789 }''');
1743 assertErrors( 1790 await assertErrors(
1744 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); 1791 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
1745 verify([source]); 1792 verify([source]);
1746 } 1793 }
1747 1794
1748 void 1795 test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() asyn c {
1749 test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() {
1750 Source source = addSource(r''' 1796 Source source = addSource(r'''
1751 abstract class A { 1797 abstract class A {
1752 x(); 1798 x();
1753 } 1799 }
1754 abstract class B extends A { 1800 abstract class B extends A {
1755 static x() {} 1801 static x() {}
1756 }'''); 1802 }''');
1757 assertErrors( 1803 await assertErrors(
1758 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); 1804 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
1759 verify([source]); 1805 verify([source]);
1760 } 1806 }
1761 1807
1762 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() { 1808 test_duplicateDefinitionInheritance_instanceSetter_staticSetter() async {
1763 Source source = addSource(r''' 1809 Source source = addSource(r'''
1764 class A { 1810 class A {
1765 set x(value) {} 1811 set x(value) {}
1766 } 1812 }
1767 class B extends A { 1813 class B extends A {
1768 static set x(value) {} 1814 static set x(value) {}
1769 }'''); 1815 }''');
1770 assertErrors( 1816 await assertErrors(
1771 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); 1817 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
1772 verify([source]); 1818 verify([source]);
1773 } 1819 }
1774 1820
1775 void 1821 test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() asyn c {
1776 test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() {
1777 Source source = addSource(r''' 1822 Source source = addSource(r'''
1778 abstract class A { 1823 abstract class A {
1779 set x(value); 1824 set x(value);
1780 } 1825 }
1781 class B extends A { 1826 class B extends A {
1782 static set x(value) {} 1827 static set x(value) {}
1783 }'''); 1828 }''');
1784 assertErrors( 1829 await assertErrors(
1785 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); 1830 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
1786 verify([source]); 1831 verify([source]);
1787 } 1832 }
1788 1833
1789 void test_duplicateNamedArgument() { 1834 test_duplicateNamedArgument() async {
1790 Source source = addSource(r''' 1835 Source source = addSource(r'''
1791 f({a, b}) {} 1836 f({a, b}) {}
1792 main() { 1837 main() {
1793 f(a: 1, a: 2); 1838 f(a: 1, a: 2);
1794 }'''); 1839 }''');
1795 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]); 1840 await assertErrors(
1841 source, [CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
1796 verify([source]); 1842 verify([source]);
1797 } 1843 }
1798 1844
1799 void test_duplicatePart_sameSource() { 1845 test_duplicatePart_sameSource() async {
1800 addNamedSource('/part.dart', 'part of lib;'); 1846 addNamedSource('/part.dart', 'part of lib;');
1801 Source source = addSource(r''' 1847 Source source = addSource(r'''
1802 library lib; 1848 library lib;
1803 part 'part.dart'; 1849 part 'part.dart';
1804 part 'foo/../part.dart'; 1850 part 'foo/../part.dart';
1805 '''); 1851 ''');
1806 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_PART]); 1852 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_PART]);
1807 verify([source]); 1853 verify([source]);
1808 } 1854 }
1809 1855
1810 void test_duplicatePart_sameUri() { 1856 test_duplicatePart_sameUri() async {
1811 addNamedSource('/part.dart', 'part of lib;'); 1857 addNamedSource('/part.dart', 'part of lib;');
1812 Source source = addSource(r''' 1858 Source source = addSource(r'''
1813 library lib; 1859 library lib;
1814 part 'part.dart'; 1860 part 'part.dart';
1815 part 'part.dart'; 1861 part 'part.dart';
1816 '''); 1862 ''');
1817 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_PART]); 1863 await assertErrors(source, [CompileTimeErrorCode.DUPLICATE_PART]);
1818 verify([source]); 1864 verify([source]);
1819 } 1865 }
1820 1866
1821 void test_exportInternalLibrary() { 1867 test_exportInternalLibrary() async {
1822 Source source = addSource("export 'dart:_interceptors';"); 1868 Source source = addSource("export 'dart:_interceptors';");
1823 assertErrors(source, [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]); 1869 await assertErrors(source, [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]);
1824 verify([source]); 1870 verify([source]);
1825 } 1871 }
1826 1872
1827 void test_exportOfNonLibrary() { 1873 test_exportOfNonLibrary() async {
1828 Source source = addSource(r''' 1874 Source source = addSource(r'''
1829 library L; 1875 library L;
1830 export 'lib1.dart';'''); 1876 export 'lib1.dart';''');
1831 addNamedSource("/lib1.dart", "part of lib;"); 1877 addNamedSource("/lib1.dart", "part of lib;");
1832 assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); 1878 await assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
1833 verify([source]); 1879 verify([source]);
1834 } 1880 }
1835 1881
1836 void test_extendsDeferredClass() { 1882 test_extendsDeferredClass() async {
1837 resolveWithErrors(<String>[ 1883 await resolveWithErrors(<String>[
1838 r''' 1884 r'''
1839 library lib1; 1885 library lib1;
1840 class A {}''', 1886 class A {}''',
1841 r''' 1887 r'''
1842 library root; 1888 library root;
1843 import 'lib1.dart' deferred as a; 1889 import 'lib1.dart' deferred as a;
1844 class B extends a.A {}''' 1890 class B extends a.A {}'''
1845 ], <ErrorCode>[ 1891 ], <ErrorCode>[
1846 CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS 1892 CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS
1847 ]); 1893 ]);
1848 } 1894 }
1849 1895
1850 void test_extendsDeferredClass_classTypeAlias() { 1896 test_extendsDeferredClass_classTypeAlias() async {
1851 resolveWithErrors(<String>[ 1897 await resolveWithErrors(<String>[
1852 r''' 1898 r'''
1853 library lib1; 1899 library lib1;
1854 class A {}''', 1900 class A {}''',
1855 r''' 1901 r'''
1856 library root; 1902 library root;
1857 import 'lib1.dart' deferred as a; 1903 import 'lib1.dart' deferred as a;
1858 class M {} 1904 class M {}
1859 class C = a.A with M;''' 1905 class C = a.A with M;'''
1860 ], <ErrorCode>[ 1906 ], <ErrorCode>[
1861 CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS 1907 CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS
1862 ]); 1908 ]);
1863 } 1909 }
1864 1910
1865 void test_extendsDisallowedClass_class_bool() { 1911 test_extendsDisallowedClass_class_bool() async {
1866 Source source = addSource("class A extends bool {}"); 1912 Source source = addSource("class A extends bool {}");
1867 assertErrors(source, [ 1913 await assertErrors(source, [
1868 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, 1914 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
1869 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT 1915 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
1870 ]); 1916 ]);
1871 verify([source]); 1917 verify([source]);
1872 } 1918 }
1873 1919
1874 void test_extendsDisallowedClass_class_double() { 1920 test_extendsDisallowedClass_class_double() async {
1875 Source source = addSource("class A extends double {}"); 1921 Source source = addSource("class A extends double {}");
1876 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 1922 await assertErrors(
1923 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1877 verify([source]); 1924 verify([source]);
1878 } 1925 }
1879 1926
1880 void test_extendsDisallowedClass_class_int() { 1927 test_extendsDisallowedClass_class_int() async {
1881 Source source = addSource("class A extends int {}"); 1928 Source source = addSource("class A extends int {}");
1882 assertErrors(source, [ 1929 await assertErrors(source, [
1883 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, 1930 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
1884 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT 1931 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
1885 ]); 1932 ]);
1886 verify([source]); 1933 verify([source]);
1887 } 1934 }
1888 1935
1889 void test_extendsDisallowedClass_class_Null() { 1936 test_extendsDisallowedClass_class_Null() async {
1890 Source source = addSource("class A extends Null {}"); 1937 Source source = addSource("class A extends Null {}");
1891 assertErrors(source, [ 1938 await assertErrors(source, [
1892 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, 1939 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
1893 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT 1940 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
1894 ]); 1941 ]);
1895 verify([source]); 1942 verify([source]);
1896 } 1943 }
1897 1944
1898 void test_extendsDisallowedClass_class_num() { 1945 test_extendsDisallowedClass_class_num() async {
1899 Source source = addSource("class A extends num {}"); 1946 Source source = addSource("class A extends num {}");
1900 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 1947 await assertErrors(
1948 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1901 verify([source]); 1949 verify([source]);
1902 } 1950 }
1903 1951
1904 void test_extendsDisallowedClass_class_String() { 1952 test_extendsDisallowedClass_class_String() async {
1905 Source source = addSource("class A extends String {}"); 1953 Source source = addSource("class A extends String {}");
1906 assertErrors(source, [ 1954 await assertErrors(source, [
1907 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, 1955 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
1908 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT 1956 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
1909 ]); 1957 ]);
1910 verify([source]); 1958 verify([source]);
1911 } 1959 }
1912 1960
1913 void test_extendsDisallowedClass_classTypeAlias_bool() { 1961 test_extendsDisallowedClass_classTypeAlias_bool() async {
1914 Source source = addSource(r''' 1962 Source source = addSource(r'''
1915 class M {} 1963 class M {}
1916 class C = bool with M;'''); 1964 class C = bool with M;''');
1917 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 1965 await assertErrors(
1966 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1918 verify([source]); 1967 verify([source]);
1919 } 1968 }
1920 1969
1921 void test_extendsDisallowedClass_classTypeAlias_double() { 1970 test_extendsDisallowedClass_classTypeAlias_double() async {
1922 Source source = addSource(r''' 1971 Source source = addSource(r'''
1923 class M {} 1972 class M {}
1924 class C = double with M;'''); 1973 class C = double with M;''');
1925 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 1974 await assertErrors(
1975 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1926 verify([source]); 1976 verify([source]);
1927 } 1977 }
1928 1978
1929 void test_extendsDisallowedClass_classTypeAlias_int() { 1979 test_extendsDisallowedClass_classTypeAlias_int() async {
1930 Source source = addSource(r''' 1980 Source source = addSource(r'''
1931 class M {} 1981 class M {}
1932 class C = int with M;'''); 1982 class C = int with M;''');
1933 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 1983 await assertErrors(
1984 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1934 verify([source]); 1985 verify([source]);
1935 } 1986 }
1936 1987
1937 void test_extendsDisallowedClass_classTypeAlias_Null() { 1988 test_extendsDisallowedClass_classTypeAlias_Null() async {
1938 Source source = addSource(r''' 1989 Source source = addSource(r'''
1939 class M {} 1990 class M {}
1940 class C = Null with M;'''); 1991 class C = Null with M;''');
1941 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 1992 await assertErrors(
1993 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1942 verify([source]); 1994 verify([source]);
1943 } 1995 }
1944 1996
1945 void test_extendsDisallowedClass_classTypeAlias_num() { 1997 test_extendsDisallowedClass_classTypeAlias_num() async {
1946 Source source = addSource(r''' 1998 Source source = addSource(r'''
1947 class M {} 1999 class M {}
1948 class C = num with M;'''); 2000 class C = num with M;''');
1949 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 2001 await assertErrors(
2002 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1950 verify([source]); 2003 verify([source]);
1951 } 2004 }
1952 2005
1953 void test_extendsDisallowedClass_classTypeAlias_String() { 2006 test_extendsDisallowedClass_classTypeAlias_String() async {
1954 Source source = addSource(r''' 2007 Source source = addSource(r'''
1955 class M {} 2008 class M {}
1956 class C = String with M;'''); 2009 class C = String with M;''');
1957 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 2010 await assertErrors(
2011 source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1958 verify([source]); 2012 verify([source]);
1959 } 2013 }
1960 2014
1961 void test_extendsEnum() { 2015 test_extendsEnum() async {
1962 Source source = addSource(r''' 2016 Source source = addSource(r'''
1963 enum E { ONE } 2017 enum E { ONE }
1964 class A extends E {}'''); 2018 class A extends E {}''');
1965 assertErrors(source, [CompileTimeErrorCode.EXTENDS_ENUM]); 2019 await assertErrors(source, [CompileTimeErrorCode.EXTENDS_ENUM]);
1966 verify([source]); 2020 verify([source]);
1967 } 2021 }
1968 2022
1969 void test_extendsNonClass_class() { 2023 test_extendsNonClass_class() async {
1970 Source source = addSource(r''' 2024 Source source = addSource(r'''
1971 int A; 2025 int A;
1972 class B extends A {}'''); 2026 class B extends A {}''');
1973 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); 2027 await assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]);
1974 verify([source]); 2028 verify([source]);
1975 } 2029 }
1976 2030
1977 void test_extendsNonClass_dynamic() { 2031 test_extendsNonClass_dynamic() async {
1978 Source source = addSource("class B extends dynamic {}"); 2032 Source source = addSource("class B extends dynamic {}");
1979 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); 2033 await assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]);
1980 verify([source]); 2034 verify([source]);
1981 } 2035 }
1982 2036
1983 void test_extraPositionalArguments_const() { 2037 test_extraPositionalArguments_const() async {
1984 Source source = addSource(r''' 2038 Source source = addSource(r'''
1985 class A { 2039 class A {
1986 const A(); 2040 const A();
1987 } 2041 }
1988 main() { 2042 main() {
1989 const A(0); 2043 const A(0);
1990 }'''); 2044 }''');
1991 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); 2045 await assertErrors(
2046 source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]);
1992 verify([source]); 2047 verify([source]);
1993 } 2048 }
1994 2049
1995 void test_extraPositionalArguments_const_super() { 2050 test_extraPositionalArguments_const_super() async {
1996 Source source = addSource(r''' 2051 Source source = addSource(r'''
1997 class A { 2052 class A {
1998 const A(); 2053 const A();
1999 } 2054 }
2000 class B extends A { 2055 class B extends A {
2001 const B() : super(0); 2056 const B() : super(0);
2002 }'''); 2057 }''');
2003 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); 2058 await assertErrors(
2059 source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]);
2004 verify([source]); 2060 verify([source]);
2005 } 2061 }
2006 2062
2007 void test_fieldFormalParameter_assignedInInitializer() { 2063 test_fieldFormalParameter_assignedInInitializer() async {
2008 Source source = addSource(r''' 2064 Source source = addSource(r'''
2009 class A { 2065 class A {
2010 int x; 2066 int x;
2011 A(this.x) : x = 3 {} 2067 A(this.x) : x = 3 {}
2012 }'''); 2068 }''');
2013 assertErrors(source, 2069 await assertErrors(source,
2014 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]); 2070 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
2015 verify([source]); 2071 verify([source]);
2016 } 2072 }
2017 2073
2018 void test_fieldInitializedByMultipleInitializers() { 2074 test_fieldInitializedByMultipleInitializers() async {
2019 Source source = addSource(r''' 2075 Source source = addSource(r'''
2020 class A { 2076 class A {
2021 int x; 2077 int x;
2022 A() : x = 0, x = 1 {} 2078 A() : x = 0, x = 1 {}
2023 }'''); 2079 }''');
2024 assertErrors(source, 2080 await assertErrors(source,
2025 [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); 2081 [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
2026 verify([source]); 2082 verify([source]);
2027 } 2083 }
2028 2084
2029 void test_fieldInitializedByMultipleInitializers_multipleInits() { 2085 test_fieldInitializedByMultipleInitializers_multipleInits() async {
2030 Source source = addSource(r''' 2086 Source source = addSource(r'''
2031 class A { 2087 class A {
2032 int x; 2088 int x;
2033 A() : x = 0, x = 1, x = 2 {} 2089 A() : x = 0, x = 1, x = 2 {}
2034 }'''); 2090 }''');
2035 assertErrors(source, [ 2091 await assertErrors(source, [
2036 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, 2092 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS,
2037 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS 2093 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
2038 ]); 2094 ]);
2039 verify([source]); 2095 verify([source]);
2040 } 2096 }
2041 2097
2042 void test_fieldInitializedByMultipleInitializers_multipleNames() { 2098 test_fieldInitializedByMultipleInitializers_multipleNames() async {
2043 Source source = addSource(r''' 2099 Source source = addSource(r'''
2044 class A { 2100 class A {
2045 int x; 2101 int x;
2046 int y; 2102 int y;
2047 A() : x = 0, x = 1, y = 0, y = 1 {} 2103 A() : x = 0, x = 1, y = 0, y = 1 {}
2048 }'''); 2104 }''');
2049 assertErrors(source, [ 2105 await assertErrors(source, [
2050 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, 2106 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS,
2051 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS 2107 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
2052 ]); 2108 ]);
2053 verify([source]); 2109 verify([source]);
2054 } 2110 }
2055 2111
2056 void test_fieldInitializedInParameterAndInitializer() { 2112 test_fieldInitializedInParameterAndInitializer() async {
2057 Source source = addSource(r''' 2113 Source source = addSource(r'''
2058 class A { 2114 class A {
2059 int x; 2115 int x;
2060 A(this.x) : x = 1 {} 2116 A(this.x) : x = 1 {}
2061 }'''); 2117 }''');
2062 assertErrors(source, 2118 await assertErrors(source,
2063 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]); 2119 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
2064 verify([source]); 2120 verify([source]);
2065 } 2121 }
2066 2122
2067 void test_fieldInitializerFactoryConstructor() { 2123 test_fieldInitializerFactoryConstructor() async {
2068 Source source = addSource(r''' 2124 Source source = addSource(r'''
2069 class A { 2125 class A {
2070 int x; 2126 int x;
2071 factory A(this.x) => null; 2127 factory A(this.x) => null;
2072 }'''); 2128 }''');
2073 assertErrors( 2129 await assertErrors(
2074 source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR]); 2130 source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR]);
2075 verify([source]); 2131 verify([source]);
2076 } 2132 }
2077 2133
2078 void test_fieldInitializerOutsideConstructor() { 2134 test_fieldInitializerOutsideConstructor() async {
2079 // TODO(brianwilkerson) Fix the duplicate error messages. 2135 // TODO(brianwilkerson) Fix the duplicate error messages.
2080 Source source = addSource(r''' 2136 Source source = addSource(r'''
2081 class A { 2137 class A {
2082 int x; 2138 int x;
2083 m(this.x) {} 2139 m(this.x) {}
2084 }'''); 2140 }''');
2085 assertErrors(source, [ 2141 await assertErrors(source, [
2086 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, 2142 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR,
2087 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR 2143 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
2088 ]); 2144 ]);
2089 verify([source]); 2145 verify([source]);
2090 } 2146 }
2091 2147
2092 void test_fieldInitializerOutsideConstructor_defaultParameter() { 2148 test_fieldInitializerOutsideConstructor_defaultParameter() async {
2093 Source source = addSource(r''' 2149 Source source = addSource(r'''
2094 class A { 2150 class A {
2095 int x; 2151 int x;
2096 m([this.x]) {} 2152 m([this.x]) {}
2097 }'''); 2153 }''');
2098 assertErrors( 2154 await assertErrors(
2099 source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); 2155 source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
2100 verify([source]); 2156 verify([source]);
2101 } 2157 }
2102 2158
2103 void test_fieldInitializerOutsideConstructor_inFunctionTypeParameter() { 2159 test_fieldInitializerOutsideConstructor_inFunctionTypeParameter() async {
2104 Source source = addSource(r''' 2160 Source source = addSource(r'''
2105 class A { 2161 class A {
2106 int x; 2162 int x;
2107 A(int p(this.x)); 2163 A(int p(this.x));
2108 }'''); 2164 }''');
2109 assertErrors( 2165 await assertErrors(
2110 source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); 2166 source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
2111 verify([source]); 2167 verify([source]);
2112 } 2168 }
2113 2169
2114 void test_fieldInitializerRedirectingConstructor_afterRedirection() { 2170 test_fieldInitializerRedirectingConstructor_afterRedirection() async {
2115 Source source = addSource(r''' 2171 Source source = addSource(r'''
2116 class A { 2172 class A {
2117 int x; 2173 int x;
2118 A.named() {} 2174 A.named() {}
2119 A() : this.named(), x = 42; 2175 A() : this.named(), x = 42;
2120 }'''); 2176 }''');
2121 assertErrors(source, 2177 await assertErrors(source,
2122 [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]); 2178 [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]);
2123 verify([source]); 2179 verify([source]);
2124 } 2180 }
2125 2181
2126 void test_fieldInitializerRedirectingConstructor_beforeRedirection() { 2182 test_fieldInitializerRedirectingConstructor_beforeRedirection() async {
2127 Source source = addSource(r''' 2183 Source source = addSource(r'''
2128 class A { 2184 class A {
2129 int x; 2185 int x;
2130 A.named() {} 2186 A.named() {}
2131 A() : x = 42, this.named(); 2187 A() : x = 42, this.named();
2132 }'''); 2188 }''');
2133 assertErrors(source, 2189 await assertErrors(source,
2134 [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]); 2190 [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]);
2135 verify([source]); 2191 verify([source]);
2136 } 2192 }
2137 2193
2138 void test_fieldInitializingFormalRedirectingConstructor() { 2194 test_fieldInitializingFormalRedirectingConstructor() async {
2139 Source source = addSource(r''' 2195 Source source = addSource(r'''
2140 class A { 2196 class A {
2141 int x; 2197 int x;
2142 A.named() {} 2198 A.named() {}
2143 A(this.x) : this.named(); 2199 A(this.x) : this.named();
2144 }'''); 2200 }''');
2145 assertErrors(source, 2201 await assertErrors(source,
2146 [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]); 2202 [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]);
2147 verify([source]); 2203 verify([source]);
2148 } 2204 }
2149 2205
2150 void test_finalInitializedMultipleTimes_initializers() { 2206 test_finalInitializedMultipleTimes_initializers() async {
2151 Source source = addSource(r''' 2207 Source source = addSource(r'''
2152 class A { 2208 class A {
2153 final x; 2209 final x;
2154 A() : x = 0, x = 0 {} 2210 A() : x = 0, x = 0 {}
2155 }'''); 2211 }''');
2156 assertErrors(source, 2212 await assertErrors(source,
2157 [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); 2213 [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
2158 verify([source]); 2214 verify([source]);
2159 } 2215 }
2160 2216
2161 /** 2217 /**
2162 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests the 2218 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests the
2163 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided here to show 2219 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided here to show
2164 * coverage over all of the permutations of initializers in constructor declar ations. 2220 * coverage over all of the permutations of initializers in constructor declar ations.
2165 * 2221 *
2166 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of 2222 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of
2167 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code 2223 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code
2168 */ 2224 */
2169 void test_finalInitializedMultipleTimes_initializingFormal_initializer() { 2225 test_finalInitializedMultipleTimes_initializingFormal_initializer() async {
2170 Source source = addSource(r''' 2226 Source source = addSource(r'''
2171 class A { 2227 class A {
2172 final x; 2228 final x;
2173 A(this.x) : x = 0 {} 2229 A(this.x) : x = 0 {}
2174 }'''); 2230 }''');
2175 assertErrors(source, 2231 await assertErrors(source,
2176 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]); 2232 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
2177 verify([source]); 2233 verify([source]);
2178 } 2234 }
2179 2235
2180 void test_finalInitializedMultipleTimes_initializingFormals() { 2236 test_finalInitializedMultipleTimes_initializingFormals() async {
2181 Source source = addSource(r''' 2237 Source source = addSource(r'''
2182 class A { 2238 class A {
2183 final x; 2239 final x;
2184 A(this.x, this.x) {} 2240 A(this.x, this.x) {}
2185 }'''); 2241 }''');
2186 // TODO(brianwilkerson) There should only be one error here. 2242 // TODO(brianwilkerson) There should only be one error here.
2187 assertErrors(source, [ 2243 await assertErrors(source, [
2188 CompileTimeErrorCode.DUPLICATE_DEFINITION, 2244 CompileTimeErrorCode.DUPLICATE_DEFINITION,
2189 CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES 2245 CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES
2190 ]); 2246 ]);
2191 verify([source]); 2247 verify([source]);
2192 } 2248 }
2193 2249
2194 void test_finalNotInitialized_instanceField_const_static() { 2250 test_finalNotInitialized_instanceField_const_static() async {
2195 Source source = addSource(r''' 2251 Source source = addSource(r'''
2196 class A { 2252 class A {
2197 static const F; 2253 static const F;
2198 }'''); 2254 }''');
2199 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); 2255 await assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
2200 verify([source]); 2256 verify([source]);
2201 } 2257 }
2202 2258
2203 void test_finalNotInitialized_library_const() { 2259 test_finalNotInitialized_library_const() async {
2204 Source source = addSource("const F;"); 2260 Source source = addSource("const F;");
2205 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); 2261 await assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
2206 verify([source]); 2262 verify([source]);
2207 } 2263 }
2208 2264
2209 void test_finalNotInitialized_local_const() { 2265 test_finalNotInitialized_local_const() async {
2210 Source source = addSource(r''' 2266 Source source = addSource(r'''
2211 f() { 2267 f() {
2212 const int x; 2268 const int x;
2213 }'''); 2269 }''');
2214 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); 2270 await assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
2215 verify([source]); 2271 verify([source]);
2216 } 2272 }
2217 2273
2218 void test_fromEnvironment_bool_badArgs() { 2274 test_fromEnvironment_bool_badArgs() async {
2219 Source source = addSource(r''' 2275 Source source = addSource(r'''
2220 var b1 = const bool.fromEnvironment(1); 2276 var b1 = const bool.fromEnvironment(1);
2221 var b2 = const bool.fromEnvironment('x', defaultValue: 1);'''); 2277 var b2 = const bool.fromEnvironment('x', defaultValue: 1);''');
2222 assertErrors(source, [ 2278 await assertErrors(source, [
2223 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 2279 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
2224 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 2280 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
2225 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 2281 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
2226 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE 2282 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
2227 ]); 2283 ]);
2228 verify([source]); 2284 verify([source]);
2229 } 2285 }
2230 2286
2231 void test_fromEnvironment_bool_badDefault_whenDefined() { 2287 test_fromEnvironment_bool_badDefault_whenDefined() async {
2232 // The type of the defaultValue needs to be correct even when the default 2288 // The type of the defaultValue needs to be correct even when the default
2233 // value isn't used (because the variable is defined in the environment). 2289 // value isn't used (because the variable is defined in the environment).
2234 analysisContext2.declaredVariables.define("x", "true"); 2290 analysisContext2.declaredVariables.define("x", "true");
2235 Source source = 2291 Source source =
2236 addSource("var b = const bool.fromEnvironment('x', defaultValue: 1);"); 2292 addSource("var b = const bool.fromEnvironment('x', defaultValue: 1);");
2237 assertErrors(source, [ 2293 await assertErrors(source, [
2238 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 2294 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
2239 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE 2295 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
2240 ]); 2296 ]);
2241 verify([source]); 2297 verify([source]);
2242 } 2298 }
2243 2299
2244 void test_getterAndMethodWithSameName() { 2300 test_getterAndMethodWithSameName() async {
2245 Source source = addSource(r''' 2301 Source source = addSource(r'''
2246 class A { 2302 class A {
2247 x(y) {} 2303 x(y) {}
2248 get x => 0; 2304 get x => 0;
2249 }'''); 2305 }''');
2250 assertErrors( 2306 await assertErrors(
2251 source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]); 2307 source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]);
2252 verify([source]); 2308 verify([source]);
2253 } 2309 }
2254 2310
2255 void test_implementsDeferredClass() { 2311 test_implementsDeferredClass() async {
2256 resolveWithErrors(<String>[ 2312 await resolveWithErrors(<String>[
2257 r''' 2313 r'''
2258 library lib1; 2314 library lib1;
2259 class A {}''', 2315 class A {}''',
2260 r''' 2316 r'''
2261 library root; 2317 library root;
2262 import 'lib1.dart' deferred as a; 2318 import 'lib1.dart' deferred as a;
2263 class B implements a.A {}''' 2319 class B implements a.A {}'''
2264 ], <ErrorCode>[ 2320 ], <ErrorCode>[
2265 CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS 2321 CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS
2266 ]); 2322 ]);
2267 } 2323 }
2268 2324
2269 void test_implementsDeferredClass_classTypeAlias() { 2325 test_implementsDeferredClass_classTypeAlias() async {
2270 resolveWithErrors(<String>[ 2326 await resolveWithErrors(<String>[
2271 r''' 2327 r'''
2272 library lib1; 2328 library lib1;
2273 class A {}''', 2329 class A {}''',
2274 r''' 2330 r'''
2275 library root; 2331 library root;
2276 import 'lib1.dart' deferred as a; 2332 import 'lib1.dart' deferred as a;
2277 class B {} 2333 class B {}
2278 class M {} 2334 class M {}
2279 class C = B with M implements a.A;''' 2335 class C = B with M implements a.A;'''
2280 ], <ErrorCode>[ 2336 ], <ErrorCode>[
2281 CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS 2337 CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS
2282 ]); 2338 ]);
2283 } 2339 }
2284 2340
2285 void test_implementsDisallowedClass_class_bool() { 2341 test_implementsDisallowedClass_class_bool() async {
2286 Source source = addSource("class A implements bool {}"); 2342 Source source = addSource("class A implements bool {}");
2287 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2343 await assertErrors(
2344 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2288 verify([source]); 2345 verify([source]);
2289 } 2346 }
2290 2347
2291 void test_implementsDisallowedClass_class_double() { 2348 test_implementsDisallowedClass_class_double() async {
2292 Source source = addSource("class A implements double {}"); 2349 Source source = addSource("class A implements double {}");
2293 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2350 await assertErrors(
2351 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2294 verify([source]); 2352 verify([source]);
2295 } 2353 }
2296 2354
2297 void test_implementsDisallowedClass_class_int() { 2355 test_implementsDisallowedClass_class_int() async {
2298 Source source = addSource("class A implements int {}"); 2356 Source source = addSource("class A implements int {}");
2299 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2357 await assertErrors(
2358 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2300 verify([source]); 2359 verify([source]);
2301 } 2360 }
2302 2361
2303 void test_implementsDisallowedClass_class_Null() { 2362 test_implementsDisallowedClass_class_Null() async {
2304 Source source = addSource("class A implements Null {}"); 2363 Source source = addSource("class A implements Null {}");
2305 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2364 await assertErrors(
2365 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2306 verify([source]); 2366 verify([source]);
2307 } 2367 }
2308 2368
2309 void test_implementsDisallowedClass_class_num() { 2369 test_implementsDisallowedClass_class_num() async {
2310 Source source = addSource("class A implements num {}"); 2370 Source source = addSource("class A implements num {}");
2311 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2371 await assertErrors(
2372 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2312 verify([source]); 2373 verify([source]);
2313 } 2374 }
2314 2375
2315 void test_implementsDisallowedClass_class_String() { 2376 test_implementsDisallowedClass_class_String() async {
2316 Source source = addSource("class A implements String {}"); 2377 Source source = addSource("class A implements String {}");
2317 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2378 await assertErrors(
2379 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2318 verify([source]); 2380 verify([source]);
2319 } 2381 }
2320 2382
2321 void test_implementsDisallowedClass_class_String_num() { 2383 test_implementsDisallowedClass_class_String_num() async {
2322 Source source = addSource("class A implements String, num {}"); 2384 Source source = addSource("class A implements String, num {}");
2323 assertErrors(source, [ 2385 await assertErrors(source, [
2324 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS, 2386 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS,
2325 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS 2387 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS
2326 ]); 2388 ]);
2327 verify([source]); 2389 verify([source]);
2328 } 2390 }
2329 2391
2330 void test_implementsDisallowedClass_classTypeAlias_bool() { 2392 test_implementsDisallowedClass_classTypeAlias_bool() async {
2331 Source source = addSource(r''' 2393 Source source = addSource(r'''
2332 class A {} 2394 class A {}
2333 class M {} 2395 class M {}
2334 class C = A with M implements bool;'''); 2396 class C = A with M implements bool;''');
2335 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2397 await assertErrors(
2398 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2336 verify([source]); 2399 verify([source]);
2337 } 2400 }
2338 2401
2339 void test_implementsDisallowedClass_classTypeAlias_double() { 2402 test_implementsDisallowedClass_classTypeAlias_double() async {
2340 Source source = addSource(r''' 2403 Source source = addSource(r'''
2341 class A {} 2404 class A {}
2342 class M {} 2405 class M {}
2343 class C = A with M implements double;'''); 2406 class C = A with M implements double;''');
2344 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2407 await assertErrors(
2408 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2345 verify([source]); 2409 verify([source]);
2346 } 2410 }
2347 2411
2348 void test_implementsDisallowedClass_classTypeAlias_int() { 2412 test_implementsDisallowedClass_classTypeAlias_int() async {
2349 Source source = addSource(r''' 2413 Source source = addSource(r'''
2350 class A {} 2414 class A {}
2351 class M {} 2415 class M {}
2352 class C = A with M implements int;'''); 2416 class C = A with M implements int;''');
2353 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2417 await assertErrors(
2418 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2354 verify([source]); 2419 verify([source]);
2355 } 2420 }
2356 2421
2357 void test_implementsDisallowedClass_classTypeAlias_Null() { 2422 test_implementsDisallowedClass_classTypeAlias_Null() async {
2358 Source source = addSource(r''' 2423 Source source = addSource(r'''
2359 class A {} 2424 class A {}
2360 class M {} 2425 class M {}
2361 class C = A with M implements Null;'''); 2426 class C = A with M implements Null;''');
2362 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2427 await assertErrors(
2428 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2363 verify([source]); 2429 verify([source]);
2364 } 2430 }
2365 2431
2366 void test_implementsDisallowedClass_classTypeAlias_num() { 2432 test_implementsDisallowedClass_classTypeAlias_num() async {
2367 Source source = addSource(r''' 2433 Source source = addSource(r'''
2368 class A {} 2434 class A {}
2369 class M {} 2435 class M {}
2370 class C = A with M implements num;'''); 2436 class C = A with M implements num;''');
2371 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2437 await assertErrors(
2438 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2372 verify([source]); 2439 verify([source]);
2373 } 2440 }
2374 2441
2375 void test_implementsDisallowedClass_classTypeAlias_String() { 2442 test_implementsDisallowedClass_classTypeAlias_String() async {
2376 Source source = addSource(r''' 2443 Source source = addSource(r'''
2377 class A {} 2444 class A {}
2378 class M {} 2445 class M {}
2379 class C = A with M implements String;'''); 2446 class C = A with M implements String;''');
2380 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2447 await assertErrors(
2448 source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2381 verify([source]); 2449 verify([source]);
2382 } 2450 }
2383 2451
2384 void test_implementsDisallowedClass_classTypeAlias_String_num() { 2452 test_implementsDisallowedClass_classTypeAlias_String_num() async {
2385 Source source = addSource(r''' 2453 Source source = addSource(r'''
2386 class A {} 2454 class A {}
2387 class M {} 2455 class M {}
2388 class C = A with M implements String, num;'''); 2456 class C = A with M implements String, num;''');
2389 assertErrors(source, [ 2457 await assertErrors(source, [
2390 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS, 2458 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS,
2391 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS 2459 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS
2392 ]); 2460 ]);
2393 verify([source]); 2461 verify([source]);
2394 } 2462 }
2395 2463
2396 void test_implementsDynamic() { 2464 test_implementsDynamic() async {
2397 Source source = addSource("class A implements dynamic {}"); 2465 Source source = addSource("class A implements dynamic {}");
2398 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]); 2466 await assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]);
2399 verify([source]); 2467 verify([source]);
2400 } 2468 }
2401 2469
2402 void test_implementsEnum() { 2470 test_implementsEnum() async {
2403 Source source = addSource(r''' 2471 Source source = addSource(r'''
2404 enum E { ONE } 2472 enum E { ONE }
2405 class A implements E {}'''); 2473 class A implements E {}''');
2406 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_ENUM]); 2474 await assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_ENUM]);
2407 verify([source]); 2475 verify([source]);
2408 } 2476 }
2409 2477
2410 void test_implementsNonClass_class() { 2478 test_implementsNonClass_class() async {
2411 Source source = addSource(r''' 2479 Source source = addSource(r'''
2412 int A; 2480 int A;
2413 class B implements A {}'''); 2481 class B implements A {}''');
2414 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); 2482 await assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
2415 verify([source]); 2483 verify([source]);
2416 } 2484 }
2417 2485
2418 void test_implementsNonClass_typeAlias() { 2486 test_implementsNonClass_typeAlias() async {
2419 Source source = addSource(r''' 2487 Source source = addSource(r'''
2420 class A {} 2488 class A {}
2421 class M {} 2489 class M {}
2422 int B; 2490 int B;
2423 class C = A with M implements B;'''); 2491 class C = A with M implements B;''');
2424 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); 2492 await assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
2425 verify([source]); 2493 verify([source]);
2426 } 2494 }
2427 2495
2428 void test_implementsRepeated() { 2496 test_implementsRepeated() async {
2429 Source source = addSource(r''' 2497 Source source = addSource(r'''
2430 class A {} 2498 class A {}
2431 class B implements A, A {}'''); 2499 class B implements A, A {}''');
2432 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_REPEATED]); 2500 await assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
2433 verify([source]); 2501 verify([source]);
2434 } 2502 }
2435 2503
2436 void test_implementsRepeated_3times() { 2504 test_implementsRepeated_3times() async {
2437 Source source = addSource(r''' 2505 Source source = addSource(r'''
2438 class A {} class C{} 2506 class A {} class C{}
2439 class B implements A, A, A, A {}'''); 2507 class B implements A, A, A, A {}''');
2440 assertErrors(source, [ 2508 await assertErrors(source, [
2441 CompileTimeErrorCode.IMPLEMENTS_REPEATED, 2509 CompileTimeErrorCode.IMPLEMENTS_REPEATED,
2442 CompileTimeErrorCode.IMPLEMENTS_REPEATED, 2510 CompileTimeErrorCode.IMPLEMENTS_REPEATED,
2443 CompileTimeErrorCode.IMPLEMENTS_REPEATED 2511 CompileTimeErrorCode.IMPLEMENTS_REPEATED
2444 ]); 2512 ]);
2445 verify([source]); 2513 verify([source]);
2446 } 2514 }
2447 2515
2448 void test_implementsSuperClass() { 2516 test_implementsSuperClass() async {
2449 Source source = addSource(r''' 2517 Source source = addSource(r'''
2450 class A {} 2518 class A {}
2451 class B extends A implements A {}'''); 2519 class B extends A implements A {}''');
2452 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); 2520 await assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
2453 verify([source]); 2521 verify([source]);
2454 } 2522 }
2455 2523
2456 void test_implementsSuperClass_Object() { 2524 test_implementsSuperClass_Object() async {
2457 Source source = addSource("class A implements Object {}"); 2525 Source source = addSource("class A implements Object {}");
2458 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); 2526 await assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
2459 verify([source]); 2527 verify([source]);
2460 } 2528 }
2461 2529
2462 void test_implicitThisReferenceInInitializer_field() { 2530 test_implicitThisReferenceInInitializer_field() async {
2463 Source source = addSource(r''' 2531 Source source = addSource(r'''
2464 class A { 2532 class A {
2465 var v; 2533 var v;
2466 A() : v = f; 2534 A() : v = f;
2467 var f; 2535 var f;
2468 }'''); 2536 }''');
2469 assertErrors( 2537 await assertErrors(
2470 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 2538 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
2471 verify([source]); 2539 verify([source]);
2472 } 2540 }
2473 2541
2474 void test_implicitThisReferenceInInitializer_field2() { 2542 test_implicitThisReferenceInInitializer_field2() async {
2475 Source source = addSource(r''' 2543 Source source = addSource(r'''
2476 class A { 2544 class A {
2477 final x = 0; 2545 final x = 0;
2478 final y = x; 2546 final y = x;
2479 }'''); 2547 }''');
2480 assertErrors( 2548 await assertErrors(
2481 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 2549 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
2482 verify([source]); 2550 verify([source]);
2483 } 2551 }
2484 2552
2485 void test_implicitThisReferenceInInitializer_invocation() { 2553 test_implicitThisReferenceInInitializer_invocation() async {
2486 Source source = addSource(r''' 2554 Source source = addSource(r'''
2487 class A { 2555 class A {
2488 var v; 2556 var v;
2489 A() : v = f(); 2557 A() : v = f();
2490 f() {} 2558 f() {}
2491 }'''); 2559 }''');
2492 assertErrors( 2560 await assertErrors(
2493 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 2561 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
2494 verify([source]); 2562 verify([source]);
2495 } 2563 }
2496 2564
2497 void test_implicitThisReferenceInInitializer_invocationInStatic() { 2565 test_implicitThisReferenceInInitializer_invocationInStatic() async {
2498 Source source = addSource(r''' 2566 Source source = addSource(r'''
2499 class A { 2567 class A {
2500 static var F = m(); 2568 static var F = m();
2501 m() {} 2569 m() {}
2502 }'''); 2570 }''');
2503 assertErrors( 2571 await assertErrors(
2504 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 2572 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
2505 verify([source]); 2573 verify([source]);
2506 } 2574 }
2507 2575
2508 void 2576 test_implicitThisReferenceInInitializer_redirectingConstructorInvocation() asy nc {
2509 test_implicitThisReferenceInInitializer_redirectingConstructorInvocation() {
2510 Source source = addSource(r''' 2577 Source source = addSource(r'''
2511 class A { 2578 class A {
2512 A(p) {} 2579 A(p) {}
2513 A.named() : this(f); 2580 A.named() : this(f);
2514 var f; 2581 var f;
2515 }'''); 2582 }''');
2516 assertErrors( 2583 await assertErrors(
2517 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 2584 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
2518 verify([source]); 2585 verify([source]);
2519 } 2586 }
2520 2587
2521 void test_implicitThisReferenceInInitializer_superConstructorInvocation() { 2588 test_implicitThisReferenceInInitializer_superConstructorInvocation() async {
2522 Source source = addSource(r''' 2589 Source source = addSource(r'''
2523 class A { 2590 class A {
2524 A(p) {} 2591 A(p) {}
2525 } 2592 }
2526 class B extends A { 2593 class B extends A {
2527 B() : super(f); 2594 B() : super(f);
2528 var f; 2595 var f;
2529 }'''); 2596 }''');
2530 assertErrors( 2597 await assertErrors(
2531 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 2598 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
2532 verify([source]); 2599 verify([source]);
2533 } 2600 }
2534 2601
2535 void test_importInternalLibrary() { 2602 test_importInternalLibrary() async {
2536 Source source = addSource("import 'dart:_interceptors';"); 2603 Source source = addSource("import 'dart:_interceptors';");
2537 // Note, in these error cases we may generate an UNUSED_IMPORT hint, while 2604 // Note, in these error cases we may generate an UNUSED_IMPORT hint, while
2538 // we could prevent the hint from being generated by testing the import 2605 // we could prevent the hint from being generated by testing the import
2539 // directive for the error, this is such a minor corner case that we don't 2606 // directive for the error, this is such a minor corner case that we don't
2540 // think we should add the additional computation time to figure out such 2607 // think we should add the additional computation time to figure out such
2541 // cases. 2608 // cases.
2542 assertErrors(source, 2609 await assertErrors(source,
2543 [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]); 2610 [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]);
2544 verify([source]); 2611 verify([source]);
2545 } 2612 }
2546 2613
2547 void test_importInternalLibrary_js_helper() { 2614 test_importInternalLibrary_js_helper() async {
2548 Source source = addSource("import 'dart:_js_helper';"); 2615 Source source = addSource("import 'dart:_js_helper';");
2549 // Note, in these error cases we may generate an UNUSED_IMPORT hint, while 2616 // Note, in these error cases we may generate an UNUSED_IMPORT hint, while
2550 // we could prevent the hint from being generated by testing the import 2617 // we could prevent the hint from being generated by testing the import
2551 // directive for the error, this is such a minor corner case that we don't 2618 // directive for the error, this is such a minor corner case that we don't
2552 // think we should add the additional computation time to figure out such 2619 // think we should add the additional computation time to figure out such
2553 // cases. 2620 // cases.
2554 assertErrors(source, 2621 await assertErrors(source,
2555 [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]); 2622 [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]);
2556 verify([source]); 2623 verify([source]);
2557 } 2624 }
2558 2625
2559 void test_importOfNonLibrary() { 2626 test_importOfNonLibrary() async {
2560 Source source = addSource(r''' 2627 Source source = addSource(r'''
2561 library lib; 2628 library lib;
2562 import 'part.dart'; 2629 import 'part.dart';
2563 A a;'''); 2630 A a;''');
2564 addNamedSource( 2631 addNamedSource(
2565 "/part.dart", 2632 "/part.dart",
2566 r''' 2633 r'''
2567 part of lib; 2634 part of lib;
2568 class A{}'''); 2635 class A{}''');
2569 assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); 2636 await assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]);
2570 verify([source]); 2637 verify([source]);
2571 } 2638 }
2572 2639
2573 void test_inconsistentCaseExpressionTypes() { 2640 test_inconsistentCaseExpressionTypes() async {
2574 Source source = addSource(r''' 2641 Source source = addSource(r'''
2575 f(var p) { 2642 f(var p) {
2576 switch (p) { 2643 switch (p) {
2577 case 1: 2644 case 1:
2578 break; 2645 break;
2579 case 'a': 2646 case 'a':
2580 break; 2647 break;
2581 } 2648 }
2582 }'''); 2649 }''');
2583 assertErrors( 2650 await assertErrors(
2584 source, [CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); 2651 source, [CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
2585 verify([source]); 2652 verify([source]);
2586 } 2653 }
2587 2654
2588 void test_inconsistentCaseExpressionTypes_dynamic() { 2655 test_inconsistentCaseExpressionTypes_dynamic() async {
2589 // Even though A.S and S have a static type of "dynamic", we should see 2656 // Even though A.S and S have a static type of "dynamic", we should see
2590 // that they fail to match 3, because they are constant strings. 2657 // that they fail to match 3, because they are constant strings.
2591 Source source = addSource(r''' 2658 Source source = addSource(r'''
2592 class A { 2659 class A {
2593 static const S = 'A.S'; 2660 static const S = 'A.S';
2594 } 2661 }
2595 2662
2596 const S = 'S'; 2663 const S = 'S';
2597 2664
2598 foo(var p) { 2665 foo(var p) {
2599 switch (p) { 2666 switch (p) {
2600 case 3: 2667 case 3:
2601 break; 2668 break;
2602 case S: 2669 case S:
2603 break; 2670 break;
2604 case A.S: 2671 case A.S:
2605 break; 2672 break;
2606 } 2673 }
2607 }'''); 2674 }''');
2608 assertErrors(source, [ 2675 await assertErrors(source, [
2609 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, 2676 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
2610 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES 2677 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES
2611 ]); 2678 ]);
2612 verify([source]); 2679 verify([source]);
2613 } 2680 }
2614 2681
2615 void test_inconsistentCaseExpressionTypes_repeated() { 2682 test_inconsistentCaseExpressionTypes_repeated() async {
2616 Source source = addSource(r''' 2683 Source source = addSource(r'''
2617 f(var p) { 2684 f(var p) {
2618 switch (p) { 2685 switch (p) {
2619 case 1: 2686 case 1:
2620 break; 2687 break;
2621 case 'a': 2688 case 'a':
2622 break; 2689 break;
2623 case 'b': 2690 case 'b':
2624 break; 2691 break;
2625 } 2692 }
2626 }'''); 2693 }''');
2627 assertErrors(source, [ 2694 await assertErrors(source, [
2628 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, 2695 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
2629 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES 2696 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES
2630 ]); 2697 ]);
2631 verify([source]); 2698 verify([source]);
2632 } 2699 }
2633 2700
2634 void test_initializerForNonExistent_const() { 2701 test_initializerForNonExistent_const() async {
2635 // Check that the absence of a matching field doesn't cause a 2702 // Check that the absence of a matching field doesn't cause a
2636 // crash during constant evaluation. 2703 // crash during constant evaluation.
2637 Source source = addSource(r''' 2704 Source source = addSource(r'''
2638 class A { 2705 class A {
2639 const A() : x = 'foo'; 2706 const A() : x = 'foo';
2640 } 2707 }
2641 A a = const A();'''); 2708 A a = const A();''');
2642 assertErrors( 2709 await assertErrors(
2643 source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD]); 2710 source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD]);
2644 } 2711 }
2645 2712
2646 void test_initializerForNonExistent_initializer() { 2713 test_initializerForNonExistent_initializer() async {
2647 Source source = addSource(r''' 2714 Source source = addSource(r'''
2648 class A { 2715 class A {
2649 A() : x = 0 {} 2716 A() : x = 0 {}
2650 }'''); 2717 }''');
2651 assertErrors( 2718 await assertErrors(
2652 source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD]); 2719 source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD]);
2653 } 2720 }
2654 2721
2655 void test_initializerForStaticField() { 2722 test_initializerForStaticField() async {
2656 Source source = addSource(r''' 2723 Source source = addSource(r'''
2657 class A { 2724 class A {
2658 static int x; 2725 static int x;
2659 A() : x = 0 {} 2726 A() : x = 0 {}
2660 }'''); 2727 }''');
2661 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]); 2728 await assertErrors(
2729 source, [CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]);
2662 verify([source]); 2730 verify([source]);
2663 } 2731 }
2664 2732
2665 void test_initializingFormalForNonExistentField() { 2733 test_initializingFormalForNonExistentField() async {
2666 Source source = addSource(r''' 2734 Source source = addSource(r'''
2667 class A { 2735 class A {
2668 A(this.x) {} 2736 A(this.x) {}
2669 }'''); 2737 }''');
2670 assertErrors(source, 2738 await assertErrors(source,
2671 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]); 2739 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
2672 verify([source]); 2740 verify([source]);
2673 } 2741 }
2674 2742
2675 void test_initializingFormalForNonExistentField_notInEnclosingClass() { 2743 test_initializingFormalForNonExistentField_notInEnclosingClass() async {
2676 Source source = addSource(r''' 2744 Source source = addSource(r'''
2677 class A { 2745 class A {
2678 int x; 2746 int x;
2679 } 2747 }
2680 class B extends A { 2748 class B extends A {
2681 B(this.x) {} 2749 B(this.x) {}
2682 }'''); 2750 }''');
2683 assertErrors(source, 2751 await assertErrors(source,
2684 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]); 2752 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
2685 verify([source]); 2753 verify([source]);
2686 } 2754 }
2687 2755
2688 void test_initializingFormalForNonExistentField_optional() { 2756 test_initializingFormalForNonExistentField_optional() async {
2689 Source source = addSource(r''' 2757 Source source = addSource(r'''
2690 class A { 2758 class A {
2691 A([this.x]) {} 2759 A([this.x]) {}
2692 }'''); 2760 }''');
2693 assertErrors(source, 2761 await assertErrors(source,
2694 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]); 2762 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
2695 verify([source]); 2763 verify([source]);
2696 } 2764 }
2697 2765
2698 void test_initializingFormalForNonExistentField_synthetic() { 2766 test_initializingFormalForNonExistentField_synthetic() async {
2699 Source source = addSource(r''' 2767 Source source = addSource(r'''
2700 class A { 2768 class A {
2701 int get x => 1; 2769 int get x => 1;
2702 A(this.x) {} 2770 A(this.x) {}
2703 }'''); 2771 }''');
2704 assertErrors(source, 2772 await assertErrors(source,
2705 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]); 2773 [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
2706 verify([source]); 2774 verify([source]);
2707 } 2775 }
2708 2776
2709 void test_initializingFormalForStaticField() { 2777 test_initializingFormalForStaticField() async {
2710 Source source = addSource(r''' 2778 Source source = addSource(r'''
2711 class A { 2779 class A {
2712 static int x; 2780 static int x;
2713 A([this.x]) {} 2781 A([this.x]) {}
2714 }'''); 2782 }''');
2715 assertErrors( 2783 await assertErrors(
2716 source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]); 2784 source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]);
2717 verify([source]); 2785 verify([source]);
2718 } 2786 }
2719 2787
2720 void test_instanceMemberAccessFromFactory_named() { 2788 test_instanceMemberAccessFromFactory_named() async {
2721 Source source = addSource(r''' 2789 Source source = addSource(r'''
2722 class A { 2790 class A {
2723 m() {} 2791 m() {}
2724 A(); 2792 A();
2725 factory A.make() { 2793 factory A.make() {
2726 m(); 2794 m();
2727 return new A(); 2795 return new A();
2728 } 2796 }
2729 }'''); 2797 }''');
2730 assertErrors( 2798 await assertErrors(
2731 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY]); 2799 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY]);
2732 verify([source]); 2800 verify([source]);
2733 } 2801 }
2734 2802
2735 void test_instanceMemberAccessFromFactory_unnamed() { 2803 test_instanceMemberAccessFromFactory_unnamed() async {
2736 Source source = addSource(r''' 2804 Source source = addSource(r'''
2737 class A { 2805 class A {
2738 m() {} 2806 m() {}
2739 A._(); 2807 A._();
2740 factory A() { 2808 factory A() {
2741 m(); 2809 m();
2742 return new A._(); 2810 return new A._();
2743 } 2811 }
2744 }'''); 2812 }''');
2745 assertErrors( 2813 await assertErrors(
2746 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY]); 2814 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY]);
2747 verify([source]); 2815 verify([source]);
2748 } 2816 }
2749 2817
2750 void test_instanceMemberAccessFromStatic_field() { 2818 test_instanceMemberAccessFromStatic_field() async {
2751 Source source = addSource(r''' 2819 Source source = addSource(r'''
2752 class A { 2820 class A {
2753 int f; 2821 int f;
2754 static foo() { 2822 static foo() {
2755 f; 2823 f;
2756 } 2824 }
2757 }'''); 2825 }''');
2758 assertErrors( 2826 await assertErrors(
2759 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]); 2827 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
2760 verify([source]); 2828 verify([source]);
2761 } 2829 }
2762 2830
2763 void test_instanceMemberAccessFromStatic_getter() { 2831 test_instanceMemberAccessFromStatic_getter() async {
2764 Source source = addSource(r''' 2832 Source source = addSource(r'''
2765 class A { 2833 class A {
2766 get g => null; 2834 get g => null;
2767 static foo() { 2835 static foo() {
2768 g; 2836 g;
2769 } 2837 }
2770 }'''); 2838 }''');
2771 assertErrors( 2839 await assertErrors(
2772 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]); 2840 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
2773 verify([source]); 2841 verify([source]);
2774 } 2842 }
2775 2843
2776 void test_instanceMemberAccessFromStatic_method() { 2844 test_instanceMemberAccessFromStatic_method() async {
2777 Source source = addSource(r''' 2845 Source source = addSource(r'''
2778 class A { 2846 class A {
2779 m() {} 2847 m() {}
2780 static foo() { 2848 static foo() {
2781 m(); 2849 m();
2782 } 2850 }
2783 }'''); 2851 }''');
2784 assertErrors( 2852 await assertErrors(
2785 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]); 2853 source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
2786 verify([source]); 2854 verify([source]);
2787 } 2855 }
2788 2856
2789 void test_instantiateEnum_const() { 2857 test_instantiateEnum_const() async {
2790 Source source = addSource(r''' 2858 Source source = addSource(r'''
2791 enum E { ONE } 2859 enum E { ONE }
2792 E e(String name) { 2860 E e(String name) {
2793 return const E(); 2861 return const E();
2794 }'''); 2862 }''');
2795 assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]); 2863 await assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]);
2796 verify([source]); 2864 verify([source]);
2797 } 2865 }
2798 2866
2799 void test_instantiateEnum_new() { 2867 test_instantiateEnum_new() async {
2800 Source source = addSource(r''' 2868 Source source = addSource(r'''
2801 enum E { ONE } 2869 enum E { ONE }
2802 E e(String name) { 2870 E e(String name) {
2803 return new E(); 2871 return new E();
2804 }'''); 2872 }''');
2805 assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]); 2873 await assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]);
2806 verify([source]); 2874 verify([source]);
2807 } 2875 }
2808 2876
2809 void test_invalidAnnotation_getter() { 2877 test_invalidAnnotation_getter() async {
2810 Source source = addSource(r''' 2878 Source source = addSource(r'''
2811 get V => 0; 2879 get V => 0;
2812 @V 2880 @V
2813 main() { 2881 main() {
2814 }'''); 2882 }''');
2815 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2883 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2816 verify([source]); 2884 verify([source]);
2817 } 2885 }
2818 2886
2819 void test_invalidAnnotation_importWithPrefix_getter() { 2887 test_invalidAnnotation_importWithPrefix_getter() async {
2820 addNamedSource( 2888 addNamedSource(
2821 "/lib.dart", 2889 "/lib.dart",
2822 r''' 2890 r'''
2823 library lib; 2891 library lib;
2824 get V => 0;'''); 2892 get V => 0;''');
2825 Source source = addSource(r''' 2893 Source source = addSource(r'''
2826 import 'lib.dart' as p; 2894 import 'lib.dart' as p;
2827 @p.V 2895 @p.V
2828 main() { 2896 main() {
2829 }'''); 2897 }''');
2830 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2898 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2831 verify([source]); 2899 verify([source]);
2832 } 2900 }
2833 2901
2834 void test_invalidAnnotation_importWithPrefix_notConstantVariable() { 2902 test_invalidAnnotation_importWithPrefix_notConstantVariable() async {
2835 addNamedSource( 2903 addNamedSource(
2836 "/lib.dart", 2904 "/lib.dart",
2837 r''' 2905 r'''
2838 library lib; 2906 library lib;
2839 final V = 0;'''); 2907 final V = 0;''');
2840 Source source = addSource(r''' 2908 Source source = addSource(r'''
2841 import 'lib.dart' as p; 2909 import 'lib.dart' as p;
2842 @p.V 2910 @p.V
2843 main() { 2911 main() {
2844 }'''); 2912 }''');
2845 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2913 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2846 verify([source]); 2914 verify([source]);
2847 } 2915 }
2848 2916
2849 void 2917 test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() a sync {
2850 test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation () {
2851 addNamedSource( 2918 addNamedSource(
2852 "/lib.dart", 2919 "/lib.dart",
2853 r''' 2920 r'''
2854 library lib; 2921 library lib;
2855 typedef V();'''); 2922 typedef V();''');
2856 Source source = addSource(r''' 2923 Source source = addSource(r'''
2857 import 'lib.dart' as p; 2924 import 'lib.dart' as p;
2858 @p.V 2925 @p.V
2859 main() { 2926 main() {
2860 }'''); 2927 }''');
2861 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2928 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2862 verify([source]); 2929 verify([source]);
2863 } 2930 }
2864 2931
2865 void test_invalidAnnotation_notConstantVariable() { 2932 test_invalidAnnotation_notConstantVariable() async {
2866 Source source = addSource(r''' 2933 Source source = addSource(r'''
2867 final V = 0; 2934 final V = 0;
2868 @V 2935 @V
2869 main() { 2936 main() {
2870 }'''); 2937 }''');
2871 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2938 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2872 verify([source]); 2939 verify([source]);
2873 } 2940 }
2874 2941
2875 void test_invalidAnnotation_notVariableOrConstructorInvocation() { 2942 test_invalidAnnotation_notVariableOrConstructorInvocation() async {
2876 Source source = addSource(r''' 2943 Source source = addSource(r'''
2877 typedef V(); 2944 typedef V();
2878 @V 2945 @V
2879 main() { 2946 main() {
2880 }'''); 2947 }''');
2881 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2948 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2882 verify([source]); 2949 verify([source]);
2883 } 2950 }
2884 2951
2885 void test_invalidAnnotation_staticMethodReference() { 2952 test_invalidAnnotation_staticMethodReference() async {
2886 Source source = addSource(r''' 2953 Source source = addSource(r'''
2887 class A { 2954 class A {
2888 static f() {} 2955 static f() {}
2889 } 2956 }
2890 @A.f 2957 @A.f
2891 main() { 2958 main() {
2892 }'''); 2959 }''');
2893 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2960 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2894 verify([source]); 2961 verify([source]);
2895 } 2962 }
2896 2963
2897 void test_invalidAnnotation_unresolved_identifier() { 2964 test_invalidAnnotation_unresolved_identifier() async {
2898 Source source = addSource(r''' 2965 Source source = addSource(r'''
2899 @unresolved 2966 @unresolved
2900 main() { 2967 main() {
2901 }'''); 2968 }''');
2902 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2969 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2903 } 2970 }
2904 2971
2905 void test_invalidAnnotation_unresolved_invocation() { 2972 test_invalidAnnotation_unresolved_invocation() async {
2906 Source source = addSource(r''' 2973 Source source = addSource(r'''
2907 @Unresolved() 2974 @Unresolved()
2908 main() { 2975 main() {
2909 }'''); 2976 }''');
2910 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2977 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2911 } 2978 }
2912 2979
2913 void test_invalidAnnotation_unresolved_prefixedIdentifier() { 2980 test_invalidAnnotation_unresolved_prefixedIdentifier() async {
2914 Source source = addSource(r''' 2981 Source source = addSource(r'''
2915 import 'dart:math' as p; 2982 import 'dart:math' as p;
2916 @p.unresolved 2983 @p.unresolved
2917 main() { 2984 main() {
2918 }'''); 2985 }''');
2919 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2986 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2920 } 2987 }
2921 2988
2922 void test_invalidAnnotation_useLibraryScope() { 2989 test_invalidAnnotation_useLibraryScope() async {
2923 Source source = addSource(r''' 2990 Source source = addSource(r'''
2924 @foo 2991 @foo
2925 class A { 2992 class A {
2926 static const foo = null; 2993 static const foo = null;
2927 }'''); 2994 }''');
2928 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2995 await assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2929 } 2996 }
2930 2997
2931 void test_invalidAnnotationFromDeferredLibrary() { 2998 test_invalidAnnotationFromDeferredLibrary() async {
2932 // See test_invalidAnnotation_notConstantVariable 2999 // See test_invalidAnnotation_notConstantVariable
2933 resolveWithErrors(<String>[ 3000 await resolveWithErrors(<String>[
2934 r''' 3001 r'''
2935 library lib1; 3002 library lib1;
2936 class V { const V(); } 3003 class V { const V(); }
2937 const v = const V();''', 3004 const v = const V();''',
2938 r''' 3005 r'''
2939 library root; 3006 library root;
2940 import 'lib1.dart' deferred as a; 3007 import 'lib1.dart' deferred as a;
2941 @a.v main () {}''' 3008 @a.v main () {}'''
2942 ], <ErrorCode>[ 3009 ], <ErrorCode>[
2943 CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY 3010 CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY
2944 ]); 3011 ]);
2945 } 3012 }
2946 3013
2947 void test_invalidAnnotationFromDeferredLibrary_constructor() { 3014 test_invalidAnnotationFromDeferredLibrary_constructor() async {
2948 // See test_invalidAnnotation_notConstantVariable 3015 // See test_invalidAnnotation_notConstantVariable
2949 resolveWithErrors(<String>[ 3016 await resolveWithErrors(<String>[
2950 r''' 3017 r'''
2951 library lib1; 3018 library lib1;
2952 class C { const C(); }''', 3019 class C { const C(); }''',
2953 r''' 3020 r'''
2954 library root; 3021 library root;
2955 import 'lib1.dart' deferred as a; 3022 import 'lib1.dart' deferred as a;
2956 @a.C() main () {}''' 3023 @a.C() main () {}'''
2957 ], <ErrorCode>[ 3024 ], <ErrorCode>[
2958 CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY 3025 CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY
2959 ]); 3026 ]);
2960 } 3027 }
2961 3028
2962 void test_invalidAnnotationFromDeferredLibrary_namedConstructor() { 3029 test_invalidAnnotationFromDeferredLibrary_namedConstructor() async {
2963 // See test_invalidAnnotation_notConstantVariable 3030 // See test_invalidAnnotation_notConstantVariable
2964 resolveWithErrors(<String>[ 3031 await resolveWithErrors(<String>[
2965 r''' 3032 r'''
2966 library lib1; 3033 library lib1;
2967 class C { const C.name(); }''', 3034 class C { const C.name(); }''',
2968 r''' 3035 r'''
2969 library root; 3036 library root;
2970 import 'lib1.dart' deferred as a; 3037 import 'lib1.dart' deferred as a;
2971 @a.C.name() main () {}''' 3038 @a.C.name() main () {}'''
2972 ], <ErrorCode>[ 3039 ], <ErrorCode>[
2973 CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY 3040 CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY
2974 ]); 3041 ]);
2975 } 3042 }
2976 3043
2977 void test_invalidConstructorName_notEnclosingClassName_defined() { 3044 test_invalidConstructorName_notEnclosingClassName_defined() async {
2978 Source source = addSource(r''' 3045 Source source = addSource(r'''
2979 class A { 3046 class A {
2980 B() : super(); 3047 B() : super();
2981 } 3048 }
2982 class B {}'''); 3049 class B {}''');
2983 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); 3050 await assertErrors(
3051 source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
2984 // no verify() call, "B" is not resolved 3052 // no verify() call, "B" is not resolved
2985 } 3053 }
2986 3054
2987 void test_invalidConstructorName_notEnclosingClassName_undefined() { 3055 test_invalidConstructorName_notEnclosingClassName_undefined() async {
2988 Source source = addSource(r''' 3056 Source source = addSource(r'''
2989 class A { 3057 class A {
2990 B() : super(); 3058 B() : super();
2991 }'''); 3059 }''');
2992 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); 3060 await assertErrors(
3061 source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
2993 // no verify() call, "B" is not resolved 3062 // no verify() call, "B" is not resolved
2994 } 3063 }
2995 3064
2996 void test_invalidFactoryNameNotAClass_notClassName() { 3065 test_invalidFactoryNameNotAClass_notClassName() async {
2997 Source source = addSource(r''' 3066 Source source = addSource(r'''
2998 int B; 3067 int B;
2999 class A { 3068 class A {
3000 factory B() => null; 3069 factory B() => null;
3001 }'''); 3070 }''');
3002 assertErrors( 3071 await assertErrors(
3003 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]); 3072 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
3004 verify([source]); 3073 verify([source]);
3005 } 3074 }
3006 3075
3007 void test_invalidFactoryNameNotAClass_notEnclosingClassName() { 3076 test_invalidFactoryNameNotAClass_notEnclosingClassName() async {
3008 Source source = addSource(r''' 3077 Source source = addSource(r'''
3009 class A { 3078 class A {
3010 factory B() => null; 3079 factory B() => null;
3011 }'''); 3080 }''');
3012 assertErrors( 3081 await assertErrors(
3013 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]); 3082 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
3014 // no verify() call, "B" is not resolved 3083 // no verify() call, "B" is not resolved
3015 } 3084 }
3016 3085
3017 void test_invalidModifierOnConstructor_async() { 3086 test_invalidModifierOnConstructor_async() async {
3018 Source source = addSource(r''' 3087 Source source = addSource(r'''
3019 class A { 3088 class A {
3020 A() async {} 3089 A() async {}
3021 }'''); 3090 }''');
3022 assertErrors( 3091 await assertErrors(
3023 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]); 3092 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]);
3024 verify([source]); 3093 verify([source]);
3025 } 3094 }
3026 3095
3027 void test_invalidModifierOnConstructor_asyncStar() { 3096 test_invalidModifierOnConstructor_asyncStar() async {
3028 Source source = addSource(r''' 3097 Source source = addSource(r'''
3029 class A { 3098 class A {
3030 A() async* {} 3099 A() async* {}
3031 }'''); 3100 }''');
3032 assertErrors( 3101 await assertErrors(
3033 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]); 3102 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]);
3034 verify([source]); 3103 verify([source]);
3035 } 3104 }
3036 3105
3037 void test_invalidModifierOnConstructor_syncStar() { 3106 test_invalidModifierOnConstructor_syncStar() async {
3038 Source source = addSource(r''' 3107 Source source = addSource(r'''
3039 class A { 3108 class A {
3040 A() sync* {} 3109 A() sync* {}
3041 }'''); 3110 }''');
3042 assertErrors( 3111 await assertErrors(
3043 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]); 3112 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]);
3044 verify([source]); 3113 verify([source]);
3045 } 3114 }
3046 3115
3047 void test_invalidModifierOnSetter_member_async() { 3116 test_invalidModifierOnSetter_member_async() async {
3048 Source source = addSource(r''' 3117 Source source = addSource(r'''
3049 class A { 3118 class A {
3050 set x(v) async {} 3119 set x(v) async {}
3051 }'''); 3120 }''');
3052 assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]); 3121 await assertErrors(
3122 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
3053 verify([source]); 3123 verify([source]);
3054 } 3124 }
3055 3125
3056 void test_invalidModifierOnSetter_member_asyncStar() { 3126 test_invalidModifierOnSetter_member_asyncStar() async {
3057 Source source = addSource(r''' 3127 Source source = addSource(r'''
3058 class A { 3128 class A {
3059 set x(v) async* {} 3129 set x(v) async* {}
3060 }'''); 3130 }''');
3061 assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]); 3131 await assertErrors(
3132 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
3062 verify([source]); 3133 verify([source]);
3063 } 3134 }
3064 3135
3065 void test_invalidModifierOnSetter_member_syncStar() { 3136 test_invalidModifierOnSetter_member_syncStar() async {
3066 Source source = addSource(r''' 3137 Source source = addSource(r'''
3067 class A { 3138 class A {
3068 set x(v) sync* {} 3139 set x(v) sync* {}
3069 }'''); 3140 }''');
3070 assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]); 3141 await assertErrors(
3142 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
3071 verify([source]); 3143 verify([source]);
3072 } 3144 }
3073 3145
3074 void test_invalidModifierOnSetter_topLevel_async() { 3146 test_invalidModifierOnSetter_topLevel_async() async {
3075 Source source = addSource("set x(v) async {}"); 3147 Source source = addSource("set x(v) async {}");
3076 assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]); 3148 await assertErrors(
3149 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
3077 verify([source]); 3150 verify([source]);
3078 } 3151 }
3079 3152
3080 void test_invalidModifierOnSetter_topLevel_asyncStar() { 3153 test_invalidModifierOnSetter_topLevel_asyncStar() async {
3081 Source source = addSource("set x(v) async* {}"); 3154 Source source = addSource("set x(v) async* {}");
3082 assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]); 3155 await assertErrors(
3156 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
3083 verify([source]); 3157 verify([source]);
3084 } 3158 }
3085 3159
3086 void test_invalidModifierOnSetter_topLevel_syncStar() { 3160 test_invalidModifierOnSetter_topLevel_syncStar() async {
3087 Source source = addSource("set x(v) sync* {}"); 3161 Source source = addSource("set x(v) sync* {}");
3088 assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]); 3162 await assertErrors(
3163 source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
3089 verify([source]); 3164 verify([source]);
3090 } 3165 }
3091 3166
3092 void test_invalidReferenceToThis_factoryConstructor() { 3167 test_invalidReferenceToThis_factoryConstructor() async {
3093 Source source = addSource(r''' 3168 Source source = addSource(r'''
3094 class A { 3169 class A {
3095 factory A() { return this; } 3170 factory A() { return this; }
3096 }'''); 3171 }''');
3097 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3172 await assertErrors(
3173 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3098 verify([source]); 3174 verify([source]);
3099 } 3175 }
3100 3176
3101 void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() { 3177 test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() async {
3102 Source source = addSource(r''' 3178 Source source = addSource(r'''
3103 class A { 3179 class A {
3104 var f; 3180 var f;
3105 A() : f = this; 3181 A() : f = this;
3106 }'''); 3182 }''');
3107 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3183 await assertErrors(
3184 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3108 verify([source]); 3185 verify([source]);
3109 } 3186 }
3110 3187
3111 void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() { 3188 test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() async {
3112 Source source = addSource(r''' 3189 Source source = addSource(r'''
3113 class A { 3190 class A {
3114 var f = this; 3191 var f = this;
3115 }'''); 3192 }''');
3116 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3193 await assertErrors(
3194 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3117 verify([source]); 3195 verify([source]);
3118 } 3196 }
3119 3197
3120 void test_invalidReferenceToThis_staticMethod() { 3198 test_invalidReferenceToThis_staticMethod() async {
3121 Source source = addSource(r''' 3199 Source source = addSource(r'''
3122 class A { 3200 class A {
3123 static m() { return this; } 3201 static m() { return this; }
3124 }'''); 3202 }''');
3125 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3203 await assertErrors(
3204 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3126 verify([source]); 3205 verify([source]);
3127 } 3206 }
3128 3207
3129 void test_invalidReferenceToThis_staticVariableInitializer() { 3208 test_invalidReferenceToThis_staticVariableInitializer() async {
3130 Source source = addSource(r''' 3209 Source source = addSource(r'''
3131 class A { 3210 class A {
3132 static A f = this; 3211 static A f = this;
3133 }'''); 3212 }''');
3134 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3213 await assertErrors(
3214 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3135 verify([source]); 3215 verify([source]);
3136 } 3216 }
3137 3217
3138 void test_invalidReferenceToThis_superInitializer() { 3218 test_invalidReferenceToThis_superInitializer() async {
3139 Source source = addSource(r''' 3219 Source source = addSource(r'''
3140 class A { 3220 class A {
3141 A(var x) {} 3221 A(var x) {}
3142 } 3222 }
3143 class B extends A { 3223 class B extends A {
3144 B() : super(this); 3224 B() : super(this);
3145 }'''); 3225 }''');
3146 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3226 await assertErrors(
3227 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3147 verify([source]); 3228 verify([source]);
3148 } 3229 }
3149 3230
3150 void test_invalidReferenceToThis_topLevelFunction() { 3231 test_invalidReferenceToThis_topLevelFunction() async {
3151 Source source = addSource("f() { return this; }"); 3232 Source source = addSource("f() { return this; }");
3152 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3233 await assertErrors(
3234 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3153 verify([source]); 3235 verify([source]);
3154 } 3236 }
3155 3237
3156 void test_invalidReferenceToThis_variableInitializer() { 3238 test_invalidReferenceToThis_variableInitializer() async {
3157 Source source = addSource("int x = this;"); 3239 Source source = addSource("int x = this;");
3158 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); 3240 await assertErrors(
3241 source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
3159 verify([source]); 3242 verify([source]);
3160 } 3243 }
3161 3244
3162 void test_invalidTypeArgumentInConstList() { 3245 test_invalidTypeArgumentInConstList() async {
3163 Source source = addSource(r''' 3246 Source source = addSource(r'''
3164 class A<E> { 3247 class A<E> {
3165 m() { 3248 m() {
3166 return const <E>[]; 3249 return const <E>[];
3167 } 3250 }
3168 }'''); 3251 }''');
3169 assertErrors( 3252 await assertErrors(
3170 source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]); 3253 source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]);
3171 verify([source]); 3254 verify([source]);
3172 } 3255 }
3173 3256
3174 void test_invalidTypeArgumentInConstMap() { 3257 test_invalidTypeArgumentInConstMap() async {
3175 Source source = addSource(r''' 3258 Source source = addSource(r'''
3176 class A<E> { 3259 class A<E> {
3177 m() { 3260 m() {
3178 return const <String, E>{}; 3261 return const <String, E>{};
3179 } 3262 }
3180 }'''); 3263 }''');
3181 assertErrors( 3264 await assertErrors(
3182 source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]); 3265 source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]);
3183 verify([source]); 3266 verify([source]);
3184 } 3267 }
3185 3268
3186 void test_invalidUri_export() { 3269 test_invalidUri_export() async {
3187 Source source = addSource("export 'ht:';"); 3270 Source source = addSource("export 'ht:';");
3188 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); 3271 await assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
3189 } 3272 }
3190 3273
3191 void test_invalidUri_import() { 3274 test_invalidUri_import() async {
3192 Source source = addSource("import 'ht:';"); 3275 Source source = addSource("import 'ht:';");
3193 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); 3276 await assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
3194 } 3277 }
3195 3278
3196 void test_invalidUri_part() { 3279 test_invalidUri_part() async {
3197 Source source = addSource(r''' 3280 Source source = addSource(r'''
3198 library lib; 3281 library lib;
3199 part 'ht:';'''); 3282 part 'ht:';''');
3200 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); 3283 await assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
3201 } 3284 }
3202 3285
3203 void test_isInConstInstanceCreation_restored() { 3286 test_isInConstInstanceCreation_restored() async {
3204 // If ErrorVerifier._isInConstInstanceCreation is not properly restored on 3287 // If ErrorVerifier._isInConstInstanceCreation is not properly restored on
3205 // exit from visitInstanceCreationExpression, the error at (1) will be 3288 // exit from visitInstanceCreationExpression, the error at (1) will be
3206 // treated as a warning rather than an error. 3289 // treated as a warning rather than an error.
3207 Source source = addSource(r''' 3290 Source source = addSource(r'''
3208 class Foo<T extends num> { 3291 class Foo<T extends num> {
3209 const Foo(x, y); 3292 const Foo(x, y);
3210 } 3293 }
3211 const x = const Foo<int>(const Foo<int>(0, 1), 3294 const x = const Foo<int>(const Foo<int>(0, 1),
3212 const <Foo<String>>[]); // (1) 3295 const <Foo<String>>[]); // (1)
3213 '''); 3296 ''');
3214 assertErrors( 3297 await assertErrors(
3215 source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); 3298 source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3216 verify([source]); 3299 verify([source]);
3217 } 3300 }
3218 3301
3219 void test_isInInstanceVariableInitializer_restored() { 3302 test_isInInstanceVariableInitializer_restored() async {
3220 // If ErrorVerifier._isInInstanceVariableInitializer is not properly 3303 // If ErrorVerifier._isInInstanceVariableInitializer is not properly
3221 // restored on exit from visitVariableDeclaration, the error at (1) 3304 // restored on exit from visitVariableDeclaration, the error at (1)
3222 // won't be detected. 3305 // won't be detected.
3223 Source source = addSource(r''' 3306 Source source = addSource(r'''
3224 class Foo { 3307 class Foo {
3225 var bar; 3308 var bar;
3226 Map foo = { 3309 Map foo = {
3227 'bar': () { 3310 'bar': () {
3228 var _bar; 3311 var _bar;
3229 }, 3312 },
3230 'bop': _foo // (1) 3313 'bop': _foo // (1)
3231 }; 3314 };
3232 _foo() { 3315 _foo() {
3233 } 3316 }
3234 }'''); 3317 }''');
3235 assertErrors( 3318 await assertErrors(
3236 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 3319 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
3237 verify([source]); 3320 verify([source]);
3238 } 3321 }
3239 3322
3240 void test_labelInOuterScope() { 3323 test_labelInOuterScope() async {
3241 Source source = addSource(r''' 3324 Source source = addSource(r'''
3242 class A { 3325 class A {
3243 void m(int i) { 3326 void m(int i) {
3244 l: while (i > 0) { 3327 l: while (i > 0) {
3245 void f() { 3328 void f() {
3246 break l; 3329 break l;
3247 }; 3330 };
3248 } 3331 }
3249 } 3332 }
3250 }'''); 3333 }''');
3251 assertErrors(source, [CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]); 3334 await assertErrors(source, [CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]);
3252 // We cannot verify resolution with unresolvable labels 3335 // We cannot verify resolution with unresolvable labels
3253 } 3336 }
3254 3337
3255 void test_labelUndefined_break() { 3338 test_labelUndefined_break() async {
3256 Source source = addSource(r''' 3339 Source source = addSource(r'''
3257 f() { 3340 f() {
3258 x: while (true) { 3341 x: while (true) {
3259 break y; 3342 break y;
3260 } 3343 }
3261 }'''); 3344 }''');
3262 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); 3345 await assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]);
3263 // We cannot verify resolution with undefined labels 3346 // We cannot verify resolution with undefined labels
3264 } 3347 }
3265 3348
3266 void test_labelUndefined_continue() { 3349 test_labelUndefined_continue() async {
3267 Source source = addSource(r''' 3350 Source source = addSource(r'''
3268 f() { 3351 f() {
3269 x: while (true) { 3352 x: while (true) {
3270 continue y; 3353 continue y;
3271 } 3354 }
3272 }'''); 3355 }''');
3273 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); 3356 await assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]);
3274 // We cannot verify resolution with undefined labels 3357 // We cannot verify resolution with undefined labels
3275 } 3358 }
3276 3359
3277 void test_length_of_erroneous_constant() { 3360 test_length_of_erroneous_constant() async {
3278 // Attempting to compute the length of constant that couldn't be evaluated 3361 // Attempting to compute the length of constant that couldn't be evaluated
3279 // (due to an error) should not crash the analyzer (see dartbug.com/23383) 3362 // (due to an error) should not crash the analyzer (see dartbug.com/23383)
3280 Source source = addSource("const int i = (1 ? 'alpha' : 'beta').length;"); 3363 Source source = addSource("const int i = (1 ? 'alpha' : 'beta').length;");
3281 assertErrors(source, [ 3364 await assertErrors(source, [
3282 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE, 3365 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE,
3283 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, 3366 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
3284 StaticTypeWarningCode.NON_BOOL_CONDITION 3367 StaticTypeWarningCode.NON_BOOL_CONDITION
3285 ]); 3368 ]);
3286 verify([source]); 3369 verify([source]);
3287 } 3370 }
3288 3371
3289 void test_memberWithClassName_field() { 3372 test_memberWithClassName_field() async {
3290 Source source = addSource(r''' 3373 Source source = addSource(r'''
3291 class A { 3374 class A {
3292 int A = 0; 3375 int A = 0;
3293 }'''); 3376 }''');
3294 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); 3377 await assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
3295 verify([source]); 3378 verify([source]);
3296 } 3379 }
3297 3380
3298 void test_memberWithClassName_field2() { 3381 test_memberWithClassName_field2() async {
3299 Source source = addSource(r''' 3382 Source source = addSource(r'''
3300 class A { 3383 class A {
3301 int z, A, b = 0; 3384 int z, A, b = 0;
3302 }'''); 3385 }''');
3303 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); 3386 await assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
3304 verify([source]); 3387 verify([source]);
3305 } 3388 }
3306 3389
3307 void test_memberWithClassName_getter() { 3390 test_memberWithClassName_getter() async {
3308 Source source = addSource(r''' 3391 Source source = addSource(r'''
3309 class A { 3392 class A {
3310 get A => 0; 3393 get A => 0;
3311 }'''); 3394 }''');
3312 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); 3395 await assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
3313 verify([source]); 3396 verify([source]);
3314 } 3397 }
3315 3398
3316 void test_memberWithClassName_method() { 3399 test_memberWithClassName_method() async {
3317 // no test because indistinguishable from constructor 3400 // no test because indistinguishable from constructor
3318 } 3401 }
3319 3402
3320 void test_methodAndGetterWithSameName() { 3403 test_methodAndGetterWithSameName() async {
3321 Source source = addSource(r''' 3404 Source source = addSource(r'''
3322 class A { 3405 class A {
3323 get x => 0; 3406 get x => 0;
3324 x(y) {} 3407 x(y) {}
3325 }'''); 3408 }''');
3326 assertErrors( 3409 await assertErrors(
3327 source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]); 3410 source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]);
3328 verify([source]); 3411 verify([source]);
3329 } 3412 }
3330 3413
3331 void test_mixinDeclaresConstructor_classDeclaration() { 3414 test_mixinDeclaresConstructor_classDeclaration() async {
3332 Source source = addSource(r''' 3415 Source source = addSource(r'''
3333 class A { 3416 class A {
3334 A() {} 3417 A() {}
3335 } 3418 }
3336 class B extends Object with A {}'''); 3419 class B extends Object with A {}''');
3337 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 3420 await assertErrors(
3421 source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
3338 verify([source]); 3422 verify([source]);
3339 } 3423 }
3340 3424
3341 void test_mixinDeclaresConstructor_typeAlias() { 3425 test_mixinDeclaresConstructor_typeAlias() async {
3342 Source source = addSource(r''' 3426 Source source = addSource(r'''
3343 class A { 3427 class A {
3344 A() {} 3428 A() {}
3345 } 3429 }
3346 class B = Object with A;'''); 3430 class B = Object with A;''');
3347 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 3431 await assertErrors(
3432 source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
3348 verify([source]); 3433 verify([source]);
3349 } 3434 }
3350 3435
3351 void test_mixinDeferredClass() { 3436 test_mixinDeferredClass() async {
3352 resolveWithErrors(<String>[ 3437 await resolveWithErrors(<String>[
3353 r''' 3438 r'''
3354 library lib1; 3439 library lib1;
3355 class A {}''', 3440 class A {}''',
3356 r''' 3441 r'''
3357 library root; 3442 library root;
3358 import 'lib1.dart' deferred as a; 3443 import 'lib1.dart' deferred as a;
3359 class B extends Object with a.A {}''' 3444 class B extends Object with a.A {}'''
3360 ], <ErrorCode>[ 3445 ], <ErrorCode>[
3361 CompileTimeErrorCode.MIXIN_DEFERRED_CLASS 3446 CompileTimeErrorCode.MIXIN_DEFERRED_CLASS
3362 ]); 3447 ]);
3363 } 3448 }
3364 3449
3365 void test_mixinDeferredClass_classTypeAlias() { 3450 test_mixinDeferredClass_classTypeAlias() async {
3366 resolveWithErrors(<String>[ 3451 await resolveWithErrors(<String>[
3367 r''' 3452 r'''
3368 library lib1; 3453 library lib1;
3369 class A {}''', 3454 class A {}''',
3370 r''' 3455 r'''
3371 library root; 3456 library root;
3372 import 'lib1.dart' deferred as a; 3457 import 'lib1.dart' deferred as a;
3373 class B {} 3458 class B {}
3374 class C = B with a.A;''' 3459 class C = B with a.A;'''
3375 ], <ErrorCode>[ 3460 ], <ErrorCode>[
3376 CompileTimeErrorCode.MIXIN_DEFERRED_CLASS 3461 CompileTimeErrorCode.MIXIN_DEFERRED_CLASS
3377 ]); 3462 ]);
3378 } 3463 }
3379 3464
3380 void test_mixinHasNoConstructors_mixinApp() { 3465 test_mixinHasNoConstructors_mixinApp() async {
3381 Source source = addSource(r''' 3466 Source source = addSource(r'''
3382 class B { 3467 class B {
3383 B({x}); 3468 B({x});
3384 } 3469 }
3385 class M {} 3470 class M {}
3386 class C = B with M; 3471 class C = B with M;
3387 '''); 3472 ''');
3388 assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); 3473 await assertErrors(
3474 source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
3389 verify([source]); 3475 verify([source]);
3390 } 3476 }
3391 3477
3392 void test_mixinHasNoConstructors_mixinClass() { 3478 test_mixinHasNoConstructors_mixinClass() async {
3393 Source source = addSource(r''' 3479 Source source = addSource(r'''
3394 class B { 3480 class B {
3395 B({x}); 3481 B({x});
3396 } 3482 }
3397 class M {} 3483 class M {}
3398 class C extends B with M {} 3484 class C extends B with M {}
3399 '''); 3485 ''');
3400 // Note: the implicit call from C's default constructor to B() should not 3486 // Note: the implicit call from C's default constructor to B() should not
3401 // generate a further error (despite the fact that it's not forwarded), 3487 // generate a further error (despite the fact that it's not forwarded),
3402 // since CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job 3488 // since CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job
3403 // of explaining the probem to the user. 3489 // of explaining the probem to the user.
3404 assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); 3490 await assertErrors(
3491 source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
3405 verify([source]); 3492 verify([source]);
3406 } 3493 }
3407 3494
3408 void test_mixinHasNoConstructors_mixinClass_explicitSuperCall() { 3495 test_mixinHasNoConstructors_mixinClass_explicitSuperCall() async {
3409 Source source = addSource(r''' 3496 Source source = addSource(r'''
3410 class B { 3497 class B {
3411 B({x}); 3498 B({x});
3412 } 3499 }
3413 class M {} 3500 class M {}
3414 class C extends B with M { 3501 class C extends B with M {
3415 C() : super(); 3502 C() : super();
3416 } 3503 }
3417 '''); 3504 ''');
3418 // Note: the explicit call from C() to B() should not generate a further 3505 // Note: the explicit call from C() to B() should not generate a further
3419 // error (despite the fact that it's not forwarded), since 3506 // error (despite the fact that it's not forwarded), since
3420 // CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of 3507 // CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of
3421 // explaining the error to the user. 3508 // explaining the error to the user.
3422 assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); 3509 await assertErrors(
3510 source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
3423 verify([source]); 3511 verify([source]);
3424 } 3512 }
3425 3513
3426 void test_mixinHasNoConstructors_mixinClass_implicitSuperCall() { 3514 test_mixinHasNoConstructors_mixinClass_implicitSuperCall() async {
3427 Source source = addSource(r''' 3515 Source source = addSource(r'''
3428 class B { 3516 class B {
3429 B({x}); 3517 B({x});
3430 } 3518 }
3431 class M {} 3519 class M {}
3432 class C extends B with M { 3520 class C extends B with M {
3433 C(); 3521 C();
3434 } 3522 }
3435 '''); 3523 ''');
3436 // Note: the implicit call from C() to B() should not generate a further 3524 // Note: the implicit call from C() to B() should not generate a further
3437 // error (despite the fact that it's not forwarded), since 3525 // error (despite the fact that it's not forwarded), since
3438 // CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of 3526 // CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of
3439 // explaining the error to the user. 3527 // explaining the error to the user.
3440 assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); 3528 await assertErrors(
3529 source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
3441 verify([source]); 3530 verify([source]);
3442 } 3531 }
3443 3532
3444 void test_mixinHasNoConstructors_mixinClass_namedSuperCall() { 3533 test_mixinHasNoConstructors_mixinClass_namedSuperCall() async {
3445 Source source = addSource(r''' 3534 Source source = addSource(r'''
3446 class B { 3535 class B {
3447 B.named({x}); 3536 B.named({x});
3448 } 3537 }
3449 class M {} 3538 class M {}
3450 class C extends B with M { 3539 class C extends B with M {
3451 C() : super.named(); 3540 C() : super.named();
3452 } 3541 }
3453 '''); 3542 ''');
3454 // Note: the explicit call from C() to B.named() should not generate a 3543 // Note: the explicit call from C() to B.named() should not generate a
3455 // further error (despite the fact that it's not forwarded), since 3544 // further error (despite the fact that it's not forwarded), since
3456 // CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of 3545 // CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of
3457 // explaining the error to the user. 3546 // explaining the error to the user.
3458 assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); 3547 await assertErrors(
3459 verify([source]); 3548 source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
3460 } 3549 verify([source]);
3461 3550 }
3462 void test_mixinInheritsFromNotObject_classDeclaration_extends() { 3551
3552 test_mixinInheritsFromNotObject_classDeclaration_extends() async {
3463 Source source = addSource(r''' 3553 Source source = addSource(r'''
3464 class A {} 3554 class A {}
3465 class B extends A {} 3555 class B extends A {}
3466 class C extends Object with B {}'''); 3556 class C extends Object with B {}''');
3467 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); 3557 await assertErrors(
3468 verify([source]); 3558 source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
3469 } 3559 verify([source]);
3470 3560 }
3471 void test_mixinInheritsFromNotObject_classDeclaration_with() { 3561
3562 test_mixinInheritsFromNotObject_classDeclaration_with() async {
3472 Source source = addSource(r''' 3563 Source source = addSource(r'''
3473 class A {} 3564 class A {}
3474 class B extends Object with A {} 3565 class B extends Object with A {}
3475 class C extends Object with B {}'''); 3566 class C extends Object with B {}''');
3476 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); 3567 await assertErrors(
3477 verify([source]); 3568 source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
3478 } 3569 verify([source]);
3479 3570 }
3480 void test_mixinInheritsFromNotObject_typeAlias_extends() { 3571
3572 test_mixinInheritsFromNotObject_typeAlias_extends() async {
3481 Source source = addSource(r''' 3573 Source source = addSource(r'''
3482 class A {} 3574 class A {}
3483 class B extends A {} 3575 class B extends A {}
3484 class C = Object with B;'''); 3576 class C = Object with B;''');
3485 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); 3577 await assertErrors(
3486 verify([source]); 3578 source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
3487 } 3579 verify([source]);
3488 3580 }
3489 void test_mixinInheritsFromNotObject_typeAlias_with() { 3581
3582 test_mixinInheritsFromNotObject_typeAlias_with() async {
3490 Source source = addSource(r''' 3583 Source source = addSource(r'''
3491 class A {} 3584 class A {}
3492 class B extends Object with A {} 3585 class B extends Object with A {}
3493 class C = Object with B;'''); 3586 class C = Object with B;''');
3494 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); 3587 await assertErrors(
3495 verify([source]); 3588 source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
3496 } 3589 verify([source]);
3497 3590 }
3498 void test_mixinOfDisallowedClass_class_bool() { 3591
3592 test_mixinOfDisallowedClass_class_bool() async {
3499 Source source = addSource("class A extends Object with bool {}"); 3593 Source source = addSource("class A extends Object with bool {}");
3500 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3594 await assertErrors(
3501 verify([source]); 3595 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3502 } 3596 verify([source]);
3503 3597 }
3504 void test_mixinOfDisallowedClass_class_double() { 3598
3599 test_mixinOfDisallowedClass_class_double() async {
3505 Source source = addSource("class A extends Object with double {}"); 3600 Source source = addSource("class A extends Object with double {}");
3506 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3601 await assertErrors(
3507 verify([source]); 3602 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3508 } 3603 verify([source]);
3509 3604 }
3510 void test_mixinOfDisallowedClass_class_int() { 3605
3606 test_mixinOfDisallowedClass_class_int() async {
3511 Source source = addSource("class A extends Object with int {}"); 3607 Source source = addSource("class A extends Object with int {}");
3512 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3608 await assertErrors(
3513 verify([source]); 3609 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3514 } 3610 verify([source]);
3515 3611 }
3516 void test_mixinOfDisallowedClass_class_Null() { 3612
3613 test_mixinOfDisallowedClass_class_Null() async {
3517 Source source = addSource("class A extends Object with Null {}"); 3614 Source source = addSource("class A extends Object with Null {}");
3518 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3615 await assertErrors(
3519 verify([source]); 3616 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3520 } 3617 verify([source]);
3521 3618 }
3522 void test_mixinOfDisallowedClass_class_num() { 3619
3620 test_mixinOfDisallowedClass_class_num() async {
3523 Source source = addSource("class A extends Object with num {}"); 3621 Source source = addSource("class A extends Object with num {}");
3524 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3622 await assertErrors(
3525 verify([source]); 3623 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3526 } 3624 verify([source]);
3527 3625 }
3528 void test_mixinOfDisallowedClass_class_String() { 3626
3627 test_mixinOfDisallowedClass_class_String() async {
3529 Source source = addSource("class A extends Object with String {}"); 3628 Source source = addSource("class A extends Object with String {}");
3530 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3629 await assertErrors(
3531 verify([source]); 3630 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3532 } 3631 verify([source]);
3533 3632 }
3534 void test_mixinOfDisallowedClass_classTypeAlias_bool() { 3633
3634 test_mixinOfDisallowedClass_classTypeAlias_bool() async {
3535 Source source = addSource(r''' 3635 Source source = addSource(r'''
3536 class A {} 3636 class A {}
3537 class C = A with bool;'''); 3637 class C = A with bool;''');
3538 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3638 await assertErrors(
3539 verify([source]); 3639 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3540 } 3640 verify([source]);
3541 3641 }
3542 void test_mixinOfDisallowedClass_classTypeAlias_double() { 3642
3643 test_mixinOfDisallowedClass_classTypeAlias_double() async {
3543 Source source = addSource(r''' 3644 Source source = addSource(r'''
3544 class A {} 3645 class A {}
3545 class C = A with double;'''); 3646 class C = A with double;''');
3546 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3647 await assertErrors(
3547 verify([source]); 3648 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3548 } 3649 verify([source]);
3549 3650 }
3550 void test_mixinOfDisallowedClass_classTypeAlias_int() { 3651
3652 test_mixinOfDisallowedClass_classTypeAlias_int() async {
3551 Source source = addSource(r''' 3653 Source source = addSource(r'''
3552 class A {} 3654 class A {}
3553 class C = A with int;'''); 3655 class C = A with int;''');
3554 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3656 await assertErrors(
3555 verify([source]); 3657 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3556 } 3658 verify([source]);
3557 3659 }
3558 void test_mixinOfDisallowedClass_classTypeAlias_Null() { 3660
3661 test_mixinOfDisallowedClass_classTypeAlias_Null() async {
3559 Source source = addSource(r''' 3662 Source source = addSource(r'''
3560 class A {} 3663 class A {}
3561 class C = A with Null;'''); 3664 class C = A with Null;''');
3562 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3665 await assertErrors(
3563 verify([source]); 3666 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3564 } 3667 verify([source]);
3565 3668 }
3566 void test_mixinOfDisallowedClass_classTypeAlias_num() { 3669
3670 test_mixinOfDisallowedClass_classTypeAlias_num() async {
3567 Source source = addSource(r''' 3671 Source source = addSource(r'''
3568 class A {} 3672 class A {}
3569 class C = A with num;'''); 3673 class C = A with num;''');
3570 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3674 await assertErrors(
3571 verify([source]); 3675 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3572 } 3676 verify([source]);
3573 3677 }
3574 void test_mixinOfDisallowedClass_classTypeAlias_String() { 3678
3679 test_mixinOfDisallowedClass_classTypeAlias_String() async {
3575 Source source = addSource(r''' 3680 Source source = addSource(r'''
3576 class A {} 3681 class A {}
3577 class C = A with String;'''); 3682 class C = A with String;''');
3578 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3683 await assertErrors(
3579 verify([source]); 3684 source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3580 } 3685 verify([source]);
3581 3686 }
3582 void test_mixinOfDisallowedClass_classTypeAlias_String_num() { 3687
3688 test_mixinOfDisallowedClass_classTypeAlias_String_num() async {
3583 Source source = addSource(r''' 3689 Source source = addSource(r'''
3584 class A {} 3690 class A {}
3585 class C = A with String, num;'''); 3691 class C = A with String, num;''');
3586 assertErrors(source, [ 3692 await assertErrors(source, [
3587 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS, 3693 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS,
3588 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS 3694 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS
3589 ]); 3695 ]);
3590 verify([source]); 3696 verify([source]);
3591 } 3697 }
3592 3698
3593 void test_mixinOfEnum() { 3699 test_mixinOfEnum() async {
3594 Source source = addSource(r''' 3700 Source source = addSource(r'''
3595 enum E { ONE } 3701 enum E { ONE }
3596 class A extends Object with E {}'''); 3702 class A extends Object with E {}''');
3597 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_ENUM]); 3703 await assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_ENUM]);
3598 verify([source]); 3704 verify([source]);
3599 } 3705 }
3600 3706
3601 void test_mixinOfNonClass_class() { 3707 test_mixinOfNonClass_class() async {
3602 Source source = addSource(r''' 3708 Source source = addSource(r'''
3603 int A; 3709 int A;
3604 class B extends Object with A {}'''); 3710 class B extends Object with A {}''');
3605 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 3711 await assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
3606 verify([source]); 3712 verify([source]);
3607 } 3713 }
3608 3714
3609 void test_mixinOfNonClass_typeAlias() { 3715 test_mixinOfNonClass_typeAlias() async {
3610 Source source = addSource(r''' 3716 Source source = addSource(r'''
3611 class A {} 3717 class A {}
3612 int B; 3718 int B;
3613 class C = A with B;'''); 3719 class C = A with B;''');
3614 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 3720 await assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
3615 verify([source]); 3721 verify([source]);
3616 } 3722 }
3617 3723
3618 void test_mixinReferencesSuper() { 3724 test_mixinReferencesSuper() async {
3619 Source source = addSource(r''' 3725 Source source = addSource(r'''
3620 class A { 3726 class A {
3621 toString() => super.toString(); 3727 toString() => super.toString();
3622 } 3728 }
3623 class B extends Object with A {}'''); 3729 class B extends Object with A {}''');
3624 assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]); 3730 await assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]);
3625 verify([source]); 3731 verify([source]);
3626 } 3732 }
3627 3733
3628 void test_mixinWithNonClassSuperclass_class() { 3734 test_mixinWithNonClassSuperclass_class() async {
3629 Source source = addSource(r''' 3735 Source source = addSource(r'''
3630 int A; 3736 int A;
3631 class B {} 3737 class B {}
3632 class C extends A with B {}'''); 3738 class C extends A with B {}''');
3633 assertErrors( 3739 await assertErrors(
3634 source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]); 3740 source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
3635 verify([source]); 3741 verify([source]);
3636 } 3742 }
3637 3743
3638 void test_mixinWithNonClassSuperclass_typeAlias() { 3744 test_mixinWithNonClassSuperclass_typeAlias() async {
3639 Source source = addSource(r''' 3745 Source source = addSource(r'''
3640 int A; 3746 int A;
3641 class B {} 3747 class B {}
3642 class C = A with B;'''); 3748 class C = A with B;''');
3643 assertErrors( 3749 await assertErrors(
3644 source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]); 3750 source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
3645 verify([source]); 3751 verify([source]);
3646 } 3752 }
3647 3753
3648 void test_multipleRedirectingConstructorInvocations() { 3754 test_multipleRedirectingConstructorInvocations() async {
3649 Source source = addSource(r''' 3755 Source source = addSource(r'''
3650 class A { 3756 class A {
3651 A() : this.a(), this.b(); 3757 A() : this.a(), this.b();
3652 A.a() {} 3758 A.a() {}
3653 A.b() {} 3759 A.b() {}
3654 }'''); 3760 }''');
3655 assertErrors(source, 3761 await assertErrors(source,
3656 [CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS]); 3762 [CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS]);
3657 verify([source]); 3763 verify([source]);
3658 } 3764 }
3659 3765
3660 void test_multipleSuperInitializers() { 3766 test_multipleSuperInitializers() async {
3661 Source source = addSource(r''' 3767 Source source = addSource(r'''
3662 class A {} 3768 class A {}
3663 class B extends A { 3769 class B extends A {
3664 B() : super(), super() {} 3770 B() : super(), super() {}
3665 }'''); 3771 }''');
3666 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]); 3772 await assertErrors(
3667 verify([source]); 3773 source, [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]);
3668 } 3774 verify([source]);
3669 3775 }
3670 void test_nativeClauseInNonSDKCode() { 3776
3777 test_nativeClauseInNonSDKCode() async {
3671 // TODO(jwren) Move this test somewhere else: This test verifies a parser 3778 // TODO(jwren) Move this test somewhere else: This test verifies a parser
3672 // error code is generated through the ErrorVerifier, it is not a 3779 // error code is generated through the ErrorVerifier, it is not a
3673 // CompileTimeErrorCode. 3780 // CompileTimeErrorCode.
3674 Source source = addSource("class A native 'string' {}"); 3781 Source source = addSource("class A native 'string' {}");
3675 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); 3782 await assertErrors(
3676 verify([source]); 3783 source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
3677 } 3784 verify([source]);
3678 3785 }
3679 void test_nativeFunctionBodyInNonSDKCode_function() { 3786
3787 test_nativeFunctionBodyInNonSDKCode_function() async {
3680 // TODO(jwren) Move this test somewhere else: This test verifies a parser 3788 // TODO(jwren) Move this test somewhere else: This test verifies a parser
3681 // error code is generated through the ErrorVerifier, it is not a 3789 // error code is generated through the ErrorVerifier, it is not a
3682 // CompileTimeErrorCode. 3790 // CompileTimeErrorCode.
3683 Source source = addSource("int m(a) native 'string';"); 3791 Source source = addSource("int m(a) native 'string';");
3684 assertErrors( 3792 await assertErrors(
3685 source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); 3793 source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
3686 verify([source]); 3794 verify([source]);
3687 } 3795 }
3688 3796
3689 void test_nativeFunctionBodyInNonSDKCode_method() { 3797 test_nativeFunctionBodyInNonSDKCode_method() async {
3690 // TODO(jwren) Move this test somewhere else: This test verifies a parser 3798 // TODO(jwren) Move this test somewhere else: This test verifies a parser
3691 // error code is generated through the ErrorVerifier, it is not a 3799 // error code is generated through the ErrorVerifier, it is not a
3692 // CompileTimeErrorCode. 3800 // CompileTimeErrorCode.
3693 Source source = addSource(r''' 3801 Source source = addSource(r'''
3694 class A{ 3802 class A{
3695 static int m(a) native 'string'; 3803 static int m(a) native 'string';
3696 }'''); 3804 }''');
3697 assertErrors( 3805 await assertErrors(
3698 source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); 3806 source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
3699 verify([source]); 3807 verify([source]);
3700 } 3808 }
3701 3809
3702 void test_noAnnotationConstructorArguments() { 3810 test_noAnnotationConstructorArguments() async {
3703 Source source = addSource(r''' 3811 Source source = addSource(r'''
3704 class A { 3812 class A {
3705 const A(); 3813 const A();
3706 } 3814 }
3707 @A 3815 @A
3708 main() { 3816 main() {
3709 }'''); 3817 }''');
3710 assertErrors( 3818 await assertErrors(
3711 source, [CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS]); 3819 source, [CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS]);
3712 verify([source]); 3820 verify([source]);
3713 } 3821 }
3714 3822
3715 void test_noDefaultSuperConstructorExplicit() { 3823 test_noDefaultSuperConstructorExplicit() async {
3716 Source source = addSource(r''' 3824 Source source = addSource(r'''
3717 class A { 3825 class A {
3718 A(p); 3826 A(p);
3719 } 3827 }
3720 class B extends A { 3828 class B extends A {
3721 B() {} 3829 B() {}
3722 }'''); 3830 }''');
3723 assertErrors( 3831 await assertErrors(
3724 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]); 3832 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
3725 verify([source]); 3833 verify([source]);
3726 } 3834 }
3727 3835
3728 void test_noDefaultSuperConstructorExplicit_MixinAppWithDirectSuperCall() { 3836 test_noDefaultSuperConstructorExplicit_MixinAppWithDirectSuperCall() async {
3729 Source source = addSource(r''' 3837 Source source = addSource(r'''
3730 class M {} 3838 class M {}
3731 class B { 3839 class B {
3732 B({x}); 3840 B({x});
3733 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS 3841 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS
3734 } 3842 }
3735 class Mixed = B with M; 3843 class Mixed = B with M;
3736 class C extends Mixed { 3844 class C extends Mixed {
3737 C(x) : super(); 3845 C(x) : super();
3738 } 3846 }
3739 '''); 3847 ''');
3740 assertErrors(source, 3848 await assertErrors(source,
3741 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 3849 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
3742 verify([source]); 3850 verify([source]);
3743 } 3851 }
3744 3852
3745 void test_noDefaultSuperConstructorExplicit_mixinAppWithNamedParam() { 3853 test_noDefaultSuperConstructorExplicit_mixinAppWithNamedParam() async {
3746 Source source = addSource(r''' 3854 Source source = addSource(r'''
3747 class M {} 3855 class M {}
3748 class B { 3856 class B {
3749 B({x}); 3857 B({x});
3750 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS 3858 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS
3751 } 3859 }
3752 class Mixed = B with M; 3860 class Mixed = B with M;
3753 class C extends Mixed { 3861 class C extends Mixed {
3754 C(); 3862 C();
3755 } 3863 }
3756 '''); 3864 ''');
3757 assertErrors(source, 3865 await assertErrors(source,
3758 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 3866 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
3759 verify([source]); 3867 verify([source]);
3760 } 3868 }
3761 3869
3762 void test_noDefaultSuperConstructorExplicit_MixinAppWithNamedSuperCall() { 3870 test_noDefaultSuperConstructorExplicit_MixinAppWithNamedSuperCall() async {
3763 Source source = addSource(r''' 3871 Source source = addSource(r'''
3764 class M {} 3872 class M {}
3765 class B { 3873 class B {
3766 B.named({x}); 3874 B.named({x});
3767 B.named2(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS 3875 B.named2(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS
3768 } 3876 }
3769 class Mixed = B with M; 3877 class Mixed = B with M;
3770 class C extends Mixed { 3878 class C extends Mixed {
3771 C(x) : super.named(); 3879 C(x) : super.named();
3772 } 3880 }
3773 '''); 3881 ''');
3774 assertErrors( 3882 await assertErrors(
3775 source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]); 3883 source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
3776 // Don't verify since call to super.named() can't be resolved. 3884 // Don't verify since call to super.named() can't be resolved.
3777 } 3885 }
3778 3886
3779 void test_noDefaultSuperConstructorExplicit_mixinAppWithOptionalParam() { 3887 test_noDefaultSuperConstructorExplicit_mixinAppWithOptionalParam() async {
3780 Source source = addSource(r''' 3888 Source source = addSource(r'''
3781 class M {} 3889 class M {}
3782 class B { 3890 class B {
3783 B([x]); 3891 B([x]);
3784 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS 3892 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS
3785 } 3893 }
3786 class Mixed = B with M; 3894 class Mixed = B with M;
3787 class C extends Mixed { 3895 class C extends Mixed {
3788 C(); 3896 C();
3789 } 3897 }
3790 '''); 3898 ''');
3791 assertErrors(source, 3899 await assertErrors(source,
3792 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 3900 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
3793 verify([source]); 3901 verify([source]);
3794 } 3902 }
3795 3903
3796 void test_noDefaultSuperConstructorExplicit_MixinWithDirectSuperCall() { 3904 test_noDefaultSuperConstructorExplicit_MixinWithDirectSuperCall() async {
3797 Source source = addSource(r''' 3905 Source source = addSource(r'''
3798 class M {} 3906 class M {}
3799 class B { 3907 class B {
3800 B({x}); 3908 B({x});
3801 B.other(); 3909 B.other();
3802 } 3910 }
3803 class C extends B with M { 3911 class C extends B with M {
3804 C(x) : super(); 3912 C(x) : super();
3805 } 3913 }
3806 '''); 3914 ''');
3807 assertErrors(source, 3915 await assertErrors(source,
3808 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 3916 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
3809 verify([source]); 3917 verify([source]);
3810 } 3918 }
3811 3919
3812 void test_noDefaultSuperConstructorExplicit_mixinWithNamedParam() { 3920 test_noDefaultSuperConstructorExplicit_mixinWithNamedParam() async {
3813 Source source = addSource(r''' 3921 Source source = addSource(r'''
3814 class M {} 3922 class M {}
3815 class B { 3923 class B {
3816 B({x}); 3924 B({x});
3817 B.named(); 3925 B.named();
3818 } 3926 }
3819 class C extends B with M { 3927 class C extends B with M {
3820 C(); 3928 C();
3821 } 3929 }
3822 '''); 3930 ''');
3823 assertErrors( 3931 await assertErrors(
3824 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]); 3932 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
3825 verify([source]); 3933 verify([source]);
3826 } 3934 }
3827 3935
3828 void test_noDefaultSuperConstructorExplicit_MixinWithNamedSuperCall() { 3936 test_noDefaultSuperConstructorExplicit_MixinWithNamedSuperCall() async {
3829 Source source = addSource(r''' 3937 Source source = addSource(r'''
3830 class M {} 3938 class M {}
3831 class B { 3939 class B {
3832 B.named({x}); 3940 B.named({x});
3833 B.other(); 3941 B.other();
3834 } 3942 }
3835 class C extends B with M { 3943 class C extends B with M {
3836 C(x) : super.named(); 3944 C(x) : super.named();
3837 } 3945 }
3838 '''); 3946 ''');
3839 assertErrors( 3947 await assertErrors(
3840 source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]); 3948 source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
3841 // Don't verify since call to super.named() can't be resolved. 3949 // Don't verify since call to super.named() can't be resolved.
3842 } 3950 }
3843 3951
3844 void test_noDefaultSuperConstructorExplicit_mixinWithOptionalParam() { 3952 test_noDefaultSuperConstructorExplicit_mixinWithOptionalParam() async {
3845 Source source = addSource(r''' 3953 Source source = addSource(r'''
3846 class M {} 3954 class M {}
3847 class B { 3955 class B {
3848 B([x]); 3956 B([x]);
3849 B.other(); 3957 B.other();
3850 } 3958 }
3851 class C extends B with M { 3959 class C extends B with M {
3852 C(); 3960 C();
3853 } 3961 }
3854 '''); 3962 ''');
3855 assertErrors( 3963 await assertErrors(
3856 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]); 3964 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
3857 verify([source]); 3965 verify([source]);
3858 } 3966 }
3859 3967
3860 void test_noDefaultSuperConstructorImplicit_mixinAppWithNamedParam() { 3968 test_noDefaultSuperConstructorImplicit_mixinAppWithNamedParam() async {
3861 Source source = addSource(r''' 3969 Source source = addSource(r'''
3862 class M {} 3970 class M {}
3863 class B { 3971 class B {
3864 B({x}); 3972 B({x});
3865 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS 3973 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS
3866 } 3974 }
3867 class Mixed = B with M; 3975 class Mixed = B with M;
3868 class C extends Mixed {} 3976 class C extends Mixed {}
3869 '''); 3977 ''');
3870 assertErrors( 3978 await assertErrors(
3871 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 3979 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
3872 verify([source]); 3980 verify([source]);
3873 } 3981 }
3874 3982
3875 void test_noDefaultSuperConstructorImplicit_mixinAppWithOptionalParam() { 3983 test_noDefaultSuperConstructorImplicit_mixinAppWithOptionalParam() async {
3876 Source source = addSource(r''' 3984 Source source = addSource(r'''
3877 class M {} 3985 class M {}
3878 class B { 3986 class B {
3879 B([x]); 3987 B([x]);
3880 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS 3988 B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS
3881 } 3989 }
3882 class Mixed = B with M; 3990 class Mixed = B with M;
3883 class C extends Mixed {} 3991 class C extends Mixed {}
3884 '''); 3992 ''');
3885 assertErrors( 3993 await assertErrors(
3886 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 3994 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
3887 verify([source]); 3995 verify([source]);
3888 } 3996 }
3889 3997
3890 void test_noDefaultSuperConstructorImplicit_mixinWithNamedParam() { 3998 test_noDefaultSuperConstructorImplicit_mixinWithNamedParam() async {
3891 Source source = addSource(r''' 3999 Source source = addSource(r'''
3892 class M {} 4000 class M {}
3893 class B { 4001 class B {
3894 B({x}); 4002 B({x});
3895 B.other(); 4003 B.other();
3896 } 4004 }
3897 class C extends B with M {} 4005 class C extends B with M {}
3898 '''); 4006 ''');
3899 assertErrors( 4007 await assertErrors(
3900 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 4008 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
3901 verify([source]); 4009 verify([source]);
3902 } 4010 }
3903 4011
3904 void test_noDefaultSuperConstructorImplicit_mixinWithOptionalParam() { 4012 test_noDefaultSuperConstructorImplicit_mixinWithOptionalParam() async {
3905 Source source = addSource(r''' 4013 Source source = addSource(r'''
3906 class M {} 4014 class M {}
3907 class B { 4015 class B {
3908 B([x]); 4016 B([x]);
3909 B.other(); 4017 B.other();
3910 } 4018 }
3911 class C extends B with M {} 4019 class C extends B with M {}
3912 '''); 4020 ''');
3913 assertErrors( 4021 await assertErrors(
3914 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 4022 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
3915 verify([source]); 4023 verify([source]);
3916 } 4024 }
3917 4025
3918 void test_noDefaultSuperConstructorImplicit_superHasParameters() { 4026 test_noDefaultSuperConstructorImplicit_superHasParameters() async {
3919 Source source = addSource(r''' 4027 Source source = addSource(r'''
3920 class A { 4028 class A {
3921 A(p); 4029 A(p);
3922 } 4030 }
3923 class B extends A { 4031 class B extends A {
3924 }'''); 4032 }''');
3925 assertErrors( 4033 await assertErrors(
3926 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 4034 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
3927 verify([source]); 4035 verify([source]);
3928 } 4036 }
3929 4037
3930 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() { 4038 test_noDefaultSuperConstructorImplicit_superOnlyNamed() async {
3931 Source source = addSource(r''' 4039 Source source = addSource(r'''
3932 class A { A.named() {} } 4040 class A { A.named() {} }
3933 class B extends A {}'''); 4041 class B extends A {}''');
3934 assertErrors( 4042 await assertErrors(
3935 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 4043 source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
3936 verify([source]); 4044 verify([source]);
3937 } 4045 }
3938 4046
3939 void test_nonConstantAnnotationConstructor_named() { 4047 test_nonConstantAnnotationConstructor_named() async {
3940 Source source = addSource(r''' 4048 Source source = addSource(r'''
3941 class A { 4049 class A {
3942 A.fromInt() {} 4050 A.fromInt() {}
3943 } 4051 }
3944 @A.fromInt() 4052 @A.fromInt()
3945 main() { 4053 main() {
3946 }'''); 4054 }''');
3947 assertErrors( 4055 await assertErrors(
3948 source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]); 4056 source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]);
3949 verify([source]); 4057 verify([source]);
3950 } 4058 }
3951 4059
3952 void test_nonConstantAnnotationConstructor_unnamed() { 4060 test_nonConstantAnnotationConstructor_unnamed() async {
3953 Source source = addSource(r''' 4061 Source source = addSource(r'''
3954 class A { 4062 class A {
3955 A() {} 4063 A() {}
3956 } 4064 }
3957 @A() 4065 @A()
3958 main() { 4066 main() {
3959 }'''); 4067 }''');
3960 assertErrors( 4068 await assertErrors(
3961 source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]); 4069 source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]);
3962 verify([source]); 4070 verify([source]);
3963 } 4071 }
3964 4072
3965 void test_nonConstantDefaultValue_function_named() { 4073 test_nonConstantDefaultValue_function_named() async {
3966 Source source = addSource(r''' 4074 Source source = addSource(r'''
3967 int y; 4075 int y;
3968 f({x : y}) {}'''); 4076 f({x : y}) {}''');
3969 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 4077 await assertErrors(
4078 source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
3970 verify([source]); 4079 verify([source]);
3971 } 4080 }
3972 4081
3973 void test_nonConstantDefaultValue_function_positional() { 4082 test_nonConstantDefaultValue_function_positional() async {
3974 Source source = addSource(r''' 4083 Source source = addSource(r'''
3975 int y; 4084 int y;
3976 f([x = y]) {}'''); 4085 f([x = y]) {}''');
3977 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 4086 await assertErrors(
4087 source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
3978 verify([source]); 4088 verify([source]);
3979 } 4089 }
3980 4090
3981 void test_nonConstantDefaultValue_inConstructor_named() { 4091 test_nonConstantDefaultValue_inConstructor_named() async {
3982 Source source = addSource(r''' 4092 Source source = addSource(r'''
3983 class A { 4093 class A {
3984 int y; 4094 int y;
3985 A({x : y}) {} 4095 A({x : y}) {}
3986 }'''); 4096 }''');
3987 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 4097 await assertErrors(
4098 source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
3988 verify([source]); 4099 verify([source]);
3989 } 4100 }
3990 4101
3991 void test_nonConstantDefaultValue_inConstructor_positional() { 4102 test_nonConstantDefaultValue_inConstructor_positional() async {
3992 Source source = addSource(r''' 4103 Source source = addSource(r'''
3993 class A { 4104 class A {
3994 int y; 4105 int y;
3995 A([x = y]) {} 4106 A([x = y]) {}
3996 }'''); 4107 }''');
3997 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 4108 await assertErrors(
4109 source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
3998 verify([source]); 4110 verify([source]);
3999 } 4111 }
4000 4112
4001 void test_nonConstantDefaultValue_method_named() { 4113 test_nonConstantDefaultValue_method_named() async {
4002 Source source = addSource(r''' 4114 Source source = addSource(r'''
4003 class A { 4115 class A {
4004 int y; 4116 int y;
4005 m({x : y}) {} 4117 m({x : y}) {}
4006 }'''); 4118 }''');
4007 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 4119 await assertErrors(
4120 source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
4008 verify([source]); 4121 verify([source]);
4009 } 4122 }
4010 4123
4011 void test_nonConstantDefaultValue_method_positional() { 4124 test_nonConstantDefaultValue_method_positional() async {
4012 Source source = addSource(r''' 4125 Source source = addSource(r'''
4013 class A { 4126 class A {
4014 int y; 4127 int y;
4015 m([x = y]) {} 4128 m([x = y]) {}
4016 }'''); 4129 }''');
4017 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 4130 await assertErrors(
4131 source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
4018 verify([source]); 4132 verify([source]);
4019 } 4133 }
4020 4134
4021 void test_nonConstantDefaultValueFromDeferredLibrary() { 4135 test_nonConstantDefaultValueFromDeferredLibrary() async {
4022 resolveWithErrors(<String>[ 4136 await resolveWithErrors(<String>[
4023 r''' 4137 r'''
4024 library lib1; 4138 library lib1;
4025 const V = 1;''', 4139 const V = 1;''',
4026 r''' 4140 r'''
4027 library root; 4141 library root;
4028 import 'lib1.dart' deferred as a; 4142 import 'lib1.dart' deferred as a;
4029 f({x : a.V}) {}''' 4143 f({x : a.V}) {}'''
4030 ], <ErrorCode>[ 4144 ], <ErrorCode>[
4031 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY 4145 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY
4032 ]); 4146 ]);
4033 } 4147 }
4034 4148
4035 void test_nonConstantDefaultValueFromDeferredLibrary_nested() { 4149 test_nonConstantDefaultValueFromDeferredLibrary_nested() async {
4036 resolveWithErrors(<String>[ 4150 await resolveWithErrors(<String>[
4037 r''' 4151 r'''
4038 library lib1; 4152 library lib1;
4039 const V = 1;''', 4153 const V = 1;''',
4040 r''' 4154 r'''
4041 library root; 4155 library root;
4042 import 'lib1.dart' deferred as a; 4156 import 'lib1.dart' deferred as a;
4043 f({x : a.V + 1}) {}''' 4157 f({x : a.V + 1}) {}'''
4044 ], <ErrorCode>[ 4158 ], <ErrorCode>[
4045 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY 4159 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY
4046 ]); 4160 ]);
4047 } 4161 }
4048 4162
4049 void test_nonConstCaseExpression() { 4163 test_nonConstCaseExpression() async {
4050 Source source = addSource(r''' 4164 Source source = addSource(r'''
4051 f(int p, int q) { 4165 f(int p, int q) {
4052 switch (p) { 4166 switch (p) {
4053 case 3 + q: 4167 case 3 + q:
4054 break; 4168 break;
4055 } 4169 }
4056 }'''); 4170 }''');
4057 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); 4171 await assertErrors(
4172 source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]);
4058 verify([source]); 4173 verify([source]);
4059 } 4174 }
4060 4175
4061 void test_nonConstCaseExpressionFromDeferredLibrary() { 4176 test_nonConstCaseExpressionFromDeferredLibrary() async {
4062 resolveWithErrors(<String>[ 4177 await resolveWithErrors(<String>[
4063 r''' 4178 r'''
4064 library lib1; 4179 library lib1;
4065 const int c = 1;''', 4180 const int c = 1;''',
4066 r''' 4181 r'''
4067 library root; 4182 library root;
4068 import 'lib1.dart' deferred as a; 4183 import 'lib1.dart' deferred as a;
4069 main (int p) { 4184 main (int p) {
4070 switch (p) { 4185 switch (p) {
4071 case a.c: 4186 case a.c:
4072 break; 4187 break;
4073 } 4188 }
4074 }''' 4189 }'''
4075 ], <ErrorCode>[ 4190 ], <ErrorCode>[
4076 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY 4191 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY
4077 ]); 4192 ]);
4078 } 4193 }
4079 4194
4080 void test_nonConstCaseExpressionFromDeferredLibrary_nested() { 4195 test_nonConstCaseExpressionFromDeferredLibrary_nested() async {
4081 resolveWithErrors(<String>[ 4196 await resolveWithErrors(<String>[
4082 r''' 4197 r'''
4083 library lib1; 4198 library lib1;
4084 const int c = 1;''', 4199 const int c = 1;''',
4085 r''' 4200 r'''
4086 library root; 4201 library root;
4087 import 'lib1.dart' deferred as a; 4202 import 'lib1.dart' deferred as a;
4088 main (int p) { 4203 main (int p) {
4089 switch (p) { 4204 switch (p) {
4090 case a.c + 1: 4205 case a.c + 1:
4091 break; 4206 break;
4092 } 4207 }
4093 }''' 4208 }'''
4094 ], <ErrorCode>[ 4209 ], <ErrorCode>[
4095 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY 4210 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY
4096 ]); 4211 ]);
4097 } 4212 }
4098 4213
4099 void test_nonConstListElement() { 4214 test_nonConstListElement() async {
4100 Source source = addSource(r''' 4215 Source source = addSource(r'''
4101 f(a) { 4216 f(a) {
4102 return const [a]; 4217 return const [a];
4103 }'''); 4218 }''');
4104 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); 4219 await assertErrors(
4220 source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
4105 verify([source]); 4221 verify([source]);
4106 } 4222 }
4107 4223
4108 void test_nonConstListElementFromDeferredLibrary() { 4224 test_nonConstListElementFromDeferredLibrary() async {
4109 resolveWithErrors(<String>[ 4225 await resolveWithErrors(<String>[
4110 r''' 4226 r'''
4111 library lib1; 4227 library lib1;
4112 const int c = 1;''', 4228 const int c = 1;''',
4113 r''' 4229 r'''
4114 library root; 4230 library root;
4115 import 'lib1.dart' deferred as a; 4231 import 'lib1.dart' deferred as a;
4116 f() { 4232 f() {
4117 return const [a.c]; 4233 return const [a.c];
4118 }''' 4234 }'''
4119 ], <ErrorCode>[ 4235 ], <ErrorCode>[
4120 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY 4236 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
4121 ]); 4237 ]);
4122 } 4238 }
4123 4239
4124 void test_nonConstListElementFromDeferredLibrary_nested() { 4240 test_nonConstListElementFromDeferredLibrary_nested() async {
4125 resolveWithErrors(<String>[ 4241 await resolveWithErrors(<String>[
4126 r''' 4242 r'''
4127 library lib1; 4243 library lib1;
4128 const int c = 1;''', 4244 const int c = 1;''',
4129 r''' 4245 r'''
4130 library root; 4246 library root;
4131 import 'lib1.dart' deferred as a; 4247 import 'lib1.dart' deferred as a;
4132 f() { 4248 f() {
4133 return const [a.c + 1]; 4249 return const [a.c + 1];
4134 }''' 4250 }'''
4135 ], <ErrorCode>[ 4251 ], <ErrorCode>[
4136 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY 4252 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
4137 ]); 4253 ]);
4138 } 4254 }
4139 4255
4140 void test_nonConstMapAsExpressionStatement_begin() { 4256 test_nonConstMapAsExpressionStatement_begin() async {
4141 Source source = addSource(r''' 4257 Source source = addSource(r'''
4142 f() { 4258 f() {
4143 {'a' : 0, 'b' : 1}.length; 4259 {'a' : 0, 'b' : 1}.length;
4144 }'''); 4260 }''');
4145 assertErrors( 4261 await assertErrors(
4146 source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]); 4262 source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
4147 verify([source]); 4263 verify([source]);
4148 } 4264 }
4149 4265
4150 void test_nonConstMapAsExpressionStatement_only() { 4266 test_nonConstMapAsExpressionStatement_only() async {
4151 Source source = addSource(r''' 4267 Source source = addSource(r'''
4152 f() { 4268 f() {
4153 {'a' : 0, 'b' : 1}; 4269 {'a' : 0, 'b' : 1};
4154 }'''); 4270 }''');
4155 assertErrors( 4271 await assertErrors(
4156 source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]); 4272 source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
4157 verify([source]); 4273 verify([source]);
4158 } 4274 }
4159 4275
4160 void test_nonConstMapKey() { 4276 test_nonConstMapKey() async {
4161 Source source = addSource(r''' 4277 Source source = addSource(r'''
4162 f(a) { 4278 f(a) {
4163 return const {a : 0}; 4279 return const {a : 0};
4164 }'''); 4280 }''');
4165 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]); 4281 await assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
4166 verify([source]); 4282 verify([source]);
4167 } 4283 }
4168 4284
4169 void test_nonConstMapKeyFromDeferredLibrary() { 4285 test_nonConstMapKeyFromDeferredLibrary() async {
4170 resolveWithErrors(<String>[ 4286 await resolveWithErrors(<String>[
4171 r''' 4287 r'''
4172 library lib1; 4288 library lib1;
4173 const int c = 1;''', 4289 const int c = 1;''',
4174 r''' 4290 r'''
4175 library root; 4291 library root;
4176 import 'lib1.dart' deferred as a; 4292 import 'lib1.dart' deferred as a;
4177 f() { 4293 f() {
4178 return const {a.c : 0}; 4294 return const {a.c : 0};
4179 }''' 4295 }'''
4180 ], <ErrorCode>[ 4296 ], <ErrorCode>[
4181 CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY 4297 CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY
4182 ]); 4298 ]);
4183 } 4299 }
4184 4300
4185 void test_nonConstMapKeyFromDeferredLibrary_nested() { 4301 test_nonConstMapKeyFromDeferredLibrary_nested() async {
4186 resolveWithErrors(<String>[ 4302 await resolveWithErrors(<String>[
4187 r''' 4303 r'''
4188 library lib1; 4304 library lib1;
4189 const int c = 1;''', 4305 const int c = 1;''',
4190 r''' 4306 r'''
4191 library root; 4307 library root;
4192 import 'lib1.dart' deferred as a; 4308 import 'lib1.dart' deferred as a;
4193 f() { 4309 f() {
4194 return const {a.c + 1 : 0}; 4310 return const {a.c + 1 : 0};
4195 }''' 4311 }'''
4196 ], <ErrorCode>[ 4312 ], <ErrorCode>[
4197 CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY 4313 CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY
4198 ]); 4314 ]);
4199 } 4315 }
4200 4316
4201 void test_nonConstMapValue() { 4317 test_nonConstMapValue() async {
4202 Source source = addSource(r''' 4318 Source source = addSource(r'''
4203 f(a) { 4319 f(a) {
4204 return const {'a' : a}; 4320 return const {'a' : a};
4205 }'''); 4321 }''');
4206 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); 4322 await assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
4207 verify([source]); 4323 verify([source]);
4208 } 4324 }
4209 4325
4210 void test_nonConstMapValueFromDeferredLibrary() { 4326 test_nonConstMapValueFromDeferredLibrary() async {
4211 resolveWithErrors(<String>[ 4327 await resolveWithErrors(<String>[
4212 r''' 4328 r'''
4213 library lib1; 4329 library lib1;
4214 const int c = 1;''', 4330 const int c = 1;''',
4215 r''' 4331 r'''
4216 library root; 4332 library root;
4217 import 'lib1.dart' deferred as a; 4333 import 'lib1.dart' deferred as a;
4218 f() { 4334 f() {
4219 return const {'a' : a.c}; 4335 return const {'a' : a.c};
4220 }''' 4336 }'''
4221 ], <ErrorCode>[ 4337 ], <ErrorCode>[
4222 CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY 4338 CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY
4223 ]); 4339 ]);
4224 } 4340 }
4225 4341
4226 void test_nonConstMapValueFromDeferredLibrary_nested() { 4342 test_nonConstMapValueFromDeferredLibrary_nested() async {
4227 resolveWithErrors(<String>[ 4343 await resolveWithErrors(<String>[
4228 r''' 4344 r'''
4229 library lib1; 4345 library lib1;
4230 const int c = 1;''', 4346 const int c = 1;''',
4231 r''' 4347 r'''
4232 library root; 4348 library root;
4233 import 'lib1.dart' deferred as a; 4349 import 'lib1.dart' deferred as a;
4234 f() { 4350 f() {
4235 return const {'a' : a.c + 1}; 4351 return const {'a' : a.c + 1};
4236 }''' 4352 }'''
4237 ], <ErrorCode>[ 4353 ], <ErrorCode>[
4238 CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY 4354 CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY
4239 ]); 4355 ]);
4240 } 4356 }
4241 4357
4242 void test_nonConstValueInInitializer_assert_condition() { 4358 test_nonConstValueInInitializer_assert_condition() async {
4243 resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true); 4359 resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true);
4244 Source source = addSource(r''' 4360 Source source = addSource(r'''
4245 class A { 4361 class A {
4246 const A(int i) : assert(i.isNegative); 4362 const A(int i) : assert(i.isNegative);
4247 }'''); 4363 }''');
4248 assertErrors( 4364 await assertErrors(
4249 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); 4365 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4250 verify([source]); 4366 verify([source]);
4251 } 4367 }
4252 4368
4253 void test_nonConstValueInInitializer_assert_message() { 4369 test_nonConstValueInInitializer_assert_message() async {
4254 resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true); 4370 resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true);
4255 Source source = addSource(r''' 4371 Source source = addSource(r'''
4256 class A { 4372 class A {
4257 const A(int i) : assert(i < 0, 'isNegative = ${i.isNegative}'); 4373 const A(int i) : assert(i < 0, 'isNegative = ${i.isNegative}');
4258 }'''); 4374 }''');
4259 assertErrors( 4375 await assertErrors(
4260 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); 4376 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4261 verify([source]); 4377 verify([source]);
4262 } 4378 }
4263 4379
4264 void test_nonConstValueInInitializer_binary_notBool_left() { 4380 test_nonConstValueInInitializer_binary_notBool_left() async {
4265 Source source = addSource(r''' 4381 Source source = addSource(r'''
4266 class A { 4382 class A {
4267 final bool a; 4383 final bool a;
4268 const A(String p) : a = p && true; 4384 const A(String p) : a = p && true;
4269 }'''); 4385 }''');
4270 assertErrors(source, [ 4386 await assertErrors(source, [
4271 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, 4387 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
4272 StaticTypeWarningCode.NON_BOOL_OPERAND 4388 StaticTypeWarningCode.NON_BOOL_OPERAND
4273 ]); 4389 ]);
4274 verify([source]); 4390 verify([source]);
4275 } 4391 }
4276 4392
4277 void test_nonConstValueInInitializer_binary_notBool_right() { 4393 test_nonConstValueInInitializer_binary_notBool_right() async {
4278 Source source = addSource(r''' 4394 Source source = addSource(r'''
4279 class A { 4395 class A {
4280 final bool a; 4396 final bool a;
4281 const A(String p) : a = true && p; 4397 const A(String p) : a = true && p;
4282 }'''); 4398 }''');
4283 assertErrors(source, [ 4399 await assertErrors(source, [
4284 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, 4400 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
4285 StaticTypeWarningCode.NON_BOOL_OPERAND 4401 StaticTypeWarningCode.NON_BOOL_OPERAND
4286 ]); 4402 ]);
4287 verify([source]); 4403 verify([source]);
4288 } 4404 }
4289 4405
4290 void test_nonConstValueInInitializer_binary_notInt() { 4406 test_nonConstValueInInitializer_binary_notInt() async {
4291 Source source = addSource(r''' 4407 Source source = addSource(r'''
4292 class A { 4408 class A {
4293 final int a; 4409 final int a;
4294 const A(String p) : a = 5 & p; 4410 const A(String p) : a = 5 & p;
4295 }'''); 4411 }''');
4296 assertErrors(source, [ 4412 await assertErrors(source, [
4297 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, 4413 CompileTimeErrorCode.CONST_EVAL_TYPE_INT,
4298 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE 4414 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
4299 ]); 4415 ]);
4300 verify([source]); 4416 verify([source]);
4301 } 4417 }
4302 4418
4303 void test_nonConstValueInInitializer_binary_notNum() { 4419 test_nonConstValueInInitializer_binary_notNum() async {
4304 Source source = addSource(r''' 4420 Source source = addSource(r'''
4305 class A { 4421 class A {
4306 final int a; 4422 final int a;
4307 const A(String p) : a = 5 + p; 4423 const A(String p) : a = 5 + p;
4308 }'''); 4424 }''');
4309 assertErrors(source, [ 4425 await assertErrors(source, [
4310 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, 4426 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM,
4311 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE 4427 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
4312 ]); 4428 ]);
4313 verify([source]); 4429 verify([source]);
4314 } 4430 }
4315 4431
4316 void test_nonConstValueInInitializer_field() { 4432 test_nonConstValueInInitializer_field() async {
4317 Source source = addSource(r''' 4433 Source source = addSource(r'''
4318 class A { 4434 class A {
4319 static int C; 4435 static int C;
4320 final int a; 4436 final int a;
4321 const A() : a = C; 4437 const A() : a = C;
4322 }'''); 4438 }''');
4323 assertErrors( 4439 await assertErrors(
4324 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); 4440 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4325 verify([source]); 4441 verify([source]);
4326 } 4442 }
4327 4443
4328 void test_nonConstValueInInitializer_instanceCreation() { 4444 test_nonConstValueInInitializer_instanceCreation() async {
4329 Source source = addSource(r''' 4445 Source source = addSource(r'''
4330 class A { 4446 class A {
4331 A(); 4447 A();
4332 } 4448 }
4333 class B { 4449 class B {
4334 const B() : a = new A(); 4450 const B() : a = new A();
4335 final a; 4451 final a;
4336 } 4452 }
4337 var b = const B();'''); 4453 var b = const B();''');
4338 // TODO(paulberry): the error INVALID_CONSTAT is redundant and ought to be 4454 // TODO(paulberry): the error INVALID_CONSTAT is redundant and ought to be
4339 // suppressed. 4455 // suppressed.
4340 assertErrors(source, [ 4456 await assertErrors(source, [
4341 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, 4457 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER,
4342 CompileTimeErrorCode.INVALID_CONSTANT 4458 CompileTimeErrorCode.INVALID_CONSTANT
4343 ]); 4459 ]);
4344 verify([source]); 4460 verify([source]);
4345 } 4461 }
4346 4462
4347 void test_nonConstValueInInitializer_redirecting() { 4463 test_nonConstValueInInitializer_redirecting() async {
4348 Source source = addSource(r''' 4464 Source source = addSource(r'''
4349 class A { 4465 class A {
4350 static var C; 4466 static var C;
4351 const A.named(p); 4467 const A.named(p);
4352 const A() : this.named(C); 4468 const A() : this.named(C);
4353 }'''); 4469 }''');
4354 assertErrors( 4470 await assertErrors(
4355 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); 4471 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4356 verify([source]); 4472 verify([source]);
4357 } 4473 }
4358 4474
4359 void test_nonConstValueInInitializer_super() { 4475 test_nonConstValueInInitializer_super() async {
4360 Source source = addSource(r''' 4476 Source source = addSource(r'''
4361 class A { 4477 class A {
4362 const A(p); 4478 const A(p);
4363 } 4479 }
4364 class B extends A { 4480 class B extends A {
4365 static var C; 4481 static var C;
4366 const B() : super(C); 4482 const B() : super(C);
4367 }'''); 4483 }''');
4368 assertErrors( 4484 await assertErrors(
4369 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); 4485 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4370 verify([source]); 4486 verify([source]);
4371 } 4487 }
4372 4488
4373 void test_nonConstValueInInitializerFromDeferredLibrary_field() { 4489 test_nonConstValueInInitializerFromDeferredLibrary_field() async {
4374 resolveWithErrors(<String>[ 4490 await resolveWithErrors(<String>[
4375 r''' 4491 r'''
4376 library lib1; 4492 library lib1;
4377 const int c = 1;''', 4493 const int c = 1;''',
4378 r''' 4494 r'''
4379 library root; 4495 library root;
4380 import 'lib1.dart' deferred as a; 4496 import 'lib1.dart' deferred as a;
4381 class A { 4497 class A {
4382 final int x; 4498 final int x;
4383 const A() : x = a.c; 4499 const A() : x = a.c;
4384 }''' 4500 }'''
4385 ], <ErrorCode>[ 4501 ], <ErrorCode>[
4386 CompileTimeErrorCode 4502 CompileTimeErrorCode
4387 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY 4503 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
4388 ]); 4504 ]);
4389 } 4505 }
4390 4506
4391 void test_nonConstValueInInitializerFromDeferredLibrary_field_nested() { 4507 test_nonConstValueInInitializerFromDeferredLibrary_field_nested() async {
4392 resolveWithErrors(<String>[ 4508 await resolveWithErrors(<String>[
4393 r''' 4509 r'''
4394 library lib1; 4510 library lib1;
4395 const int c = 1;''', 4511 const int c = 1;''',
4396 r''' 4512 r'''
4397 library root; 4513 library root;
4398 import 'lib1.dart' deferred as a; 4514 import 'lib1.dart' deferred as a;
4399 class A { 4515 class A {
4400 final int x; 4516 final int x;
4401 const A() : x = a.c + 1; 4517 const A() : x = a.c + 1;
4402 }''' 4518 }'''
4403 ], <ErrorCode>[ 4519 ], <ErrorCode>[
4404 CompileTimeErrorCode 4520 CompileTimeErrorCode
4405 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY 4521 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
4406 ]); 4522 ]);
4407 } 4523 }
4408 4524
4409 void test_nonConstValueInInitializerFromDeferredLibrary_redirecting() { 4525 test_nonConstValueInInitializerFromDeferredLibrary_redirecting() async {
4410 resolveWithErrors(<String>[ 4526 await resolveWithErrors(<String>[
4411 r''' 4527 r'''
4412 library lib1; 4528 library lib1;
4413 const int c = 1;''', 4529 const int c = 1;''',
4414 r''' 4530 r'''
4415 library root; 4531 library root;
4416 import 'lib1.dart' deferred as a; 4532 import 'lib1.dart' deferred as a;
4417 class A { 4533 class A {
4418 const A.named(p); 4534 const A.named(p);
4419 const A() : this.named(a.c); 4535 const A() : this.named(a.c);
4420 }''' 4536 }'''
4421 ], <ErrorCode>[ 4537 ], <ErrorCode>[
4422 CompileTimeErrorCode 4538 CompileTimeErrorCode
4423 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY 4539 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
4424 ]); 4540 ]);
4425 } 4541 }
4426 4542
4427 void test_nonConstValueInInitializerFromDeferredLibrary_super() { 4543 test_nonConstValueInInitializerFromDeferredLibrary_super() async {
4428 resolveWithErrors(<String>[ 4544 await resolveWithErrors(<String>[
4429 r''' 4545 r'''
4430 library lib1; 4546 library lib1;
4431 const int c = 1;''', 4547 const int c = 1;''',
4432 r''' 4548 r'''
4433 library root; 4549 library root;
4434 import 'lib1.dart' deferred as a; 4550 import 'lib1.dart' deferred as a;
4435 class A { 4551 class A {
4436 const A(p); 4552 const A(p);
4437 } 4553 }
4438 class B extends A { 4554 class B extends A {
4439 const B() : super(a.c); 4555 const B() : super(a.c);
4440 }''' 4556 }'''
4441 ], <ErrorCode>[ 4557 ], <ErrorCode>[
4442 CompileTimeErrorCode 4558 CompileTimeErrorCode
4443 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY 4559 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
4444 ]); 4560 ]);
4445 } 4561 }
4446 4562
4447 void test_nonGenerativeConstructor_explicit() { 4563 test_nonGenerativeConstructor_explicit() async {
4448 Source source = addSource(r''' 4564 Source source = addSource(r'''
4449 class A { 4565 class A {
4450 factory A.named() => null; 4566 factory A.named() => null;
4451 } 4567 }
4452 class B extends A { 4568 class B extends A {
4453 B() : super.named(); 4569 B() : super.named();
4454 }'''); 4570 }''');
4455 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 4571 await assertErrors(
4572 source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
4456 verify([source]); 4573 verify([source]);
4457 } 4574 }
4458 4575
4459 void test_nonGenerativeConstructor_implicit() { 4576 test_nonGenerativeConstructor_implicit() async {
4460 Source source = addSource(r''' 4577 Source source = addSource(r'''
4461 class A { 4578 class A {
4462 factory A() => null; 4579 factory A() => null;
4463 } 4580 }
4464 class B extends A { 4581 class B extends A {
4465 B(); 4582 B();
4466 }'''); 4583 }''');
4467 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 4584 await assertErrors(
4585 source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
4468 verify([source]); 4586 verify([source]);
4469 } 4587 }
4470 4588
4471 void test_nonGenerativeConstructor_implicit2() { 4589 test_nonGenerativeConstructor_implicit2() async {
4472 Source source = addSource(r''' 4590 Source source = addSource(r'''
4473 class A { 4591 class A {
4474 factory A() => null; 4592 factory A() => null;
4475 } 4593 }
4476 class B extends A { 4594 class B extends A {
4477 }'''); 4595 }''');
4478 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 4596 await assertErrors(
4597 source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
4479 verify([source]); 4598 verify([source]);
4480 } 4599 }
4481 4600
4482 void test_notEnoughRequiredArguments_const() { 4601 test_notEnoughRequiredArguments_const() async {
4483 Source source = addSource(r''' 4602 Source source = addSource(r'''
4484 class A { 4603 class A {
4485 const A(int p); 4604 const A(int p);
4486 } 4605 }
4487 main() { 4606 main() {
4488 const A(); 4607 const A();
4489 }'''); 4608 }''');
4490 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); 4609 await assertErrors(
4610 source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
4491 verify([source]); 4611 verify([source]);
4492 } 4612 }
4493 4613
4494 void test_notEnoughRequiredArguments_const_super() { 4614 test_notEnoughRequiredArguments_const_super() async {
4495 Source source = addSource(r''' 4615 Source source = addSource(r'''
4496 class A { 4616 class A {
4497 const A(int p); 4617 const A(int p);
4498 } 4618 }
4499 class B extends A { 4619 class B extends A {
4500 const B() : super(); 4620 const B() : super();
4501 }'''); 4621 }''');
4502 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); 4622 await assertErrors(
4623 source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
4503 verify([source]); 4624 verify([source]);
4504 } 4625 }
4505 4626
4506 void test_optionalParameterInOperator_named() { 4627 test_optionalParameterInOperator_named() async {
4507 Source source = addSource(r''' 4628 Source source = addSource(r'''
4508 class A { 4629 class A {
4509 operator +({p}) {} 4630 operator +({p}) {}
4510 }'''); 4631 }''');
4511 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); 4632 await assertErrors(
4633 source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
4512 verify([source]); 4634 verify([source]);
4513 } 4635 }
4514 4636
4515 void test_optionalParameterInOperator_positional() { 4637 test_optionalParameterInOperator_positional() async {
4516 Source source = addSource(r''' 4638 Source source = addSource(r'''
4517 class A { 4639 class A {
4518 operator +([p]) {} 4640 operator +([p]) {}
4519 }'''); 4641 }''');
4520 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); 4642 await assertErrors(
4643 source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
4521 verify([source]); 4644 verify([source]);
4522 } 4645 }
4523 4646
4524 void test_partOfNonPart() { 4647 test_partOfNonPart() async {
4525 Source source = addSource(r''' 4648 Source source = addSource(r'''
4526 library l1; 4649 library l1;
4527 part 'l2.dart';'''); 4650 part 'l2.dart';''');
4528 addNamedSource("/l2.dart", "library l2;"); 4651 addNamedSource("/l2.dart", "library l2;");
4529 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); 4652 await assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]);
4530 verify([source]); 4653 verify([source]);
4531 } 4654 }
4532 4655
4533 void test_partOfNonPart_self() { 4656 test_partOfNonPart_self() async {
4534 Source source = addSource(r''' 4657 Source source = addSource(r'''
4535 library lib; 4658 library lib;
4536 part 'test.dart';'''); 4659 part 'test.dart';''');
4537 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); 4660 await assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]);
4538 verify([source]); 4661 verify([source]);
4539 } 4662 }
4540 4663
4541 void test_prefix_assignment_compound_in_method() { 4664 test_prefix_assignment_compound_in_method() async {
4542 addNamedSource('/lib.dart', 'library lib;'); 4665 addNamedSource('/lib.dart', 'library lib;');
4543 Source source = addSource(''' 4666 Source source = addSource('''
4544 import 'lib.dart' as p; 4667 import 'lib.dart' as p;
4545 class C { 4668 class C {
4546 f() { 4669 f() {
4547 p += 1; 4670 p += 1;
4548 } 4671 }
4549 } 4672 }
4550 '''); 4673 ''');
4551 assertErrors( 4674 await assertErrors(
4552 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4675 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4553 verify([source]); 4676 verify([source]);
4554 } 4677 }
4555 4678
4556 void test_prefix_assignment_compound_not_in_method() { 4679 test_prefix_assignment_compound_not_in_method() async {
4557 addNamedSource('/lib.dart', 'library lib;'); 4680 addNamedSource('/lib.dart', 'library lib;');
4558 Source source = addSource(''' 4681 Source source = addSource('''
4559 import 'lib.dart' as p; 4682 import 'lib.dart' as p;
4560 f() { 4683 f() {
4561 p += 1; 4684 p += 1;
4562 } 4685 }
4563 '''); 4686 ''');
4564 assertErrors( 4687 await assertErrors(
4565 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4688 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4566 verify([source]); 4689 verify([source]);
4567 } 4690 }
4568 4691
4569 void test_prefix_assignment_in_method() { 4692 test_prefix_assignment_in_method() async {
4570 addNamedSource('/lib.dart', 'library lib;'); 4693 addNamedSource('/lib.dart', 'library lib;');
4571 Source source = addSource(''' 4694 Source source = addSource('''
4572 import 'lib.dart' as p; 4695 import 'lib.dart' as p;
4573 class C { 4696 class C {
4574 f() { 4697 f() {
4575 p = 1; 4698 p = 1;
4576 } 4699 }
4577 } 4700 }
4578 '''); 4701 ''');
4579 assertErrors( 4702 await assertErrors(
4580 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4703 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4581 verify([source]); 4704 verify([source]);
4582 } 4705 }
4583 4706
4584 void test_prefix_assignment_not_in_method() { 4707 test_prefix_assignment_not_in_method() async {
4585 addNamedSource('/lib.dart', 'library lib;'); 4708 addNamedSource('/lib.dart', 'library lib;');
4586 Source source = addSource(''' 4709 Source source = addSource('''
4587 import 'lib.dart' as p; 4710 import 'lib.dart' as p;
4588 f() { 4711 f() {
4589 p = 1; 4712 p = 1;
4590 } 4713 }
4591 '''); 4714 ''');
4592 assertErrors( 4715 await assertErrors(
4593 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4716 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4594 verify([source]); 4717 verify([source]);
4595 } 4718 }
4596 4719
4597 void test_prefix_conditionalPropertyAccess_call() { 4720 test_prefix_conditionalPropertyAccess_call() async {
4598 addNamedSource( 4721 addNamedSource(
4599 '/lib.dart', 4722 '/lib.dart',
4600 ''' 4723 '''
4601 library lib; 4724 library lib;
4602 g() {} 4725 g() {}
4603 '''); 4726 ''');
4604 Source source = addSource(''' 4727 Source source = addSource('''
4605 import 'lib.dart' as p; 4728 import 'lib.dart' as p;
4606 f() { 4729 f() {
4607 p?.g(); 4730 p?.g();
4608 } 4731 }
4609 '''); 4732 ''');
4610 assertErrors( 4733 await assertErrors(
4611 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4734 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4612 verify([source]); 4735 verify([source]);
4613 } 4736 }
4614 4737
4615 void test_prefix_conditionalPropertyAccess_call_loadLibrary() { 4738 test_prefix_conditionalPropertyAccess_call_loadLibrary() async {
4616 addNamedSource( 4739 addNamedSource(
4617 '/lib.dart', 4740 '/lib.dart',
4618 ''' 4741 '''
4619 library lib; 4742 library lib;
4620 '''); 4743 ''');
4621 Source source = addSource(''' 4744 Source source = addSource('''
4622 import 'lib.dart' deferred as p; 4745 import 'lib.dart' deferred as p;
4623 f() { 4746 f() {
4624 p?.loadLibrary(); 4747 p?.loadLibrary();
4625 } 4748 }
4626 '''); 4749 ''');
4627 assertErrors( 4750 await assertErrors(
4628 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4751 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4629 verify([source]); 4752 verify([source]);
4630 } 4753 }
4631 4754
4632 void test_prefix_conditionalPropertyAccess_get() { 4755 test_prefix_conditionalPropertyAccess_get() async {
4633 addNamedSource( 4756 addNamedSource(
4634 '/lib.dart', 4757 '/lib.dart',
4635 ''' 4758 '''
4636 library lib; 4759 library lib;
4637 var x; 4760 var x;
4638 '''); 4761 ''');
4639 Source source = addSource(''' 4762 Source source = addSource('''
4640 import 'lib.dart' as p; 4763 import 'lib.dart' as p;
4641 f() { 4764 f() {
4642 return p?.x; 4765 return p?.x;
4643 } 4766 }
4644 '''); 4767 ''');
4645 assertErrors( 4768 await assertErrors(
4646 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4769 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4647 verify([source]); 4770 verify([source]);
4648 } 4771 }
4649 4772
4650 void test_prefix_conditionalPropertyAccess_get_loadLibrary() { 4773 test_prefix_conditionalPropertyAccess_get_loadLibrary() async {
4651 addNamedSource( 4774 addNamedSource(
4652 '/lib.dart', 4775 '/lib.dart',
4653 ''' 4776 '''
4654 library lib; 4777 library lib;
4655 '''); 4778 ''');
4656 Source source = addSource(''' 4779 Source source = addSource('''
4657 import 'lib.dart' deferred as p; 4780 import 'lib.dart' deferred as p;
4658 f() { 4781 f() {
4659 return p?.loadLibrary; 4782 return p?.loadLibrary;
4660 } 4783 }
4661 '''); 4784 ''');
4662 assertErrors( 4785 await assertErrors(
4663 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4786 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4664 verify([source]); 4787 verify([source]);
4665 } 4788 }
4666 4789
4667 void test_prefix_conditionalPropertyAccess_set() { 4790 test_prefix_conditionalPropertyAccess_set() async {
4668 addNamedSource( 4791 addNamedSource(
4669 '/lib.dart', 4792 '/lib.dart',
4670 ''' 4793 '''
4671 library lib; 4794 library lib;
4672 var x; 4795 var x;
4673 '''); 4796 ''');
4674 Source source = addSource(''' 4797 Source source = addSource('''
4675 import 'lib.dart' as p; 4798 import 'lib.dart' as p;
4676 f() { 4799 f() {
4677 p?.x = null; 4800 p?.x = null;
4678 } 4801 }
4679 '''); 4802 ''');
4680 assertErrors( 4803 await assertErrors(
4681 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4804 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4682 verify([source]); 4805 verify([source]);
4683 } 4806 }
4684 4807
4685 void test_prefix_conditionalPropertyAccess_set_loadLibrary() { 4808 test_prefix_conditionalPropertyAccess_set_loadLibrary() async {
4686 addNamedSource( 4809 addNamedSource(
4687 '/lib.dart', 4810 '/lib.dart',
4688 ''' 4811 '''
4689 library lib; 4812 library lib;
4690 '''); 4813 ''');
4691 Source source = addSource(''' 4814 Source source = addSource('''
4692 import 'lib.dart' deferred as p; 4815 import 'lib.dart' deferred as p;
4693 f() { 4816 f() {
4694 p?.loadLibrary = null; 4817 p?.loadLibrary = null;
4695 } 4818 }
4696 '''); 4819 ''');
4697 assertErrors( 4820 await assertErrors(
4698 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4821 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4699 verify([source]); 4822 verify([source]);
4700 } 4823 }
4701 4824
4702 void test_prefix_unqualified_invocation_in_method() { 4825 test_prefix_unqualified_invocation_in_method() async {
4703 addNamedSource('/lib.dart', 'librarylib;'); 4826 addNamedSource('/lib.dart', 'librarylib;');
4704 Source source = addSource(''' 4827 Source source = addSource('''
4705 import 'lib.dart' as p; 4828 import 'lib.dart' as p;
4706 class C { 4829 class C {
4707 f() { 4830 f() {
4708 p(); 4831 p();
4709 } 4832 }
4710 } 4833 }
4711 '''); 4834 ''');
4712 assertErrors( 4835 await assertErrors(
4713 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4836 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4714 verify([source]); 4837 verify([source]);
4715 } 4838 }
4716 4839
4717 void test_prefix_unqualified_invocation_not_in_method() { 4840 test_prefix_unqualified_invocation_not_in_method() async {
4718 addNamedSource('/lib.dart', 'librarylib;'); 4841 addNamedSource('/lib.dart', 'librarylib;');
4719 Source source = addSource(''' 4842 Source source = addSource('''
4720 import 'lib.dart' as p; 4843 import 'lib.dart' as p;
4721 f() { 4844 f() {
4722 p(); 4845 p();
4723 } 4846 }
4724 '''); 4847 ''');
4725 assertErrors( 4848 await assertErrors(
4726 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4849 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4727 verify([source]); 4850 verify([source]);
4728 } 4851 }
4729 4852
4730 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { 4853 test_prefixCollidesWithTopLevelMembers_functionTypeAlias() async {
4731 addNamedSource( 4854 addNamedSource(
4732 "/lib.dart", 4855 "/lib.dart",
4733 r''' 4856 r'''
4734 library lib; 4857 library lib;
4735 class A{}'''); 4858 class A{}''');
4736 Source source = addSource(r''' 4859 Source source = addSource(r'''
4737 import 'lib.dart' as p; 4860 import 'lib.dart' as p;
4738 typedef p(); 4861 typedef p();
4739 p.A a;'''); 4862 p.A a;''');
4740 assertErrors( 4863 await assertErrors(
4741 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); 4864 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
4742 verify([source]); 4865 verify([source]);
4743 } 4866 }
4744 4867
4745 void test_prefixCollidesWithTopLevelMembers_topLevelFunction() { 4868 test_prefixCollidesWithTopLevelMembers_topLevelFunction() async {
4746 addNamedSource( 4869 addNamedSource(
4747 "/lib.dart", 4870 "/lib.dart",
4748 r''' 4871 r'''
4749 library lib; 4872 library lib;
4750 class A{}'''); 4873 class A{}''');
4751 Source source = addSource(r''' 4874 Source source = addSource(r'''
4752 import 'lib.dart' as p; 4875 import 'lib.dart' as p;
4753 p() {} 4876 p() {}
4754 p.A a;'''); 4877 p.A a;''');
4755 assertErrors( 4878 await assertErrors(
4756 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); 4879 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
4757 verify([source]); 4880 verify([source]);
4758 } 4881 }
4759 4882
4760 void test_prefixCollidesWithTopLevelMembers_topLevelVariable() { 4883 test_prefixCollidesWithTopLevelMembers_topLevelVariable() async {
4761 addNamedSource( 4884 addNamedSource(
4762 "/lib.dart", 4885 "/lib.dart",
4763 r''' 4886 r'''
4764 library lib; 4887 library lib;
4765 class A{}'''); 4888 class A{}''');
4766 Source source = addSource(r''' 4889 Source source = addSource(r'''
4767 import 'lib.dart' as p; 4890 import 'lib.dart' as p;
4768 var p = null; 4891 var p = null;
4769 p.A a;'''); 4892 p.A a;''');
4770 assertErrors( 4893 await assertErrors(
4771 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); 4894 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
4772 verify([source]); 4895 verify([source]);
4773 } 4896 }
4774 4897
4775 void test_prefixCollidesWithTopLevelMembers_type() { 4898 test_prefixCollidesWithTopLevelMembers_type() async {
4776 addNamedSource( 4899 addNamedSource(
4777 "/lib.dart", 4900 "/lib.dart",
4778 r''' 4901 r'''
4779 library lib; 4902 library lib;
4780 class A{}'''); 4903 class A{}''');
4781 Source source = addSource(r''' 4904 Source source = addSource(r'''
4782 import 'lib.dart' as p; 4905 import 'lib.dart' as p;
4783 class p {} 4906 class p {}
4784 p.A a;'''); 4907 p.A a;''');
4785 assertErrors( 4908 await assertErrors(
4786 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); 4909 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
4787 verify([source]); 4910 verify([source]);
4788 } 4911 }
4789 4912
4790 void test_prefixNotFollowedByDot() { 4913 test_prefixNotFollowedByDot() async {
4791 addNamedSource('/lib.dart', 'library lib;'); 4914 addNamedSource('/lib.dart', 'library lib;');
4792 Source source = addSource(''' 4915 Source source = addSource('''
4793 import 'lib.dart' as p; 4916 import 'lib.dart' as p;
4794 f() { 4917 f() {
4795 return p; 4918 return p;
4796 } 4919 }
4797 '''); 4920 ''');
4798 assertErrors( 4921 await assertErrors(
4799 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4922 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4800 verify([source]); 4923 verify([source]);
4801 } 4924 }
4802 4925
4803 void test_prefixNotFollowedByDot_compoundAssignment() { 4926 test_prefixNotFollowedByDot_compoundAssignment() async {
4804 addNamedSource('/lib.dart', 'library lib;'); 4927 addNamedSource('/lib.dart', 'library lib;');
4805 Source source = addSource(''' 4928 Source source = addSource('''
4806 import 'lib.dart' as p; 4929 import 'lib.dart' as p;
4807 f() { 4930 f() {
4808 p += 1; 4931 p += 1;
4809 } 4932 }
4810 '''); 4933 ''');
4811 assertErrors( 4934 await assertErrors(
4812 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4935 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4813 verify([source]); 4936 verify([source]);
4814 } 4937 }
4815 4938
4816 void test_prefixNotFollowedByDot_conditionalMethodInvocation() { 4939 test_prefixNotFollowedByDot_conditionalMethodInvocation() async {
4817 addNamedSource( 4940 addNamedSource(
4818 '/lib.dart', 4941 '/lib.dart',
4819 ''' 4942 '''
4820 library lib; 4943 library lib;
4821 g() {} 4944 g() {}
4822 '''); 4945 ''');
4823 Source source = addSource(''' 4946 Source source = addSource('''
4824 import 'lib.dart' as p; 4947 import 'lib.dart' as p;
4825 f() { 4948 f() {
4826 p?.g(); 4949 p?.g();
4827 } 4950 }
4828 '''); 4951 ''');
4829 assertErrors( 4952 await assertErrors(
4830 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4953 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4831 verify([source]); 4954 verify([source]);
4832 } 4955 }
4833 4956
4834 void test_privateOptionalParameter() { 4957 test_privateOptionalParameter() async {
4835 Source source = addSource("f({var _p}) {}"); 4958 Source source = addSource("f({var _p}) {}");
4836 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); 4959 await assertErrors(
4960 source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
4837 verify([source]); 4961 verify([source]);
4838 } 4962 }
4839 4963
4840 void test_privateOptionalParameter_fieldFormal() { 4964 test_privateOptionalParameter_fieldFormal() async {
4841 Source source = addSource(r''' 4965 Source source = addSource(r'''
4842 class A { 4966 class A {
4843 var _p; 4967 var _p;
4844 A({this._p: 0}); 4968 A({this._p: 0});
4845 }'''); 4969 }''');
4846 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); 4970 await assertErrors(
4971 source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
4847 verify([source]); 4972 verify([source]);
4848 } 4973 }
4849 4974
4850 void test_privateOptionalParameter_withDefaultValue() { 4975 test_privateOptionalParameter_withDefaultValue() async {
4851 Source source = addSource("f({_p : 0}) {}"); 4976 Source source = addSource("f({_p : 0}) {}");
4852 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); 4977 await assertErrors(
4978 source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
4853 verify([source]); 4979 verify([source]);
4854 } 4980 }
4855 4981
4856 void test_recursiveCompileTimeConstant() { 4982 test_recursiveCompileTimeConstant() async {
4857 Source source = addSource(r''' 4983 Source source = addSource(r'''
4858 class A { 4984 class A {
4859 const A(); 4985 const A();
4860 final m = const A(); 4986 final m = const A();
4861 }'''); 4987 }''');
4862 assertErrors( 4988 await assertErrors(
4863 source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]); 4989 source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
4864 verify([source]); 4990 verify([source]);
4865 } 4991 }
4866 4992
4867 void test_recursiveCompileTimeConstant_cycle() { 4993 test_recursiveCompileTimeConstant_cycle() async {
4868 Source source = addSource(r''' 4994 Source source = addSource(r'''
4869 const x = y + 1; 4995 const x = y + 1;
4870 const y = x + 1;'''); 4996 const y = x + 1;''');
4871 assertErrors(source, [ 4997 await assertErrors(source, [
4872 CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT, 4998 CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT,
4873 CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT 4999 CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT
4874 ]); 5000 ]);
4875 verify([source]); 5001 verify([source]);
4876 } 5002 }
4877 5003
4878 void test_recursiveCompileTimeConstant_initializer_after_toplevel_var() { 5004 test_recursiveCompileTimeConstant_initializer_after_toplevel_var() async {
4879 Source source = addSource(''' 5005 Source source = addSource('''
4880 const y = const C(); 5006 const y = const C();
4881 class C { 5007 class C {
4882 const C() : x = y; 5008 const C() : x = y;
4883 final x; 5009 final x;
4884 } 5010 }
4885 '''); 5011 ''');
4886 assertErrors( 5012 await assertErrors(
4887 source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]); 5013 source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
4888 verify([source]); 5014 verify([source]);
4889 } 5015 }
4890 5016
4891 void test_recursiveCompileTimeConstant_singleVariable() { 5017 test_recursiveCompileTimeConstant_singleVariable() async {
4892 Source source = addSource(r''' 5018 Source source = addSource(r'''
4893 const x = x; 5019 const x = x;
4894 '''); 5020 ''');
4895 assertErrors( 5021 await assertErrors(
4896 source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]); 5022 source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
4897 verify([source]); 5023 verify([source]);
4898 } 5024 }
4899 5025
4900 void test_recursiveConstructorRedirect() { 5026 test_recursiveConstructorRedirect() async {
4901 Source source = addSource(r''' 5027 Source source = addSource(r'''
4902 class A { 5028 class A {
4903 A.a() : this.b(); 5029 A.a() : this.b();
4904 A.b() : this.a(); 5030 A.b() : this.a();
4905 }'''); 5031 }''');
4906 assertErrors(source, [ 5032 await assertErrors(source, [
4907 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, 5033 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT,
4908 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT 5034 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT
4909 ]); 5035 ]);
4910 verify([source]); 5036 verify([source]);
4911 } 5037 }
4912 5038
4913 void test_recursiveConstructorRedirect_directSelfReference() { 5039 test_recursiveConstructorRedirect_directSelfReference() async {
4914 Source source = addSource(r''' 5040 Source source = addSource(r'''
4915 class A { 5041 class A {
4916 A() : this(); 5042 A() : this();
4917 }'''); 5043 }''');
4918 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); 5044 await assertErrors(
5045 source, [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]);
4919 verify([source]); 5046 verify([source]);
4920 } 5047 }
4921 5048
4922 void test_recursiveFactoryRedirect() { 5049 test_recursiveFactoryRedirect() async {
4923 Source source = addSource(r''' 5050 Source source = addSource(r'''
4924 class A implements B { 5051 class A implements B {
4925 factory A() = C; 5052 factory A() = C;
4926 } 5053 }
4927 class B implements C { 5054 class B implements C {
4928 factory B() = A; 5055 factory B() = A;
4929 } 5056 }
4930 class C implements A { 5057 class C implements A {
4931 factory C() = B; 5058 factory C() = B;
4932 }'''); 5059 }''');
4933 assertErrors(source, [ 5060 await assertErrors(source, [
4934 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5061 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
4935 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5062 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
4936 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5063 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
4937 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5064 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
4938 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5065 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
4939 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5066 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
4940 ]); 5067 ]);
4941 verify([source]); 5068 verify([source]);
4942 } 5069 }
4943 5070
4944 void test_recursiveFactoryRedirect_directSelfReference() { 5071 test_recursiveFactoryRedirect_directSelfReference() async {
4945 Source source = addSource(r''' 5072 Source source = addSource(r'''
4946 class A { 5073 class A {
4947 factory A() = A; 5074 factory A() = A;
4948 }'''); 5075 }''');
4949 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]); 5076 await assertErrors(
5077 source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
4950 verify([source]); 5078 verify([source]);
4951 } 5079 }
4952 5080
4953 void test_recursiveFactoryRedirect_diverging() { 5081 test_recursiveFactoryRedirect_diverging() async {
4954 // Analysis should terminate even though the redirections don't reach a 5082 // Analysis should terminate even though the redirections don't reach a
4955 // fixed point. (C<int> redirects to C<C<int>>, then to C<C<C<int>>>, and 5083 // fixed point. (C<int> redirects to C<C<int>>, then to C<C<C<int>>>, and
4956 // so on). 5084 // so on).
4957 Source source = addSource(''' 5085 Source source = addSource('''
4958 class C<T> { 5086 class C<T> {
4959 const factory C() = C<C<T>>; 5087 const factory C() = C<C<T>>;
4960 } 5088 }
4961 main() { 5089 main() {
4962 const C<int>(); 5090 const C<int>();
4963 } 5091 }
4964 '''); 5092 ''');
4965 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]); 5093 await assertErrors(
5094 source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
4966 verify([source]); 5095 verify([source]);
4967 } 5096 }
4968 5097
4969 void test_recursiveFactoryRedirect_generic() { 5098 test_recursiveFactoryRedirect_generic() async {
4970 Source source = addSource(r''' 5099 Source source = addSource(r'''
4971 class A<T> implements B<T> { 5100 class A<T> implements B<T> {
4972 factory A() = C; 5101 factory A() = C;
4973 } 5102 }
4974 class B<T> implements C<T> { 5103 class B<T> implements C<T> {
4975 factory B() = A; 5104 factory B() = A;
4976 } 5105 }
4977 class C<T> implements A<T> { 5106 class C<T> implements A<T> {
4978 factory C() = B; 5107 factory C() = B;
4979 }'''); 5108 }''');
4980 assertErrors(source, [ 5109 await assertErrors(source, [
4981 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5110 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
4982 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5111 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
4983 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5112 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
4984 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5113 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
4985 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5114 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
4986 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5115 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
4987 ]); 5116 ]);
4988 verify([source]); 5117 verify([source]);
4989 } 5118 }
4990 5119
4991 void test_recursiveFactoryRedirect_named() { 5120 test_recursiveFactoryRedirect_named() async {
4992 Source source = addSource(r''' 5121 Source source = addSource(r'''
4993 class A implements B { 5122 class A implements B {
4994 factory A.nameA() = C.nameC; 5123 factory A.nameA() = C.nameC;
4995 } 5124 }
4996 class B implements C { 5125 class B implements C {
4997 factory B.nameB() = A.nameA; 5126 factory B.nameB() = A.nameA;
4998 } 5127 }
4999 class C implements A { 5128 class C implements A {
5000 factory C.nameC() = B.nameB; 5129 factory C.nameC() = B.nameB;
5001 }'''); 5130 }''');
5002 assertErrors(source, [ 5131 await assertErrors(source, [
5003 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5132 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
5004 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5133 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
5005 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5134 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
5006 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5135 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5007 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5136 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5008 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5137 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5009 ]); 5138 ]);
5010 verify([source]); 5139 verify([source]);
5011 } 5140 }
5012 5141
5013 /** 5142 /**
5014 * "A" references "C" which has cycle with "B". But we should not report probl em for "A" - it is 5143 * "A" references "C" which has cycle with "B". But we should not report probl em for "A" - it is
5015 * not the part of a cycle. 5144 * not the part of a cycle.
5016 */ 5145 */
5017 void test_recursiveFactoryRedirect_outsideCycle() { 5146 test_recursiveFactoryRedirect_outsideCycle() async {
5018 Source source = addSource(r''' 5147 Source source = addSource(r'''
5019 class A { 5148 class A {
5020 factory A() = C; 5149 factory A() = C;
5021 } 5150 }
5022 class B implements C { 5151 class B implements C {
5023 factory B() = C; 5152 factory B() = C;
5024 } 5153 }
5025 class C implements A, B { 5154 class C implements A, B {
5026 factory C() = B; 5155 factory C() = B;
5027 }'''); 5156 }''');
5028 assertErrors(source, [ 5157 await assertErrors(source, [
5029 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5158 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
5030 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, 5159 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
5031 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5160 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5032 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5161 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5033 ]); 5162 ]);
5034 verify([source]); 5163 verify([source]);
5035 } 5164 }
5036 5165
5037 void test_recursiveInterfaceInheritance_extends() { 5166 test_recursiveInterfaceInheritance_extends() async {
5038 Source source = addSource(r''' 5167 Source source = addSource(r'''
5039 class A extends B {} 5168 class A extends B {}
5040 class B extends A {}'''); 5169 class B extends A {}''');
5041 assertErrors(source, [ 5170 await assertErrors(source, [
5042 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5171 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5043 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5172 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5044 ]); 5173 ]);
5045 verify([source]); 5174 verify([source]);
5046 } 5175 }
5047 5176
5048 void test_recursiveInterfaceInheritance_extends_implements() { 5177 test_recursiveInterfaceInheritance_extends_implements() async {
5049 Source source = addSource(r''' 5178 Source source = addSource(r'''
5050 class A extends B {} 5179 class A extends B {}
5051 class B implements A {}'''); 5180 class B implements A {}''');
5052 assertErrors(source, [ 5181 await assertErrors(source, [
5053 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5182 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5054 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5183 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5055 ]); 5184 ]);
5056 verify([source]); 5185 verify([source]);
5057 } 5186 }
5058 5187
5059 void test_recursiveInterfaceInheritance_implements() { 5188 test_recursiveInterfaceInheritance_implements() async {
5060 Source source = addSource(r''' 5189 Source source = addSource(r'''
5061 class A implements B {} 5190 class A implements B {}
5062 class B implements A {}'''); 5191 class B implements A {}''');
5063 assertErrors(source, [ 5192 await assertErrors(source, [
5064 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5193 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5065 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5194 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5066 ]); 5195 ]);
5067 verify([source]); 5196 verify([source]);
5068 } 5197 }
5069 5198
5070 void test_recursiveInterfaceInheritance_mixin() { 5199 test_recursiveInterfaceInheritance_mixin() async {
5071 Source source = addSource(r''' 5200 Source source = addSource(r'''
5072 class M1 = Object with M2; 5201 class M1 = Object with M2;
5073 class M2 = Object with M1;'''); 5202 class M2 = Object with M1;''');
5074 assertErrors(source, [ 5203 await assertErrors(source, [
5075 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5204 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5076 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5205 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5077 ]); 5206 ]);
5078 verify([source]); 5207 verify([source]);
5079 } 5208 }
5080 5209
5081 void test_recursiveInterfaceInheritance_mixin_superclass() { 5210 test_recursiveInterfaceInheritance_mixin_superclass() async {
5082 // Make sure we don't get CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS in 5211 // Make sure we don't get CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS in
5083 // addition--that would just be confusing. 5212 // addition--that would just be confusing.
5084 Source source = addSource(''' 5213 Source source = addSource('''
5085 class C = D with M; 5214 class C = D with M;
5086 class D = C with M; 5215 class D = C with M;
5087 class M {} 5216 class M {}
5088 '''); 5217 ''');
5089 assertErrors(source, [ 5218 await assertErrors(source, [
5090 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5219 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5091 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5220 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5092 ]); 5221 ]);
5093 verify([source]); 5222 verify([source]);
5094 } 5223 }
5095 5224
5096 void test_recursiveInterfaceInheritance_tail() { 5225 test_recursiveInterfaceInheritance_tail() async {
5097 Source source = addSource(r''' 5226 Source source = addSource(r'''
5098 abstract class A implements A {} 5227 abstract class A implements A {}
5099 class B implements A {}'''); 5228 class B implements A {}''');
5100 assertErrors(source, [ 5229 await assertErrors(source, [
5101 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS 5230 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS
5102 ]); 5231 ]);
5103 verify([source]); 5232 verify([source]);
5104 } 5233 }
5105 5234
5106 void test_recursiveInterfaceInheritance_tail2() { 5235 test_recursiveInterfaceInheritance_tail2() async {
5107 Source source = addSource(r''' 5236 Source source = addSource(r'''
5108 abstract class A implements B {} 5237 abstract class A implements B {}
5109 abstract class B implements A {} 5238 abstract class B implements A {}
5110 class C implements A {}'''); 5239 class C implements A {}''');
5111 assertErrors(source, [ 5240 await assertErrors(source, [
5112 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5241 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5113 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5242 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5114 ]); 5243 ]);
5115 verify([source]); 5244 verify([source]);
5116 } 5245 }
5117 5246
5118 void test_recursiveInterfaceInheritance_tail3() { 5247 test_recursiveInterfaceInheritance_tail3() async {
5119 Source source = addSource(r''' 5248 Source source = addSource(r'''
5120 abstract class A implements B {} 5249 abstract class A implements B {}
5121 abstract class B implements C {} 5250 abstract class B implements C {}
5122 abstract class C implements A {} 5251 abstract class C implements A {}
5123 class D implements A {}'''); 5252 class D implements A {}''');
5124 assertErrors(source, [ 5253 await assertErrors(source, [
5125 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5254 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5126 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 5255 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
5127 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE 5256 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
5128 ]); 5257 ]);
5129 verify([source]); 5258 verify([source]);
5130 } 5259 }
5131 5260
5132 void test_recursiveInterfaceInheritanceBaseCaseExtends() { 5261 test_recursiveInterfaceInheritanceBaseCaseExtends() async {
5133 Source source = addSource("class A extends A {}"); 5262 Source source = addSource("class A extends A {}");
5134 assertErrors(source, [ 5263 await assertErrors(source, [
5135 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS 5264 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS
5136 ]); 5265 ]);
5137 verify([source]); 5266 verify([source]);
5138 } 5267 }
5139 5268
5140 void test_recursiveInterfaceInheritanceBaseCaseExtends_abstract() { 5269 test_recursiveInterfaceInheritanceBaseCaseExtends_abstract() async {
5141 Source source = addSource(r''' 5270 Source source = addSource(r'''
5142 class C extends C { 5271 class C extends C {
5143 var bar = 0; 5272 var bar = 0;
5144 m(); 5273 m();
5145 } 5274 }
5146 '''); 5275 ''');
5147 assertErrors(source, [ 5276 await assertErrors(source, [
5148 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS, 5277 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS,
5149 StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER, 5278 StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER,
5150 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE 5279 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE
5151 ]); 5280 ]);
5152 verify([source]); 5281 verify([source]);
5153 } 5282 }
5154 5283
5155 void test_recursiveInterfaceInheritanceBaseCaseImplements() { 5284 test_recursiveInterfaceInheritanceBaseCaseImplements() async {
5156 Source source = addSource("class A implements A {}"); 5285 Source source = addSource("class A implements A {}");
5157 assertErrors(source, [ 5286 await assertErrors(source, [
5158 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS 5287 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS
5159 ]); 5288 ]);
5160 verify([source]); 5289 verify([source]);
5161 } 5290 }
5162 5291
5163 void test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias() { 5292 test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias() async {
5164 Source source = addSource(r''' 5293 Source source = addSource(r'''
5165 class A {} 5294 class A {}
5166 class M {} 5295 class M {}
5167 class B = A with M implements B;'''); 5296 class B = A with M implements B;''');
5168 assertErrors(source, [ 5297 await assertErrors(source, [
5169 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS 5298 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS
5170 ]); 5299 ]);
5171 verify([source]); 5300 verify([source]);
5172 } 5301 }
5173 5302
5174 void test_recursiveInterfaceInheritanceBaseCaseWith() { 5303 test_recursiveInterfaceInheritanceBaseCaseWith() async {
5175 Source source = addSource("class M = Object with M;"); 5304 Source source = addSource("class M = Object with M;");
5176 assertErrors(source, 5305 await assertErrors(source,
5177 [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH]); 5306 [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH]);
5178 verify([source]); 5307 verify([source]);
5179 } 5308 }
5180 5309
5181 void test_redirectGenerativeToMissingConstructor() { 5310 test_redirectGenerativeToMissingConstructor() async {
5182 Source source = addSource(r''' 5311 Source source = addSource(r'''
5183 class A { 5312 class A {
5184 A() : this.noSuchConstructor(); 5313 A() : this.noSuchConstructor();
5185 }'''); 5314 }''');
5186 assertErrors(source, 5315 await assertErrors(source,
5187 [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]); 5316 [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]);
5188 } 5317 }
5189 5318
5190 void test_redirectGenerativeToNonGenerativeConstructor() { 5319 test_redirectGenerativeToNonGenerativeConstructor() async {
5191 Source source = addSource(r''' 5320 Source source = addSource(r'''
5192 class A { 5321 class A {
5193 A() : this.x(); 5322 A() : this.x();
5194 factory A.x() => null; 5323 factory A.x() => null;
5195 }'''); 5324 }''');
5196 assertErrors(source, [ 5325 await assertErrors(source, [
5197 CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR 5326 CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR
5198 ]); 5327 ]);
5199 verify([source]); 5328 verify([source]);
5200 } 5329 }
5201 5330
5202 void test_redirectToMissingConstructor_named() { 5331 test_redirectToMissingConstructor_named() async {
5203 Source source = addSource(r''' 5332 Source source = addSource(r'''
5204 class A implements B{ 5333 class A implements B{
5205 A() {} 5334 A() {}
5206 } 5335 }
5207 class B { 5336 class B {
5208 const factory B() = A.name; 5337 const factory B() = A.name;
5209 }'''); 5338 }''');
5210 assertErrors( 5339 await assertErrors(
5211 source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); 5340 source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
5212 } 5341 }
5213 5342
5214 void test_redirectToMissingConstructor_unnamed() { 5343 test_redirectToMissingConstructor_unnamed() async {
5215 Source source = addSource(r''' 5344 Source source = addSource(r'''
5216 class A implements B{ 5345 class A implements B{
5217 A.name() {} 5346 A.name() {}
5218 } 5347 }
5219 class B { 5348 class B {
5220 const factory B() = A; 5349 const factory B() = A;
5221 }'''); 5350 }''');
5222 assertErrors( 5351 await assertErrors(
5223 source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); 5352 source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
5224 } 5353 }
5225 5354
5226 void test_redirectToNonClass_notAType() { 5355 test_redirectToNonClass_notAType() async {
5227 Source source = addSource(r''' 5356 Source source = addSource(r'''
5228 int A; 5357 int A;
5229 class B { 5358 class B {
5230 const factory B() = A; 5359 const factory B() = A;
5231 }'''); 5360 }''');
5232 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]); 5361 await assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]);
5233 verify([source]); 5362 verify([source]);
5234 } 5363 }
5235 5364
5236 void test_redirectToNonClass_undefinedIdentifier() { 5365 test_redirectToNonClass_undefinedIdentifier() async {
5237 Source source = addSource(r''' 5366 Source source = addSource(r'''
5238 class B { 5367 class B {
5239 const factory B() = A; 5368 const factory B() = A;
5240 }'''); 5369 }''');
5241 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]); 5370 await assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]);
5242 verify([source]); 5371 verify([source]);
5243 } 5372 }
5244 5373
5245 void test_redirectToNonConstConstructor() { 5374 test_redirectToNonConstConstructor() async {
5246 Source source = addSource(r''' 5375 Source source = addSource(r'''
5247 class A { 5376 class A {
5248 A.a() {} 5377 A.a() {}
5249 const factory A.b() = A.a; 5378 const factory A.b() = A.a;
5250 }'''); 5379 }''');
5251 assertErrors( 5380 await assertErrors(
5252 source, [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR]); 5381 source, [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR]);
5253 verify([source]); 5382 verify([source]);
5254 } 5383 }
5255 5384
5256 void test_referencedBeforeDeclaration_hideInBlock_function() { 5385 test_referencedBeforeDeclaration_hideInBlock_function() async {
5257 Source source = addSource(r''' 5386 Source source = addSource(r'''
5258 var v = 1; 5387 var v = 1;
5259 main() { 5388 main() {
5260 print(v); 5389 print(v);
5261 v() {} 5390 v() {}
5262 } 5391 }
5263 print(x) {}'''); 5392 print(x) {}''');
5264 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); 5393 await assertErrors(
5394 source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
5265 } 5395 }
5266 5396
5267 void test_referencedBeforeDeclaration_hideInBlock_local() { 5397 test_referencedBeforeDeclaration_hideInBlock_local() async {
5268 Source source = addSource(r''' 5398 Source source = addSource(r'''
5269 var v = 1; 5399 var v = 1;
5270 main() { 5400 main() {
5271 print(v); 5401 print(v);
5272 var v = 2; 5402 var v = 2;
5273 } 5403 }
5274 print(x) {}'''); 5404 print(x) {}''');
5275 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); 5405 await assertErrors(
5406 source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
5276 } 5407 }
5277 5408
5278 void test_referencedBeforeDeclaration_hideInBlock_subBlock() { 5409 test_referencedBeforeDeclaration_hideInBlock_subBlock() async {
5279 Source source = addSource(r''' 5410 Source source = addSource(r'''
5280 var v = 1; 5411 var v = 1;
5281 main() { 5412 main() {
5282 { 5413 {
5283 print(v); 5414 print(v);
5284 } 5415 }
5285 var v = 2; 5416 var v = 2;
5286 } 5417 }
5287 print(x) {}'''); 5418 print(x) {}''');
5288 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); 5419 await assertErrors(
5420 source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
5289 } 5421 }
5290 5422
5291 void test_referencedBeforeDeclaration_inInitializer_closure() { 5423 test_referencedBeforeDeclaration_inInitializer_closure() async {
5292 Source source = addSource(r''' 5424 Source source = addSource(r'''
5293 main() { 5425 main() {
5294 var v = () => v; 5426 var v = () => v;
5295 }'''); 5427 }''');
5296 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); 5428 await assertErrors(
5429 source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
5297 } 5430 }
5298 5431
5299 void test_referencedBeforeDeclaration_inInitializer_directly() { 5432 test_referencedBeforeDeclaration_inInitializer_directly() async {
5300 Source source = addSource(r''' 5433 Source source = addSource(r'''
5301 main() { 5434 main() {
5302 var v = v; 5435 var v = v;
5303 }'''); 5436 }''');
5304 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); 5437 await assertErrors(
5438 source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
5305 } 5439 }
5306 5440
5307 void test_referencedBeforeDeclaration_type_localFunction() { 5441 test_referencedBeforeDeclaration_type_localFunction() async {
5308 Source source = addSource(r''' 5442 Source source = addSource(r'''
5309 void testTypeRef() { 5443 void testTypeRef() {
5310 String s = ''; 5444 String s = '';
5311 int String(int x) => x + 1; 5445 int String(int x) => x + 1;
5312 } 5446 }
5313 '''); 5447 ''');
5314 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); 5448 await assertErrors(
5449 source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
5315 } 5450 }
5316 5451
5317 void test_referencedBeforeDeclaration_type_localVariable() { 5452 test_referencedBeforeDeclaration_type_localVariable() async {
5318 Source source = addSource(r''' 5453 Source source = addSource(r'''
5319 void testTypeRef() { 5454 void testTypeRef() {
5320 String s = ''; 5455 String s = '';
5321 var String = ''; 5456 var String = '';
5322 } 5457 }
5323 '''); 5458 ''');
5324 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); 5459 await assertErrors(
5460 source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
5325 } 5461 }
5326 5462
5327 void test_rethrowOutsideCatch() { 5463 test_rethrowOutsideCatch() async {
5328 Source source = addSource(r''' 5464 Source source = addSource(r'''
5329 f() { 5465 f() {
5330 rethrow; 5466 rethrow;
5331 }'''); 5467 }''');
5332 assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); 5468 await assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]);
5333 verify([source]); 5469 verify([source]);
5334 } 5470 }
5335 5471
5336 void test_returnInGenerativeConstructor() { 5472 test_returnInGenerativeConstructor() async {
5337 Source source = addSource(r''' 5473 Source source = addSource(r'''
5338 class A { 5474 class A {
5339 A() { return 0; } 5475 A() { return 0; }
5340 }'''); 5476 }''');
5341 assertErrors( 5477 await assertErrors(
5342 source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]); 5478 source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]);
5343 verify([source]); 5479 verify([source]);
5344 } 5480 }
5345 5481
5346 void test_returnInGenerativeConstructor_expressionFunctionBody() { 5482 test_returnInGenerativeConstructor_expressionFunctionBody() async {
5347 Source source = addSource(r''' 5483 Source source = addSource(r'''
5348 class A { 5484 class A {
5349 A() => null; 5485 A() => null;
5350 }'''); 5486 }''');
5351 assertErrors( 5487 await assertErrors(
5352 source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]); 5488 source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]);
5353 verify([source]); 5489 verify([source]);
5354 } 5490 }
5355 5491
5356 void test_returnInGenerator_asyncStar() { 5492 test_returnInGenerator_asyncStar() async {
5357 Source source = addSource(r''' 5493 Source source = addSource(r'''
5358 f() async* { 5494 f() async* {
5359 return 0; 5495 return 0;
5360 }'''); 5496 }''');
5361 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]); 5497 await assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]);
5362 verify([source]); 5498 verify([source]);
5363 } 5499 }
5364 5500
5365 void test_returnInGenerator_syncStar() { 5501 test_returnInGenerator_syncStar() async {
5366 Source source = addSource(r''' 5502 Source source = addSource(r'''
5367 f() sync* { 5503 f() sync* {
5368 return 0; 5504 return 0;
5369 }'''); 5505 }''');
5370 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]); 5506 await assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]);
5371 verify([source]); 5507 verify([source]);
5372 } 5508 }
5373 5509
5374 void test_sharedDeferredPrefix() { 5510 test_sharedDeferredPrefix() async {
5375 resolveWithErrors(<String>[ 5511 await resolveWithErrors(<String>[
5376 r''' 5512 r'''
5377 library lib1; 5513 library lib1;
5378 f1() {}''', 5514 f1() {}''',
5379 r''' 5515 r'''
5380 library lib2; 5516 library lib2;
5381 f2() {}''', 5517 f2() {}''',
5382 r''' 5518 r'''
5383 library root; 5519 library root;
5384 import 'lib1.dart' deferred as lib; 5520 import 'lib1.dart' deferred as lib;
5385 import 'lib2.dart' as lib; 5521 import 'lib2.dart' as lib;
5386 main() { lib.f1(); lib.f2(); }''' 5522 main() { lib.f1(); lib.f2(); }'''
5387 ], <ErrorCode>[ 5523 ], <ErrorCode>[
5388 CompileTimeErrorCode.SHARED_DEFERRED_PREFIX 5524 CompileTimeErrorCode.SHARED_DEFERRED_PREFIX
5389 ]); 5525 ]);
5390 } 5526 }
5391 5527
5392 void test_superInInvalidContext_binaryExpression() { 5528 test_superInInvalidContext_binaryExpression() async {
5393 Source source = addSource("var v = super + 0;"); 5529 Source source = addSource("var v = super + 0;");
5394 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5530 await assertErrors(
5531 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5395 // no verify(), 'super.v' is not resolved 5532 // no verify(), 'super.v' is not resolved
5396 } 5533 }
5397 5534
5398 void test_superInInvalidContext_constructorFieldInitializer() { 5535 test_superInInvalidContext_constructorFieldInitializer() async {
5399 Source source = addSource(r''' 5536 Source source = addSource(r'''
5400 class A { 5537 class A {
5401 m() {} 5538 m() {}
5402 } 5539 }
5403 class B extends A { 5540 class B extends A {
5404 var f; 5541 var f;
5405 B() : f = super.m(); 5542 B() : f = super.m();
5406 }'''); 5543 }''');
5407 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5544 await assertErrors(
5545 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5408 // no verify(), 'super.m' is not resolved 5546 // no verify(), 'super.m' is not resolved
5409 } 5547 }
5410 5548
5411 void test_superInInvalidContext_factoryConstructor() { 5549 test_superInInvalidContext_factoryConstructor() async {
5412 Source source = addSource(r''' 5550 Source source = addSource(r'''
5413 class A { 5551 class A {
5414 m() {} 5552 m() {}
5415 } 5553 }
5416 class B extends A { 5554 class B extends A {
5417 factory B() { 5555 factory B() {
5418 super.m(); 5556 super.m();
5419 return null; 5557 return null;
5420 } 5558 }
5421 }'''); 5559 }''');
5422 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5560 await assertErrors(
5561 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5423 // no verify(), 'super.m' is not resolved 5562 // no verify(), 'super.m' is not resolved
5424 } 5563 }
5425 5564
5426 void test_superInInvalidContext_instanceVariableInitializer() { 5565 test_superInInvalidContext_instanceVariableInitializer() async {
5427 Source source = addSource(r''' 5566 Source source = addSource(r'''
5428 class A { 5567 class A {
5429 var a; 5568 var a;
5430 } 5569 }
5431 class B extends A { 5570 class B extends A {
5432 var b = super.a; 5571 var b = super.a;
5433 }'''); 5572 }''');
5434 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5573 await assertErrors(
5574 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5435 // no verify(), 'super.a' is not resolved 5575 // no verify(), 'super.a' is not resolved
5436 } 5576 }
5437 5577
5438 void test_superInInvalidContext_staticMethod() { 5578 test_superInInvalidContext_staticMethod() async {
5439 Source source = addSource(r''' 5579 Source source = addSource(r'''
5440 class A { 5580 class A {
5441 static m() {} 5581 static m() {}
5442 } 5582 }
5443 class B extends A { 5583 class B extends A {
5444 static n() { return super.m(); } 5584 static n() { return super.m(); }
5445 }'''); 5585 }''');
5446 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5586 await assertErrors(
5587 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5447 // no verify(), 'super.m' is not resolved 5588 // no verify(), 'super.m' is not resolved
5448 } 5589 }
5449 5590
5450 void test_superInInvalidContext_staticVariableInitializer() { 5591 test_superInInvalidContext_staticVariableInitializer() async {
5451 Source source = addSource(r''' 5592 Source source = addSource(r'''
5452 class A { 5593 class A {
5453 static int a = 0; 5594 static int a = 0;
5454 } 5595 }
5455 class B extends A { 5596 class B extends A {
5456 static int b = super.a; 5597 static int b = super.a;
5457 }'''); 5598 }''');
5458 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5599 await assertErrors(
5600 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5459 // no verify(), 'super.a' is not resolved 5601 // no verify(), 'super.a' is not resolved
5460 } 5602 }
5461 5603
5462 void test_superInInvalidContext_topLevelFunction() { 5604 test_superInInvalidContext_topLevelFunction() async {
5463 Source source = addSource(r''' 5605 Source source = addSource(r'''
5464 f() { 5606 f() {
5465 super.f(); 5607 super.f();
5466 }'''); 5608 }''');
5467 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5609 await assertErrors(
5610 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5468 // no verify(), 'super.f' is not resolved 5611 // no verify(), 'super.f' is not resolved
5469 } 5612 }
5470 5613
5471 void test_superInInvalidContext_topLevelVariableInitializer() { 5614 test_superInInvalidContext_topLevelVariableInitializer() async {
5472 Source source = addSource("var v = super.y;"); 5615 Source source = addSource("var v = super.y;");
5473 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5616 await assertErrors(
5617 source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5474 // no verify(), 'super.y' is not resolved 5618 // no verify(), 'super.y' is not resolved
5475 } 5619 }
5476 5620
5477 void test_superInRedirectingConstructor_redirectionSuper() { 5621 test_superInRedirectingConstructor_redirectionSuper() async {
5478 Source source = addSource(r''' 5622 Source source = addSource(r'''
5479 class A {} 5623 class A {}
5480 class B { 5624 class B {
5481 B() : this.name(), super(); 5625 B() : this.name(), super();
5482 B.name() {} 5626 B.name() {}
5483 }'''); 5627 }''');
5484 assertErrors( 5628 await assertErrors(
5485 source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]); 5629 source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]);
5486 verify([source]); 5630 verify([source]);
5487 } 5631 }
5488 5632
5489 void test_superInRedirectingConstructor_superRedirection() { 5633 test_superInRedirectingConstructor_superRedirection() async {
5490 Source source = addSource(r''' 5634 Source source = addSource(r'''
5491 class A {} 5635 class A {}
5492 class B { 5636 class B {
5493 B() : super(), this.name(); 5637 B() : super(), this.name();
5494 B.name() {} 5638 B.name() {}
5495 }'''); 5639 }''');
5496 assertErrors( 5640 await assertErrors(
5497 source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]); 5641 source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]);
5498 verify([source]); 5642 verify([source]);
5499 } 5643 }
5500 5644
5501 void test_symbol_constructor_badArgs() { 5645 test_symbol_constructor_badArgs() async {
5502 Source source = addSource(r''' 5646 Source source = addSource(r'''
5503 var s1 = const Symbol('3'); 5647 var s1 = const Symbol('3');
5504 var s2 = const Symbol(3); 5648 var s2 = const Symbol(3);
5505 var s3 = const Symbol(); 5649 var s3 = const Symbol();
5506 var s4 = const Symbol('x', 'y'); 5650 var s4 = const Symbol('x', 'y');
5507 var s5 = const Symbol('x', foo: 'x');'''); 5651 var s5 = const Symbol('x', foo: 'x');''');
5508 assertErrors(source, [ 5652 await assertErrors(source, [
5509 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 5653 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
5510 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 5654 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
5511 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 5655 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
5512 CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS, 5656 CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS,
5513 CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 5657 CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS,
5514 CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER 5658 CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER
5515 ]); 5659 ]);
5516 verify([source]); 5660 verify([source]);
5517 } 5661 }
5518 5662
5519 void test_typeAliasCannotReferenceItself_11987() { 5663 test_typeAliasCannotReferenceItself_11987() async {
5520 Source source = addSource(r''' 5664 Source source = addSource(r'''
5521 typedef void F(List<G> l); 5665 typedef void F(List<G> l);
5522 typedef void G(List<F> l); 5666 typedef void G(List<F> l);
5523 main() { 5667 main() {
5524 F foo(G g) => g; 5668 F foo(G g) => g;
5525 }'''); 5669 }''');
5526 assertErrors(source, [ 5670 await assertErrors(source, [
5527 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 5671 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
5528 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF 5672 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
5529 ]); 5673 ]);
5530 verify([source]); 5674 verify([source]);
5531 } 5675 }
5532 5676
5533 void test_typeAliasCannotReferenceItself_19459() { 5677 test_typeAliasCannotReferenceItself_19459() async {
5534 // A complex example involving multiple classes. This is legal, since 5678 // A complex example involving multiple classes. This is legal, since
5535 // typedef F references itself only via a class. 5679 // typedef F references itself only via a class.
5536 Source source = addSource(r''' 5680 Source source = addSource(r'''
5537 class A<B, C> {} 5681 class A<B, C> {}
5538 abstract class D { 5682 abstract class D {
5539 f(E e); 5683 f(E e);
5540 } 5684 }
5541 abstract class E extends A<dynamic, F> {} 5685 abstract class E extends A<dynamic, F> {}
5542 typedef D F(); 5686 typedef D F();
5543 '''); 5687 ''');
5544 assertNoErrors(source); 5688 await assertNoErrors(source);
5545 verify([source]); 5689 verify([source]);
5546 } 5690 }
5547 5691
5548 void test_typeAliasCannotReferenceItself_parameterType_named() { 5692 test_typeAliasCannotReferenceItself_parameterType_named() async {
5549 Source source = addSource("typedef A({A a});"); 5693 Source source = addSource("typedef A({A a});");
5550 assertErrors( 5694 await assertErrors(
5551 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); 5695 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
5552 verify([source]); 5696 verify([source]);
5553 } 5697 }
5554 5698
5555 void test_typeAliasCannotReferenceItself_parameterType_positional() { 5699 test_typeAliasCannotReferenceItself_parameterType_positional() async {
5556 Source source = addSource("typedef A([A a]);"); 5700 Source source = addSource("typedef A([A a]);");
5557 assertErrors( 5701 await assertErrors(
5558 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); 5702 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
5559 verify([source]); 5703 verify([source]);
5560 } 5704 }
5561 5705
5562 void test_typeAliasCannotReferenceItself_parameterType_required() { 5706 test_typeAliasCannotReferenceItself_parameterType_required() async {
5563 Source source = addSource("typedef A(A a);"); 5707 Source source = addSource("typedef A(A a);");
5564 assertErrors( 5708 await assertErrors(
5565 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); 5709 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
5566 verify([source]); 5710 verify([source]);
5567 } 5711 }
5568 5712
5569 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() { 5713 test_typeAliasCannotReferenceItself_parameterType_typeArgument() async {
5570 Source source = addSource("typedef A(List<A> a);"); 5714 Source source = addSource("typedef A(List<A> a);");
5571 assertErrors( 5715 await assertErrors(
5572 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); 5716 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
5573 verify([source]); 5717 verify([source]);
5574 } 5718 }
5575 5719
5576 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { 5720 test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() async {
5577 // A typedef is allowed to indirectly reference itself via a class. 5721 // A typedef is allowed to indirectly reference itself via a class.
5578 Source source = addSource(r''' 5722 Source source = addSource(r'''
5579 typedef C A(); 5723 typedef C A();
5580 typedef A B(); 5724 typedef A B();
5581 class C { 5725 class C {
5582 B a; 5726 B a;
5583 }'''); 5727 }''');
5584 assertNoErrors(source); 5728 await assertNoErrors(source);
5585 verify([source]); 5729 verify([source]);
5586 } 5730 }
5587 5731
5588 void test_typeAliasCannotReferenceItself_returnType() { 5732 test_typeAliasCannotReferenceItself_returnType() async {
5589 Source source = addSource("typedef A A();"); 5733 Source source = addSource("typedef A A();");
5590 assertErrors( 5734 await assertErrors(
5591 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); 5735 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
5592 verify([source]); 5736 verify([source]);
5593 } 5737 }
5594 5738
5595 void test_typeAliasCannotReferenceItself_returnType_indirect() { 5739 test_typeAliasCannotReferenceItself_returnType_indirect() async {
5596 Source source = addSource(r''' 5740 Source source = addSource(r'''
5597 typedef B A(); 5741 typedef B A();
5598 typedef A B();'''); 5742 typedef A B();''');
5599 assertErrors(source, [ 5743 await assertErrors(source, [
5600 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 5744 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
5601 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF 5745 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
5602 ]); 5746 ]);
5603 verify([source]); 5747 verify([source]);
5604 } 5748 }
5605 5749
5606 void test_typeAliasCannotReferenceItself_typeVariableBounds() { 5750 test_typeAliasCannotReferenceItself_typeVariableBounds() async {
5607 Source source = addSource("typedef A<T extends A>();"); 5751 Source source = addSource("typedef A<T extends A>();");
5608 assertErrors( 5752 await assertErrors(
5609 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); 5753 source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
5610 verify([source]); 5754 verify([source]);
5611 } 5755 }
5612 5756
5613 void test_typeArgumentNotMatchingBounds_const() { 5757 test_typeArgumentNotMatchingBounds_const() async {
5614 Source source = addSource(r''' 5758 Source source = addSource(r'''
5615 class A {} 5759 class A {}
5616 class B {} 5760 class B {}
5617 class G<E extends A> { 5761 class G<E extends A> {
5618 const G(); 5762 const G();
5619 } 5763 }
5620 f() { return const G<B>(); }'''); 5764 f() { return const G<B>(); }''');
5621 assertErrors( 5765 await assertErrors(
5622 source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); 5766 source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
5623 verify([source]); 5767 verify([source]);
5624 } 5768 }
5625 5769
5626 void test_undefinedClass_const() { 5770 test_undefinedClass_const() async {
5627 Source source = addSource(r''' 5771 Source source = addSource(r'''
5628 f() { 5772 f() {
5629 return const A(); 5773 return const A();
5630 }'''); 5774 }''');
5631 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CLASS]); 5775 await assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CLASS]);
5632 verify([source]); 5776 verify([source]);
5633 } 5777 }
5634 5778
5635 void test_undefinedConstructorInInitializer_explicit_named() { 5779 test_undefinedConstructorInInitializer_explicit_named() async {
5636 Source source = addSource(r''' 5780 Source source = addSource(r'''
5637 class A {} 5781 class A {}
5638 class B extends A { 5782 class B extends A {
5639 B() : super.named(); 5783 B() : super.named();
5640 }'''); 5784 }''');
5641 assertErrors( 5785 await assertErrors(
5642 source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]); 5786 source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
5643 // no verify(), "super.named()" is not resolved 5787 // no verify(), "super.named()" is not resolved
5644 } 5788 }
5645 5789
5646 void test_undefinedConstructorInInitializer_explicit_unnamed() { 5790 test_undefinedConstructorInInitializer_explicit_unnamed() async {
5647 Source source = addSource(r''' 5791 Source source = addSource(r'''
5648 class A { 5792 class A {
5649 A.named() {} 5793 A.named() {}
5650 } 5794 }
5651 class B extends A { 5795 class B extends A {
5652 B() : super(); 5796 B() : super();
5653 }'''); 5797 }''');
5654 assertErrors(source, 5798 await assertErrors(source,
5655 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 5799 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
5656 verify([source]); 5800 verify([source]);
5657 } 5801 }
5658 5802
5659 void test_undefinedConstructorInInitializer_implicit() { 5803 test_undefinedConstructorInInitializer_implicit() async {
5660 Source source = addSource(r''' 5804 Source source = addSource(r'''
5661 class A { 5805 class A {
5662 A.named() {} 5806 A.named() {}
5663 } 5807 }
5664 class B extends A { 5808 class B extends A {
5665 B(); 5809 B();
5666 }'''); 5810 }''');
5667 assertErrors(source, 5811 await assertErrors(source,
5668 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 5812 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
5669 verify([source]); 5813 verify([source]);
5670 } 5814 }
5671 5815
5672 void test_undefinedNamedParameter() { 5816 test_undefinedNamedParameter() async {
5673 Source source = addSource(r''' 5817 Source source = addSource(r'''
5674 class A { 5818 class A {
5675 const A(); 5819 const A();
5676 } 5820 }
5677 main() { 5821 main() {
5678 const A(p: 0); 5822 const A(p: 0);
5679 }'''); 5823 }''');
5680 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]); 5824 await assertErrors(
5825 source, [CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]);
5681 // no verify(), 'p' is not resolved 5826 // no verify(), 'p' is not resolved
5682 } 5827 }
5683 5828
5684 void test_uriDoesNotExist_export() { 5829 test_uriDoesNotExist_export() async {
5685 Source source = addSource("export 'unknown.dart';"); 5830 Source source = addSource("export 'unknown.dart';");
5686 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); 5831 await assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5687 } 5832 }
5688 5833
5689 void test_uriDoesNotExist_import() { 5834 test_uriDoesNotExist_import() async {
5690 Source source = addSource("import 'unknown.dart';"); 5835 Source source = addSource("import 'unknown.dart';");
5691 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); 5836 await assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5692 } 5837 }
5693 5838
5694 void test_uriDoesNotExist_import_appears_after_deleting_target() { 5839 test_uriDoesNotExist_import_appears_after_deleting_target() async {
5695 Source test = addSource("import 'target.dart';"); 5840 Source test = addSource("import 'target.dart';");
5696 Source target = addNamedSource("/target.dart", ""); 5841 Source target = addNamedSource("/target.dart", "");
5697 assertErrors(test, [HintCode.UNUSED_IMPORT]); 5842 await assertErrors(test, [HintCode.UNUSED_IMPORT]);
5698 5843
5699 // Remove the overlay in the same way as AnalysisServer. 5844 // Remove the overlay in the same way as AnalysisServer.
5700 analysisContext2.setContents(target, null); 5845 analysisContext2.setContents(target, null);
5701 ChangeSet changeSet = new ChangeSet()..removedSource(target); 5846 ChangeSet changeSet = new ChangeSet()..removedSource(target);
5702 analysisContext2.applyChanges(changeSet); 5847 analysisContext2.applyChanges(changeSet);
5703 5848
5704 assertErrors(test, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); 5849 await assertErrors(test, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5705 } 5850 }
5706 5851
5707 void test_uriDoesNotExist_import_disappears_when_fixed() { 5852 test_uriDoesNotExist_import_disappears_when_fixed() async {
5708 Source source = addSource("import 'target.dart';"); 5853 Source source = addSource("import 'target.dart';");
5709 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); 5854 await assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5710 5855
5711 // Check that the file is represented as missing. 5856 // Check that the file is represented as missing.
5712 Source target = analysisContext2 5857 Source target = analysisContext2
5713 .getSourcesWithFullName(resourceProvider.convertPath("/target.dart")) 5858 .getSourcesWithFullName(resourceProvider.convertPath("/target.dart"))
5714 .first; 5859 .first;
5715 expect(analysisContext2.getModificationStamp(target), -1); 5860 expect(analysisContext2.getModificationStamp(target), -1);
5716 5861
5717 // Add an overlay in the same way as AnalysisServer. 5862 // Add an overlay in the same way as AnalysisServer.
5718 analysisContext2 5863 analysisContext2
5719 ..setContents(target, "") 5864 ..setContents(target, "")
5720 ..handleContentsChanged(target, null, "", true); 5865 ..handleContentsChanged(target, null, "", true);
5721 5866
5722 // Make sure the error goes away. 5867 // Make sure the error goes away.
5723 assertErrors(source, [HintCode.UNUSED_IMPORT]); 5868 await assertErrors(source, [HintCode.UNUSED_IMPORT]);
5724 } 5869 }
5725 5870
5726 void test_uriDoesNotExist_part() { 5871 test_uriDoesNotExist_part() async {
5727 Source source = addSource(r''' 5872 Source source = addSource(r'''
5728 library lib; 5873 library lib;
5729 part 'unknown.dart';'''); 5874 part 'unknown.dart';''');
5730 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); 5875 await assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5731 } 5876 }
5732 5877
5733 void test_uriWithInterpolation_constant() { 5878 test_uriWithInterpolation_constant() async {
5734 Source source = addSource("import 'stuff_\$platform.dart';"); 5879 Source source = addSource("import 'stuff_\$platform.dart';");
5735 assertErrors(source, [ 5880 await assertErrors(source, [
5736 CompileTimeErrorCode.URI_WITH_INTERPOLATION, 5881 CompileTimeErrorCode.URI_WITH_INTERPOLATION,
5737 StaticWarningCode.UNDEFINED_IDENTIFIER 5882 StaticWarningCode.UNDEFINED_IDENTIFIER
5738 ]); 5883 ]);
5739 // We cannot verify resolution with an unresolvable 5884 // We cannot verify resolution with an unresolvable
5740 // URI: 'stuff_$platform.dart' 5885 // URI: 'stuff_$platform.dart'
5741 } 5886 }
5742 5887
5743 void test_uriWithInterpolation_nonConstant() { 5888 test_uriWithInterpolation_nonConstant() async {
5744 Source source = addSource(r''' 5889 Source source = addSource(r'''
5745 library lib; 5890 library lib;
5746 part '${'a'}.dart';'''); 5891 part '${'a'}.dart';''');
5747 assertErrors(source, [CompileTimeErrorCode.URI_WITH_INTERPOLATION]); 5892 await assertErrors(source, [CompileTimeErrorCode.URI_WITH_INTERPOLATION]);
5748 // We cannot verify resolution with an unresolvable URI: '${'a'}.dart' 5893 // We cannot verify resolution with an unresolvable URI: '${'a'}.dart'
5749 } 5894 }
5750 5895
5751 void test_wrongNumberOfParametersForOperator1() { 5896 test_wrongNumberOfParametersForOperator1() async {
5752 _check_wrongNumberOfParametersForOperator1("<"); 5897 await _check_wrongNumberOfParametersForOperator1("<");
5753 _check_wrongNumberOfParametersForOperator1(">"); 5898 await _check_wrongNumberOfParametersForOperator1(">");
5754 _check_wrongNumberOfParametersForOperator1("<="); 5899 await _check_wrongNumberOfParametersForOperator1("<=");
5755 _check_wrongNumberOfParametersForOperator1(">="); 5900 await _check_wrongNumberOfParametersForOperator1(">=");
5756 _check_wrongNumberOfParametersForOperator1("+"); 5901 await _check_wrongNumberOfParametersForOperator1("+");
5757 _check_wrongNumberOfParametersForOperator1("/"); 5902 await _check_wrongNumberOfParametersForOperator1("/");
5758 _check_wrongNumberOfParametersForOperator1("~/"); 5903 await _check_wrongNumberOfParametersForOperator1("~/");
5759 _check_wrongNumberOfParametersForOperator1("*"); 5904 await _check_wrongNumberOfParametersForOperator1("*");
5760 _check_wrongNumberOfParametersForOperator1("%"); 5905 await _check_wrongNumberOfParametersForOperator1("%");
5761 _check_wrongNumberOfParametersForOperator1("|"); 5906 await _check_wrongNumberOfParametersForOperator1("|");
5762 _check_wrongNumberOfParametersForOperator1("^"); 5907 await _check_wrongNumberOfParametersForOperator1("^");
5763 _check_wrongNumberOfParametersForOperator1("&"); 5908 await _check_wrongNumberOfParametersForOperator1("&");
5764 _check_wrongNumberOfParametersForOperator1("<<"); 5909 await _check_wrongNumberOfParametersForOperator1("<<");
5765 _check_wrongNumberOfParametersForOperator1(">>"); 5910 await _check_wrongNumberOfParametersForOperator1(">>");
5766 _check_wrongNumberOfParametersForOperator1("[]"); 5911 await _check_wrongNumberOfParametersForOperator1("[]");
5767 } 5912 }
5768 5913
5769 void test_wrongNumberOfParametersForOperator_minus() { 5914 test_wrongNumberOfParametersForOperator_minus() async {
5770 Source source = addSource(r''' 5915 Source source = addSource(r'''
5771 class A { 5916 class A {
5772 operator -(a, b) {} 5917 operator -(a, b) {}
5773 }'''); 5918 }''');
5774 assertErrors(source, 5919 await assertErrors(source,
5775 [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS]); 5920 [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS]);
5776 verify([source]); 5921 verify([source]);
5777 reset(); 5922 reset();
5778 } 5923 }
5779 5924
5780 void test_wrongNumberOfParametersForOperator_tilde() { 5925 test_wrongNumberOfParametersForOperator_tilde() async {
5781 _check_wrongNumberOfParametersForOperator("~", "a"); 5926 await _check_wrongNumberOfParametersForOperator("~", "a");
5782 _check_wrongNumberOfParametersForOperator("~", "a, b"); 5927 await _check_wrongNumberOfParametersForOperator("~", "a, b");
5783 } 5928 }
5784 5929
5785 void test_wrongNumberOfParametersForSetter_function_named() { 5930 test_wrongNumberOfParametersForSetter_function_named() async {
5786 Source source = addSource("set x({p}) {}"); 5931 Source source = addSource("set x({p}) {}");
5787 assertErrors( 5932 await assertErrors(
5788 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5933 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5789 verify([source]); 5934 verify([source]);
5790 } 5935 }
5791 5936
5792 void test_wrongNumberOfParametersForSetter_function_optional() { 5937 test_wrongNumberOfParametersForSetter_function_optional() async {
5793 Source source = addSource("set x([p]) {}"); 5938 Source source = addSource("set x([p]) {}");
5794 assertErrors( 5939 await assertErrors(
5795 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5940 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5796 verify([source]); 5941 verify([source]);
5797 } 5942 }
5798 5943
5799 void test_wrongNumberOfParametersForSetter_function_tooFew() { 5944 test_wrongNumberOfParametersForSetter_function_tooFew() async {
5800 Source source = addSource("set x() {}"); 5945 Source source = addSource("set x() {}");
5801 assertErrors( 5946 await assertErrors(
5802 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5947 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5803 verify([source]); 5948 verify([source]);
5804 } 5949 }
5805 5950
5806 void test_wrongNumberOfParametersForSetter_function_tooMany() { 5951 test_wrongNumberOfParametersForSetter_function_tooMany() async {
5807 Source source = addSource("set x(a, b) {}"); 5952 Source source = addSource("set x(a, b) {}");
5808 assertErrors( 5953 await assertErrors(
5809 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5954 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5810 verify([source]); 5955 verify([source]);
5811 } 5956 }
5812 5957
5813 void test_wrongNumberOfParametersForSetter_method_named() { 5958 test_wrongNumberOfParametersForSetter_method_named() async {
5814 Source source = addSource(r''' 5959 Source source = addSource(r'''
5815 class A { 5960 class A {
5816 set x({p}) {} 5961 set x({p}) {}
5817 }'''); 5962 }''');
5818 assertErrors( 5963 await assertErrors(
5819 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5964 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5820 verify([source]); 5965 verify([source]);
5821 } 5966 }
5822 5967
5823 void test_wrongNumberOfParametersForSetter_method_optional() { 5968 test_wrongNumberOfParametersForSetter_method_optional() async {
5824 Source source = addSource(r''' 5969 Source source = addSource(r'''
5825 class A { 5970 class A {
5826 set x([p]) {} 5971 set x([p]) {}
5827 }'''); 5972 }''');
5828 assertErrors( 5973 await assertErrors(
5829 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5974 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5830 verify([source]); 5975 verify([source]);
5831 } 5976 }
5832 5977
5833 void test_wrongNumberOfParametersForSetter_method_tooFew() { 5978 test_wrongNumberOfParametersForSetter_method_tooFew() async {
5834 Source source = addSource(r''' 5979 Source source = addSource(r'''
5835 class A { 5980 class A {
5836 set x() {} 5981 set x() {}
5837 }'''); 5982 }''');
5838 assertErrors( 5983 await assertErrors(
5839 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5984 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5840 verify([source]); 5985 verify([source]);
5841 } 5986 }
5842 5987
5843 void test_wrongNumberOfParametersForSetter_method_tooMany() { 5988 test_wrongNumberOfParametersForSetter_method_tooMany() async {
5844 Source source = addSource(r''' 5989 Source source = addSource(r'''
5845 class A { 5990 class A {
5846 set x(a, b) {} 5991 set x(a, b) {}
5847 }'''); 5992 }''');
5848 assertErrors( 5993 await assertErrors(
5849 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5994 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5850 verify([source]); 5995 verify([source]);
5851 } 5996 }
5852 5997
5853 void test_yield_used_as_identifier_in_async_method() { 5998 test_yield_used_as_identifier_in_async_method() async {
5854 Source source = addSource(''' 5999 Source source = addSource('''
5855 f() async { 6000 f() async {
5856 var yield = 1; 6001 var yield = 1;
5857 } 6002 }
5858 '''); 6003 ''');
5859 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 6004 await assertErrors(
6005 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
5860 verify([source]); 6006 verify([source]);
5861 } 6007 }
5862 6008
5863 void test_yield_used_as_identifier_in_async_star_method() { 6009 test_yield_used_as_identifier_in_async_star_method() async {
5864 Source source = addSource(''' 6010 Source source = addSource('''
5865 f() async* { 6011 f() async* {
5866 var yield = 1; 6012 var yield = 1;
5867 } 6013 }
5868 '''); 6014 ''');
5869 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 6015 await assertErrors(
6016 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
5870 verify([source]); 6017 verify([source]);
5871 } 6018 }
5872 6019
5873 void test_yield_used_as_identifier_in_sync_star_method() { 6020 test_yield_used_as_identifier_in_sync_star_method() async {
5874 Source source = addSource(''' 6021 Source source = addSource('''
5875 f() sync* { 6022 f() sync* {
5876 var yield = 1; 6023 var yield = 1;
5877 } 6024 }
5878 '''); 6025 ''');
5879 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); 6026 await assertErrors(
6027 source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
5880 verify([source]); 6028 verify([source]);
5881 } 6029 }
5882 6030
5883 void _check_constEvalThrowsException_binary_null(String expr, bool resolved) { 6031 Future<Null> _check_constEvalThrowsException_binary_null(
6032 String expr, bool resolved) async {
5884 Source source = addSource("const C = $expr;"); 6033 Source source = addSource("const C = $expr;");
5885 if (resolved) { 6034 if (resolved) {
5886 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); 6035 await assertErrors(
6036 source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
5887 verify([source]); 6037 verify([source]);
5888 } else { 6038 } else {
5889 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); 6039 await assertErrors(
6040 source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
5890 // no verify(), 'null x' is not resolved 6041 // no verify(), 'null x' is not resolved
5891 } 6042 }
5892 reset(); 6043 reset();
5893 } 6044 }
5894 6045
5895 void _check_constEvalTypeBool_withParameter_binary(String expr) { 6046 Future<Null> _check_constEvalTypeBool_withParameter_binary(
6047 String expr) async {
5896 Source source = addSource(''' 6048 Source source = addSource('''
5897 class A { 6049 class A {
5898 final a; 6050 final a;
5899 const A(bool p) : a = $expr; 6051 const A(bool p) : a = $expr;
5900 }'''); 6052 }''');
5901 assertErrors(source, [ 6053 await assertErrors(source, [
5902 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, 6054 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
5903 StaticTypeWarningCode.NON_BOOL_OPERAND 6055 StaticTypeWarningCode.NON_BOOL_OPERAND
5904 ]); 6056 ]);
5905 verify([source]); 6057 verify([source]);
5906 reset(); 6058 reset();
5907 } 6059 }
5908 6060
5909 void _check_constEvalTypeInt_withParameter_binary(String expr) { 6061 Future<Null> _check_constEvalTypeInt_withParameter_binary(String expr) async {
5910 Source source = addSource(''' 6062 Source source = addSource('''
5911 class A { 6063 class A {
5912 final a; 6064 final a;
5913 const A(int p) : a = $expr; 6065 const A(int p) : a = $expr;
5914 }'''); 6066 }''');
5915 assertErrors(source, [ 6067 await assertErrors(source, [
5916 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, 6068 CompileTimeErrorCode.CONST_EVAL_TYPE_INT,
5917 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE 6069 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
5918 ]); 6070 ]);
5919 verify([source]); 6071 verify([source]);
5920 reset(); 6072 reset();
5921 } 6073 }
5922 6074
5923 void _check_constEvalTypeNum_withParameter_binary(String expr) { 6075 Future<Null> _check_constEvalTypeNum_withParameter_binary(String expr) async {
5924 Source source = addSource(''' 6076 Source source = addSource('''
5925 class A { 6077 class A {
5926 final a; 6078 final a;
5927 const A(num p) : a = $expr; 6079 const A(num p) : a = $expr;
5928 }'''); 6080 }''');
5929 assertErrors(source, [ 6081 await assertErrors(source, [
5930 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, 6082 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM,
5931 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE 6083 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
5932 ]); 6084 ]);
5933 verify([source]); 6085 verify([source]);
5934 reset(); 6086 reset();
5935 } 6087 }
5936 6088
5937 void _check_wrongNumberOfParametersForOperator( 6089 Future<Null> _check_wrongNumberOfParametersForOperator(
5938 String name, String parameters) { 6090 String name, String parameters) async {
5939 Source source = addSource(''' 6091 Source source = addSource('''
5940 class A { 6092 class A {
5941 operator $name($parameters) {} 6093 operator $name($parameters) {}
5942 }'''); 6094 }''');
5943 assertErrors( 6095 await assertErrors(
5944 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 6096 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
5945 verify([source]); 6097 verify([source]);
5946 reset(); 6098 reset();
5947 } 6099 }
5948 6100
5949 void _check_wrongNumberOfParametersForOperator1(String name) { 6101 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async {
5950 _check_wrongNumberOfParametersForOperator(name, ""); 6102 await _check_wrongNumberOfParametersForOperator(name, "");
5951 _check_wrongNumberOfParametersForOperator(name, "a, b"); 6103 await _check_wrongNumberOfParametersForOperator(name, "a, b");
5952 } 6104 }
5953 } 6105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698