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

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

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

Powered by Google App Engine
This is Rietveld 408576698