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

Side by Side Diff: pkg/analyzer/test/generated/static_warning_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.static_warning_code_test; 5 library analyzer.test.generated.static_warning_code_test;
6 6
7 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart'; 8 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
(...skipping 13 matching lines...) Expand all
24 fail_argumentTypeNotAssignable_tearOff_required() async { 24 fail_argumentTypeNotAssignable_tearOff_required() async {
25 Source source = addSource(r''' 25 Source source = addSource(r'''
26 class C { 26 class C {
27 Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x; 27 Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x;
28 } 28 }
29 g(C c) { 29 g(C c) {
30 var h = c.f/*<int>*/; 30 var h = c.f/*<int>*/;
31 print(h('s')); 31 print(h('s'));
32 } 32 }
33 '''); 33 ''');
34 await computeAnalysisResult(source);
34 await assertErrors( 35 await assertErrors(
35 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 36 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
36 verify([source]); 37 verify([source]);
37 } 38 }
38 39
39 fail_undefinedGetter() async { 40 fail_undefinedGetter() async {
40 Source source = addSource(r''' 41 Source source = addSource(r'''
41 '''); 42 ''');
43 await computeAnalysisResult(source);
42 await assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]); 44 await assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]);
43 verify([source]); 45 verify([source]);
44 } 46 }
45 47
46 fail_undefinedIdentifier_commentReference() async { 48 fail_undefinedIdentifier_commentReference() async {
47 Source source = addSource(r''' 49 Source source = addSource(r'''
48 /** [m] xxx [new B.c] */ 50 /** [m] xxx [new B.c] */
49 class A { 51 class A {
50 }'''); 52 }''');
53 await computeAnalysisResult(source);
51 await assertErrors(source, [ 54 await assertErrors(source, [
52 StaticWarningCode.UNDEFINED_IDENTIFIER, 55 StaticWarningCode.UNDEFINED_IDENTIFIER,
53 StaticWarningCode.UNDEFINED_IDENTIFIER 56 StaticWarningCode.UNDEFINED_IDENTIFIER
54 ]); 57 ]);
55 } 58 }
56 59
57 fail_undefinedSetter() async { 60 fail_undefinedSetter() async {
58 Source source = addSource(r''' 61 Source source = addSource(r'''
59 class C {} 62 class C {}
60 f(var p) { 63 f(var p) {
61 C.m = 0; 64 C.m = 0;
62 }'''); 65 }''');
66 await computeAnalysisResult(source);
63 await assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]); 67 await assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]);
64 verify([source]); 68 verify([source]);
65 } 69 }
66 70
67 test_ambiguousImport_as() async { 71 test_ambiguousImport_as() async {
68 Source source = addSource(r''' 72 Source source = addSource(r'''
69 import 'lib1.dart'; 73 import 'lib1.dart';
70 import 'lib2.dart'; 74 import 'lib2.dart';
71 f(p) {p as N;}'''); 75 f(p) {p as N;}''');
72 addNamedSource( 76 addNamedSource(
73 "/lib1.dart", 77 "/lib1.dart",
74 r''' 78 r'''
75 library lib1; 79 library lib1;
76 class N {}'''); 80 class N {}''');
77 addNamedSource( 81 addNamedSource(
78 "/lib2.dart", 82 "/lib2.dart",
79 r''' 83 r'''
80 library lib2; 84 library lib2;
81 class N {}'''); 85 class N {}''');
86 await computeAnalysisResult(source);
82 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 87 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
83 } 88 }
84 89
85 test_ambiguousImport_extends() async { 90 test_ambiguousImport_extends() async {
86 Source source = addSource(r''' 91 Source source = addSource(r'''
87 import 'lib1.dart'; 92 import 'lib1.dart';
88 import 'lib2.dart'; 93 import 'lib2.dart';
89 class A extends N {}'''); 94 class A extends N {}''');
90 addNamedSource( 95 addNamedSource(
91 "/lib1.dart", 96 "/lib1.dart",
92 r''' 97 r'''
93 library lib1; 98 library lib1;
94 class N {}'''); 99 class N {}''');
95 addNamedSource( 100 addNamedSource(
96 "/lib2.dart", 101 "/lib2.dart",
97 r''' 102 r'''
98 library lib2; 103 library lib2;
99 class N {}'''); 104 class N {}''');
105 await computeAnalysisResult(source);
100 await assertErrors(source, [ 106 await assertErrors(source, [
101 StaticWarningCode.AMBIGUOUS_IMPORT, 107 StaticWarningCode.AMBIGUOUS_IMPORT,
102 CompileTimeErrorCode.EXTENDS_NON_CLASS 108 CompileTimeErrorCode.EXTENDS_NON_CLASS
103 ]); 109 ]);
104 } 110 }
105 111
106 test_ambiguousImport_implements() async { 112 test_ambiguousImport_implements() async {
107 Source source = addSource(r''' 113 Source source = addSource(r'''
108 import 'lib1.dart'; 114 import 'lib1.dart';
109 import 'lib2.dart'; 115 import 'lib2.dart';
110 class A implements N {}'''); 116 class A implements N {}''');
111 addNamedSource( 117 addNamedSource(
112 "/lib1.dart", 118 "/lib1.dart",
113 r''' 119 r'''
114 library lib1; 120 library lib1;
115 class N {}'''); 121 class N {}''');
116 addNamedSource( 122 addNamedSource(
117 "/lib2.dart", 123 "/lib2.dart",
118 r''' 124 r'''
119 library lib2; 125 library lib2;
120 class N {}'''); 126 class N {}''');
127 await computeAnalysisResult(source);
121 await assertErrors(source, [ 128 await assertErrors(source, [
122 StaticWarningCode.AMBIGUOUS_IMPORT, 129 StaticWarningCode.AMBIGUOUS_IMPORT,
123 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS 130 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS
124 ]); 131 ]);
125 } 132 }
126 133
127 test_ambiguousImport_inPart() async { 134 test_ambiguousImport_inPart() async {
128 Source source = addSource(r''' 135 Source source = addSource(r'''
129 library lib; 136 library lib;
130 import 'lib1.dart'; 137 import 'lib1.dart';
131 import 'lib2.dart'; 138 import 'lib2.dart';
132 part 'part.dart';'''); 139 part 'part.dart';''');
133 addNamedSource( 140 addNamedSource(
134 "/lib1.dart", 141 "/lib1.dart",
135 r''' 142 r'''
136 library lib1; 143 library lib1;
137 class N {}'''); 144 class N {}''');
138 addNamedSource( 145 addNamedSource(
139 "/lib2.dart", 146 "/lib2.dart",
140 r''' 147 r'''
141 library lib2; 148 library lib2;
142 class N {}'''); 149 class N {}''');
143 Source partSource = addNamedSource( 150 Source partSource = addNamedSource(
144 "/part.dart", 151 "/part.dart",
145 r''' 152 r'''
146 part of lib; 153 part of lib;
147 class A extends N {}'''); 154 class A extends N {}''');
155 await computeAnalysisResult(source);
156 await computeAnalysisResult(partSource);
148 await assertNoErrors(source); 157 await assertNoErrors(source);
149 await assertErrors(partSource, [ 158 await assertErrors(partSource, [
150 StaticWarningCode.AMBIGUOUS_IMPORT, 159 StaticWarningCode.AMBIGUOUS_IMPORT,
151 CompileTimeErrorCode.EXTENDS_NON_CLASS 160 CompileTimeErrorCode.EXTENDS_NON_CLASS
152 ]); 161 ]);
153 } 162 }
154 163
155 test_ambiguousImport_instanceCreation() async { 164 test_ambiguousImport_instanceCreation() async {
156 Source source = addSource(r''' 165 Source source = addSource(r'''
157 library L; 166 library L;
158 import 'lib1.dart'; 167 import 'lib1.dart';
159 import 'lib2.dart'; 168 import 'lib2.dart';
160 f() {new N();}'''); 169 f() {new N();}''');
161 addNamedSource( 170 addNamedSource(
162 "/lib1.dart", 171 "/lib1.dart",
163 r''' 172 r'''
164 library lib1; 173 library lib1;
165 class N {}'''); 174 class N {}''');
166 addNamedSource( 175 addNamedSource(
167 "/lib2.dart", 176 "/lib2.dart",
168 r''' 177 r'''
169 library lib2; 178 library lib2;
170 class N {}'''); 179 class N {}''');
180 await computeAnalysisResult(source);
171 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 181 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
172 } 182 }
173 183
174 test_ambiguousImport_is() async { 184 test_ambiguousImport_is() async {
175 Source source = addSource(r''' 185 Source source = addSource(r'''
176 import 'lib1.dart'; 186 import 'lib1.dart';
177 import 'lib2.dart'; 187 import 'lib2.dart';
178 f(p) {p is N;}'''); 188 f(p) {p is N;}''');
179 addNamedSource( 189 addNamedSource(
180 "/lib1.dart", 190 "/lib1.dart",
181 r''' 191 r'''
182 library lib1; 192 library lib1;
183 class N {}'''); 193 class N {}''');
184 addNamedSource( 194 addNamedSource(
185 "/lib2.dart", 195 "/lib2.dart",
186 r''' 196 r'''
187 library lib2; 197 library lib2;
188 class N {}'''); 198 class N {}''');
199 await computeAnalysisResult(source);
189 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 200 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
190 } 201 }
191 202
192 test_ambiguousImport_qualifier() async { 203 test_ambiguousImport_qualifier() async {
193 Source source = addSource(r''' 204 Source source = addSource(r'''
194 import 'lib1.dart'; 205 import 'lib1.dart';
195 import 'lib2.dart'; 206 import 'lib2.dart';
196 g() { N.FOO; }'''); 207 g() { N.FOO; }''');
197 addNamedSource( 208 addNamedSource(
198 "/lib1.dart", 209 "/lib1.dart",
199 r''' 210 r'''
200 library lib1; 211 library lib1;
201 class N {}'''); 212 class N {}''');
202 addNamedSource( 213 addNamedSource(
203 "/lib2.dart", 214 "/lib2.dart",
204 r''' 215 r'''
205 library lib2; 216 library lib2;
206 class N {}'''); 217 class N {}''');
218 await computeAnalysisResult(source);
207 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 219 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
208 } 220 }
209 221
210 test_ambiguousImport_typeAnnotation() async { 222 test_ambiguousImport_typeAnnotation() async {
211 Source source = addSource(r''' 223 Source source = addSource(r'''
212 import 'lib1.dart'; 224 import 'lib1.dart';
213 import 'lib2.dart'; 225 import 'lib2.dart';
214 typedef N FT(N p); 226 typedef N FT(N p);
215 N f(N p) { 227 N f(N p) {
216 N v; 228 N v;
217 return null; 229 return null;
218 } 230 }
219 class A { 231 class A {
220 N m() { return null; } 232 N m() { return null; }
221 } 233 }
222 class B<T extends N> {}'''); 234 class B<T extends N> {}''');
223 addNamedSource( 235 addNamedSource(
224 "/lib1.dart", 236 "/lib1.dart",
225 r''' 237 r'''
226 library lib1; 238 library lib1;
227 class N {}'''); 239 class N {}''');
228 addNamedSource( 240 addNamedSource(
229 "/lib2.dart", 241 "/lib2.dart",
230 r''' 242 r'''
231 library lib2; 243 library lib2;
232 class N {}'''); 244 class N {}''');
245 await computeAnalysisResult(source);
233 await assertErrors(source, [ 246 await assertErrors(source, [
234 StaticWarningCode.AMBIGUOUS_IMPORT, 247 StaticWarningCode.AMBIGUOUS_IMPORT,
235 StaticWarningCode.AMBIGUOUS_IMPORT, 248 StaticWarningCode.AMBIGUOUS_IMPORT,
236 StaticWarningCode.AMBIGUOUS_IMPORT, 249 StaticWarningCode.AMBIGUOUS_IMPORT,
237 StaticWarningCode.AMBIGUOUS_IMPORT, 250 StaticWarningCode.AMBIGUOUS_IMPORT,
238 StaticWarningCode.AMBIGUOUS_IMPORT, 251 StaticWarningCode.AMBIGUOUS_IMPORT,
239 StaticWarningCode.AMBIGUOUS_IMPORT, 252 StaticWarningCode.AMBIGUOUS_IMPORT,
240 StaticWarningCode.AMBIGUOUS_IMPORT 253 StaticWarningCode.AMBIGUOUS_IMPORT
241 ]); 254 ]);
242 } 255 }
243 256
244 test_ambiguousImport_typeArgument_annotation() async { 257 test_ambiguousImport_typeArgument_annotation() async {
245 Source source = addSource(r''' 258 Source source = addSource(r'''
246 import 'lib1.dart'; 259 import 'lib1.dart';
247 import 'lib2.dart'; 260 import 'lib2.dart';
248 class A<T> {} 261 class A<T> {}
249 A<N> f() { return null; }'''); 262 A<N> f() { return null; }''');
250 addNamedSource( 263 addNamedSource(
251 "/lib1.dart", 264 "/lib1.dart",
252 r''' 265 r'''
253 library lib1; 266 library lib1;
254 class N {}'''); 267 class N {}''');
255 addNamedSource( 268 addNamedSource(
256 "/lib2.dart", 269 "/lib2.dart",
257 r''' 270 r'''
258 library lib2; 271 library lib2;
259 class N {}'''); 272 class N {}''');
273 await computeAnalysisResult(source);
260 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 274 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
261 } 275 }
262 276
263 test_ambiguousImport_typeArgument_instanceCreation() async { 277 test_ambiguousImport_typeArgument_instanceCreation() async {
264 Source source = addSource(r''' 278 Source source = addSource(r'''
265 import 'lib1.dart'; 279 import 'lib1.dart';
266 import 'lib2.dart'; 280 import 'lib2.dart';
267 class A<T> {} 281 class A<T> {}
268 f() {new A<N>();}'''); 282 f() {new A<N>();}''');
269 addNamedSource( 283 addNamedSource(
270 "/lib1.dart", 284 "/lib1.dart",
271 r''' 285 r'''
272 library lib1; 286 library lib1;
273 class N {}'''); 287 class N {}''');
274 addNamedSource( 288 addNamedSource(
275 "/lib2.dart", 289 "/lib2.dart",
276 r''' 290 r'''
277 library lib2; 291 library lib2;
278 class N {}'''); 292 class N {}''');
293 await computeAnalysisResult(source);
279 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 294 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
280 } 295 }
281 296
282 test_ambiguousImport_varRead() async { 297 test_ambiguousImport_varRead() async {
283 Source source = addSource(r''' 298 Source source = addSource(r'''
284 import 'lib1.dart'; 299 import 'lib1.dart';
285 import 'lib2.dart'; 300 import 'lib2.dart';
286 f() { g(v); } 301 f() { g(v); }
287 g(p) {}'''); 302 g(p) {}''');
288 addNamedSource( 303 addNamedSource(
289 "/lib1.dart", 304 "/lib1.dart",
290 r''' 305 r'''
291 library lib1; 306 library lib1;
292 var v;'''); 307 var v;''');
293 addNamedSource( 308 addNamedSource(
294 "/lib2.dart", 309 "/lib2.dart",
295 r''' 310 r'''
296 library lib2; 311 library lib2;
297 var v;'''); 312 var v;''');
313 await computeAnalysisResult(source);
298 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 314 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
299 } 315 }
300 316
301 test_ambiguousImport_varWrite() async { 317 test_ambiguousImport_varWrite() async {
302 Source source = addSource(r''' 318 Source source = addSource(r'''
303 import 'lib1.dart'; 319 import 'lib1.dart';
304 import 'lib2.dart'; 320 import 'lib2.dart';
305 f() { v = 0; }'''); 321 f() { v = 0; }''');
306 addNamedSource( 322 addNamedSource(
307 "/lib1.dart", 323 "/lib1.dart",
308 r''' 324 r'''
309 library lib1; 325 library lib1;
310 var v;'''); 326 var v;''');
311 addNamedSource( 327 addNamedSource(
312 "/lib2.dart", 328 "/lib2.dart",
313 r''' 329 r'''
314 library lib2; 330 library lib2;
315 var v;'''); 331 var v;''');
332 await computeAnalysisResult(source);
316 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 333 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
317 } 334 }
318 335
319 test_ambiguousImport_withPrefix() async { 336 test_ambiguousImport_withPrefix() async {
320 Source source = addSource(r''' 337 Source source = addSource(r'''
321 library test; 338 library test;
322 import 'lib1.dart' as p; 339 import 'lib1.dart' as p;
323 import 'lib2.dart' as p; 340 import 'lib2.dart' as p;
324 main() { 341 main() {
325 p.f(); 342 p.f();
326 }'''); 343 }''');
327 addNamedSource( 344 addNamedSource(
328 "/lib1.dart", 345 "/lib1.dart",
329 r''' 346 r'''
330 library lib1; 347 library lib1;
331 f() {}'''); 348 f() {}''');
332 addNamedSource( 349 addNamedSource(
333 "/lib2.dart", 350 "/lib2.dart",
334 r''' 351 r'''
335 library lib2; 352 library lib2;
336 f() {}'''); 353 f() {}''');
354 await computeAnalysisResult(source);
337 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); 355 await assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
338 } 356 }
339 357
340 test_argumentTypeNotAssignable_ambiguousClassName() async { 358 test_argumentTypeNotAssignable_ambiguousClassName() async {
341 // See dartbug.com/19624 359 // See dartbug.com/19624
342 Source source = addNamedSource( 360 Source source = addNamedSource(
343 "/lib1.dart", 361 "/lib1.dart",
344 r''' 362 r'''
345 library lib1; 363 library lib1;
346 import 'lib2.dart'; 364 import 'lib2.dart';
(...skipping 21 matching lines...) Expand all
368 } 386 }
369 387
370 test_argumentTypeNotAssignable_annotation_namedConstructor() async { 388 test_argumentTypeNotAssignable_annotation_namedConstructor() async {
371 Source source = addSource(r''' 389 Source source = addSource(r'''
372 class A { 390 class A {
373 const A.fromInt(int p); 391 const A.fromInt(int p);
374 } 392 }
375 @A.fromInt('0') 393 @A.fromInt('0')
376 main() { 394 main() {
377 }'''); 395 }''');
396 await computeAnalysisResult(source);
378 await assertErrors( 397 await assertErrors(
379 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 398 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
380 verify([source]); 399 verify([source]);
381 } 400 }
382 401
383 test_argumentTypeNotAssignable_annotation_unnamedConstructor() async { 402 test_argumentTypeNotAssignable_annotation_unnamedConstructor() async {
384 Source source = addSource(r''' 403 Source source = addSource(r'''
385 class A { 404 class A {
386 const A(int p); 405 const A(int p);
387 } 406 }
388 @A('0') 407 @A('0')
389 main() { 408 main() {
390 }'''); 409 }''');
410 await computeAnalysisResult(source);
391 await assertErrors( 411 await assertErrors(
392 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 412 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
393 verify([source]); 413 verify([source]);
394 } 414 }
395 415
396 test_argumentTypeNotAssignable_binary() async { 416 test_argumentTypeNotAssignable_binary() async {
397 Source source = addSource(r''' 417 Source source = addSource(r'''
398 class A { 418 class A {
399 operator +(int p) {} 419 operator +(int p) {}
400 } 420 }
401 f(A a) { 421 f(A a) {
402 a + '0'; 422 a + '0';
403 }'''); 423 }''');
424 await computeAnalysisResult(source);
404 await assertErrors( 425 await assertErrors(
405 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 426 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
406 verify([source]); 427 verify([source]);
407 } 428 }
408 429
409 test_argumentTypeNotAssignable_cascadeSecond() async { 430 test_argumentTypeNotAssignable_cascadeSecond() async {
410 Source source = addSource(r''' 431 Source source = addSource(r'''
411 // filler filler filler filler filler filler filler filler filler filler 432 // filler filler filler filler filler filler filler filler filler filler
412 class A { 433 class A {
413 B ma() { return new B(); } 434 B ma() { return new B(); }
414 } 435 }
415 class B { 436 class B {
416 mb(String p) {} 437 mb(String p) {}
417 } 438 }
418 439
419 main() { 440 main() {
420 A a = new A(); 441 A a = new A();
421 a.. ma().mb(0); 442 a.. ma().mb(0);
422 }'''); 443 }''');
444 await computeAnalysisResult(source);
423 await assertErrors( 445 await assertErrors(
424 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 446 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
425 verify([source]); 447 verify([source]);
426 } 448 }
427 449
428 test_argumentTypeNotAssignable_const() async { 450 test_argumentTypeNotAssignable_const() async {
429 Source source = addSource(r''' 451 Source source = addSource(r'''
430 class A { 452 class A {
431 const A(String p); 453 const A(String p);
432 } 454 }
433 main() { 455 main() {
434 const A(42); 456 const A(42);
435 }'''); 457 }''');
458 await computeAnalysisResult(source);
436 await assertErrors(source, [ 459 await assertErrors(source, [
437 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 460 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
438 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH 461 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
439 ]); 462 ]);
440 verify([source]); 463 verify([source]);
441 } 464 }
442 465
443 test_argumentTypeNotAssignable_const_super() async { 466 test_argumentTypeNotAssignable_const_super() async {
444 Source source = addSource(r''' 467 Source source = addSource(r'''
445 class A { 468 class A {
446 const A(String p); 469 const A(String p);
447 } 470 }
448 class B extends A { 471 class B extends A {
449 const B() : super(42); 472 const B() : super(42);
450 }'''); 473 }''');
474 await computeAnalysisResult(source);
451 await assertErrors( 475 await assertErrors(
452 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 476 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
453 verify([source]); 477 verify([source]);
454 } 478 }
455 479
456 test_argumentTypeNotAssignable_functionExpressionInvocation_required() async { 480 test_argumentTypeNotAssignable_functionExpressionInvocation_required() async {
457 Source source = addSource(r''' 481 Source source = addSource(r'''
458 main() { 482 main() {
459 (int x) {} (''); 483 (int x) {} ('');
460 }'''); 484 }''');
485 await computeAnalysisResult(source);
461 await assertErrors( 486 await assertErrors(
462 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 487 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
463 verify([source]); 488 verify([source]);
464 } 489 }
465 490
466 test_argumentTypeNotAssignable_index() async { 491 test_argumentTypeNotAssignable_index() async {
467 Source source = addSource(r''' 492 Source source = addSource(r'''
468 class A { 493 class A {
469 operator [](int index) {} 494 operator [](int index) {}
470 } 495 }
471 f(A a) { 496 f(A a) {
472 a['0']; 497 a['0'];
473 }'''); 498 }''');
499 await computeAnalysisResult(source);
474 await assertErrors( 500 await assertErrors(
475 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 501 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
476 verify([source]); 502 verify([source]);
477 } 503 }
478 504
479 test_argumentTypeNotAssignable_invocation_callParameter() async { 505 test_argumentTypeNotAssignable_invocation_callParameter() async {
480 Source source = addSource(r''' 506 Source source = addSource(r'''
481 class A { 507 class A {
482 call(int p) {} 508 call(int p) {}
483 } 509 }
484 f(A a) { 510 f(A a) {
485 a('0'); 511 a('0');
486 }'''); 512 }''');
513 await computeAnalysisResult(source);
487 await assertErrors( 514 await assertErrors(
488 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 515 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
489 verify([source]); 516 verify([source]);
490 } 517 }
491 518
492 test_argumentTypeNotAssignable_invocation_callVariable() async { 519 test_argumentTypeNotAssignable_invocation_callVariable() async {
493 Source source = addSource(r''' 520 Source source = addSource(r'''
494 class A { 521 class A {
495 call(int p) {} 522 call(int p) {}
496 } 523 }
497 main() { 524 main() {
498 A a = new A(); 525 A a = new A();
499 a('0'); 526 a('0');
500 }'''); 527 }''');
528 await computeAnalysisResult(source);
501 await assertErrors( 529 await assertErrors(
502 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 530 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
503 verify([source]); 531 verify([source]);
504 } 532 }
505 533
506 test_argumentTypeNotAssignable_invocation_functionParameter() async { 534 test_argumentTypeNotAssignable_invocation_functionParameter() async {
507 Source source = addSource(r''' 535 Source source = addSource(r'''
508 a(b(int p)) { 536 a(b(int p)) {
509 b('0'); 537 b('0');
510 }'''); 538 }''');
539 await computeAnalysisResult(source);
511 await assertErrors( 540 await assertErrors(
512 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 541 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
513 verify([source]); 542 verify([source]);
514 } 543 }
515 544
516 test_argumentTypeNotAssignable_invocation_functionParameter_generic() async { 545 test_argumentTypeNotAssignable_invocation_functionParameter_generic() async {
517 Source source = addSource(r''' 546 Source source = addSource(r'''
518 class A<K, V> { 547 class A<K, V> {
519 m(f(K k), V v) { 548 m(f(K k), V v) {
520 f(v); 549 f(v);
521 } 550 }
522 }'''); 551 }''');
552 await computeAnalysisResult(source);
523 await assertErrors( 553 await assertErrors(
524 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 554 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
525 verify([source]); 555 verify([source]);
526 } 556 }
527 557
528 test_argumentTypeNotAssignable_invocation_functionTypes_optional() async { 558 test_argumentTypeNotAssignable_invocation_functionTypes_optional() async {
529 Source source = addSource(r''' 559 Source source = addSource(r'''
530 void acceptFunNumOptBool(void funNumOptBool([bool b])) {} 560 void acceptFunNumOptBool(void funNumOptBool([bool b])) {}
531 void funNumBool(bool b) {} 561 void funNumBool(bool b) {}
532 main() { 562 main() {
533 acceptFunNumOptBool(funNumBool); 563 acceptFunNumOptBool(funNumBool);
534 }'''); 564 }''');
565 await computeAnalysisResult(source);
535 await assertErrors( 566 await assertErrors(
536 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 567 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
537 verify([source]); 568 verify([source]);
538 } 569 }
539 570
540 test_argumentTypeNotAssignable_invocation_generic() async { 571 test_argumentTypeNotAssignable_invocation_generic() async {
541 Source source = addSource(r''' 572 Source source = addSource(r'''
542 class A<T> { 573 class A<T> {
543 m(T t) {} 574 m(T t) {}
544 } 575 }
545 f(A<String> a) { 576 f(A<String> a) {
546 a.m(1); 577 a.m(1);
547 }'''); 578 }''');
579 await computeAnalysisResult(source);
548 await assertErrors( 580 await assertErrors(
549 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 581 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
550 verify([source]); 582 verify([source]);
551 } 583 }
552 584
553 test_argumentTypeNotAssignable_invocation_named() async { 585 test_argumentTypeNotAssignable_invocation_named() async {
554 Source source = addSource(r''' 586 Source source = addSource(r'''
555 f({String p}) {} 587 f({String p}) {}
556 main() { 588 main() {
557 f(p: 42); 589 f(p: 42);
558 }'''); 590 }''');
591 await computeAnalysisResult(source);
559 await assertErrors( 592 await assertErrors(
560 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 593 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
561 verify([source]); 594 verify([source]);
562 } 595 }
563 596
564 test_argumentTypeNotAssignable_invocation_optional() async { 597 test_argumentTypeNotAssignable_invocation_optional() async {
565 Source source = addSource(r''' 598 Source source = addSource(r'''
566 f([String p]) {} 599 f([String p]) {}
567 main() { 600 main() {
568 f(42); 601 f(42);
569 }'''); 602 }''');
603 await computeAnalysisResult(source);
570 await assertErrors( 604 await assertErrors(
571 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 605 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
572 verify([source]); 606 verify([source]);
573 } 607 }
574 608
575 test_argumentTypeNotAssignable_invocation_required() async { 609 test_argumentTypeNotAssignable_invocation_required() async {
576 Source source = addSource(r''' 610 Source source = addSource(r'''
577 f(String p) {} 611 f(String p) {}
578 main() { 612 main() {
579 f(42); 613 f(42);
580 }'''); 614 }''');
615 await computeAnalysisResult(source);
581 await assertErrors( 616 await assertErrors(
582 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 617 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
583 verify([source]); 618 verify([source]);
584 } 619 }
585 620
586 test_argumentTypeNotAssignable_invocation_typedef_generic() async { 621 test_argumentTypeNotAssignable_invocation_typedef_generic() async {
587 Source source = addSource(r''' 622 Source source = addSource(r'''
588 typedef A<T>(T p); 623 typedef A<T>(T p);
589 f(A<int> a) { 624 f(A<int> a) {
590 a('1'); 625 a('1');
591 }'''); 626 }''');
627 await computeAnalysisResult(source);
592 await assertErrors( 628 await assertErrors(
593 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 629 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
594 verify([source]); 630 verify([source]);
595 } 631 }
596 632
597 test_argumentTypeNotAssignable_invocation_typedef_local() async { 633 test_argumentTypeNotAssignable_invocation_typedef_local() async {
598 Source source = addSource(r''' 634 Source source = addSource(r'''
599 typedef A(int p); 635 typedef A(int p);
600 A getA() => null; 636 A getA() => null;
601 main() { 637 main() {
602 A a = getA(); 638 A a = getA();
603 a('1'); 639 a('1');
604 }'''); 640 }''');
641 await computeAnalysisResult(source);
605 await assertErrors( 642 await assertErrors(
606 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 643 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
607 verify([source]); 644 verify([source]);
608 } 645 }
609 646
610 test_argumentTypeNotAssignable_invocation_typedef_parameter() async { 647 test_argumentTypeNotAssignable_invocation_typedef_parameter() async {
611 Source source = addSource(r''' 648 Source source = addSource(r'''
612 typedef A(int p); 649 typedef A(int p);
613 f(A a) { 650 f(A a) {
614 a('1'); 651 a('1');
615 }'''); 652 }''');
653 await computeAnalysisResult(source);
616 await assertErrors( 654 await assertErrors(
617 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 655 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
618 verify([source]); 656 verify([source]);
619 } 657 }
620 658
621 test_argumentTypeNotAssignable_new_generic() async { 659 test_argumentTypeNotAssignable_new_generic() async {
622 Source source = addSource(r''' 660 Source source = addSource(r'''
623 class A<T> { 661 class A<T> {
624 A(T p) {} 662 A(T p) {}
625 } 663 }
626 main() { 664 main() {
627 new A<String>(42); 665 new A<String>(42);
628 }'''); 666 }''');
667 await computeAnalysisResult(source);
629 await assertErrors( 668 await assertErrors(
630 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 669 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
631 verify([source]); 670 verify([source]);
632 } 671 }
633 672
634 test_argumentTypeNotAssignable_new_optional() async { 673 test_argumentTypeNotAssignable_new_optional() async {
635 Source source = addSource(r''' 674 Source source = addSource(r'''
636 class A { 675 class A {
637 A([String p]) {} 676 A([String p]) {}
638 } 677 }
639 main() { 678 main() {
640 new A(42); 679 new A(42);
641 }'''); 680 }''');
681 await computeAnalysisResult(source);
642 await assertErrors( 682 await assertErrors(
643 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 683 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
644 verify([source]); 684 verify([source]);
645 } 685 }
646 686
647 test_argumentTypeNotAssignable_new_required() async { 687 test_argumentTypeNotAssignable_new_required() async {
648 Source source = addSource(r''' 688 Source source = addSource(r'''
649 class A { 689 class A {
650 A(String p) {} 690 A(String p) {}
651 } 691 }
652 main() { 692 main() {
653 new A(42); 693 new A(42);
654 }'''); 694 }''');
695 await computeAnalysisResult(source);
655 await assertErrors( 696 await assertErrors(
656 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 697 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
657 verify([source]); 698 verify([source]);
658 } 699 }
659 700
660 test_assignmentToClass() async { 701 test_assignmentToClass() async {
661 Source source = addSource(''' 702 Source source = addSource('''
662 class C {} 703 class C {}
663 main() { 704 main() {
664 C = null; 705 C = null;
665 } 706 }
666 '''); 707 ''');
708 await computeAnalysisResult(source);
667 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]); 709 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
668 } 710 }
669 711
670 test_assignmentToConst_instanceVariable() async { 712 test_assignmentToConst_instanceVariable() async {
671 Source source = addSource(r''' 713 Source source = addSource(r'''
672 class A { 714 class A {
673 static const v = 0; 715 static const v = 0;
674 } 716 }
675 f() { 717 f() {
676 A.v = 1; 718 A.v = 1;
677 }'''); 719 }''');
720 await computeAnalysisResult(source);
678 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); 721 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
679 verify([source]); 722 verify([source]);
680 } 723 }
681 724
682 test_assignmentToConst_instanceVariable_plusEq() async { 725 test_assignmentToConst_instanceVariable_plusEq() async {
683 Source source = addSource(r''' 726 Source source = addSource(r'''
684 class A { 727 class A {
685 static const v = 0; 728 static const v = 0;
686 } 729 }
687 f() { 730 f() {
688 A.v += 1; 731 A.v += 1;
689 }'''); 732 }''');
733 await computeAnalysisResult(source);
690 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); 734 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
691 verify([source]); 735 verify([source]);
692 } 736 }
693 737
694 test_assignmentToConst_localVariable() async { 738 test_assignmentToConst_localVariable() async {
695 Source source = addSource(r''' 739 Source source = addSource(r'''
696 f() { 740 f() {
697 const x = 0; 741 const x = 0;
698 x = 1; 742 x = 1;
699 }'''); 743 }''');
744 await computeAnalysisResult(source);
700 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); 745 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
701 verify([source]); 746 verify([source]);
702 } 747 }
703 748
704 test_assignmentToConst_localVariable_plusEq() async { 749 test_assignmentToConst_localVariable_plusEq() async {
705 Source source = addSource(r''' 750 Source source = addSource(r'''
706 f() { 751 f() {
707 const x = 0; 752 const x = 0;
708 x += 1; 753 x += 1;
709 }'''); 754 }''');
755 await computeAnalysisResult(source);
710 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); 756 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
711 verify([source]); 757 verify([source]);
712 } 758 }
713 759
714 test_assignmentToEnumType() async { 760 test_assignmentToEnumType() async {
715 Source source = addSource(''' 761 Source source = addSource('''
716 enum E { e } 762 enum E { e }
717 main() { 763 main() {
718 E = null; 764 E = null;
719 } 765 }
720 '''); 766 ''');
767 await computeAnalysisResult(source);
721 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]); 768 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
722 } 769 }
723 770
724 test_assignmentToFinal_instanceVariable() async { 771 test_assignmentToFinal_instanceVariable() async {
725 Source source = addSource(r''' 772 Source source = addSource(r'''
726 class A { 773 class A {
727 final v = 0; 774 final v = 0;
728 } 775 }
729 f() { 776 f() {
730 A a = new A(); 777 A a = new A();
731 a.v = 1; 778 a.v = 1;
732 }'''); 779 }''');
780 await computeAnalysisResult(source);
733 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 781 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
734 verify([source]); 782 verify([source]);
735 } 783 }
736 784
737 test_assignmentToFinal_instanceVariable_plusEq() async { 785 test_assignmentToFinal_instanceVariable_plusEq() async {
738 Source source = addSource(r''' 786 Source source = addSource(r'''
739 class A { 787 class A {
740 final v = 0; 788 final v = 0;
741 } 789 }
742 f() { 790 f() {
743 A a = new A(); 791 A a = new A();
744 a.v += 1; 792 a.v += 1;
745 }'''); 793 }''');
794 await computeAnalysisResult(source);
746 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 795 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
747 verify([source]); 796 verify([source]);
748 } 797 }
749 798
750 test_assignmentToFinal_localVariable() async { 799 test_assignmentToFinal_localVariable() async {
751 Source source = addSource(r''' 800 Source source = addSource(r'''
752 f() { 801 f() {
753 final x = 0; 802 final x = 0;
754 x = 1; 803 x = 1;
755 }'''); 804 }''');
805 await computeAnalysisResult(source);
756 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 806 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
757 verify([source]); 807 verify([source]);
758 } 808 }
759 809
760 test_assignmentToFinal_localVariable_plusEq() async { 810 test_assignmentToFinal_localVariable_plusEq() async {
761 Source source = addSource(r''' 811 Source source = addSource(r'''
762 f() { 812 f() {
763 final x = 0; 813 final x = 0;
764 x += 1; 814 x += 1;
765 }'''); 815 }''');
816 await computeAnalysisResult(source);
766 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 817 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
767 verify([source]); 818 verify([source]);
768 } 819 }
769 820
770 test_assignmentToFinal_postfixMinusMinus() async { 821 test_assignmentToFinal_postfixMinusMinus() async {
771 Source source = addSource(r''' 822 Source source = addSource(r'''
772 f() { 823 f() {
773 final x = 0; 824 final x = 0;
774 x--; 825 x--;
775 }'''); 826 }''');
827 await computeAnalysisResult(source);
776 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 828 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
777 verify([source]); 829 verify([source]);
778 } 830 }
779 831
780 test_assignmentToFinal_postfixPlusPlus() async { 832 test_assignmentToFinal_postfixPlusPlus() async {
781 Source source = addSource(r''' 833 Source source = addSource(r'''
782 f() { 834 f() {
783 final x = 0; 835 final x = 0;
784 x++; 836 x++;
785 }'''); 837 }''');
838 await computeAnalysisResult(source);
786 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 839 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
787 verify([source]); 840 verify([source]);
788 } 841 }
789 842
790 test_assignmentToFinal_prefixMinusMinus() async { 843 test_assignmentToFinal_prefixMinusMinus() async {
791 Source source = addSource(r''' 844 Source source = addSource(r'''
792 f() { 845 f() {
793 final x = 0; 846 final x = 0;
794 --x; 847 --x;
795 }'''); 848 }''');
849 await computeAnalysisResult(source);
796 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 850 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
797 verify([source]); 851 verify([source]);
798 } 852 }
799 853
800 test_assignmentToFinal_prefixPlusPlus() async { 854 test_assignmentToFinal_prefixPlusPlus() async {
801 Source source = addSource(r''' 855 Source source = addSource(r'''
802 f() { 856 f() {
803 final x = 0; 857 final x = 0;
804 ++x; 858 ++x;
805 }'''); 859 }''');
860 await computeAnalysisResult(source);
806 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 861 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
807 verify([source]); 862 verify([source]);
808 } 863 }
809 864
810 test_assignmentToFinal_suffixMinusMinus() async { 865 test_assignmentToFinal_suffixMinusMinus() async {
811 Source source = addSource(r''' 866 Source source = addSource(r'''
812 f() { 867 f() {
813 final x = 0; 868 final x = 0;
814 x--; 869 x--;
815 }'''); 870 }''');
871 await computeAnalysisResult(source);
816 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 872 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
817 verify([source]); 873 verify([source]);
818 } 874 }
819 875
820 test_assignmentToFinal_suffixPlusPlus() async { 876 test_assignmentToFinal_suffixPlusPlus() async {
821 Source source = addSource(r''' 877 Source source = addSource(r'''
822 f() { 878 f() {
823 final x = 0; 879 final x = 0;
824 x++; 880 x++;
825 }'''); 881 }''');
882 await computeAnalysisResult(source);
826 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 883 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
827 verify([source]); 884 verify([source]);
828 } 885 }
829 886
830 test_assignmentToFinal_topLevelVariable() async { 887 test_assignmentToFinal_topLevelVariable() async {
831 Source source = addSource(r''' 888 Source source = addSource(r'''
832 final x = 0; 889 final x = 0;
833 f() { x = 1; }'''); 890 f() { x = 1; }''');
891 await computeAnalysisResult(source);
834 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); 892 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
835 verify([source]); 893 verify([source]);
836 } 894 }
837 895
838 test_assignmentToFinalNoSetter_prefixedIdentifier() async { 896 test_assignmentToFinalNoSetter_prefixedIdentifier() async {
839 Source source = addSource(r''' 897 Source source = addSource(r'''
840 class A { 898 class A {
841 int get x => 0; 899 int get x => 0;
842 } 900 }
843 main() { 901 main() {
844 A a = new A(); 902 A a = new A();
845 a.x = 0; 903 a.x = 0;
846 }'''); 904 }''');
905 await computeAnalysisResult(source);
847 await assertErrors( 906 await assertErrors(
848 source, [StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER]); 907 source, [StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER]);
849 verify([source]); 908 verify([source]);
850 } 909 }
851 910
852 test_assignmentToFinalNoSetter_propertyAccess() async { 911 test_assignmentToFinalNoSetter_propertyAccess() async {
853 Source source = addSource(r''' 912 Source source = addSource(r'''
854 class A { 913 class A {
855 int get x => 0; 914 int get x => 0;
856 } 915 }
857 class B { 916 class B {
858 static A a; 917 static A a;
859 } 918 }
860 main() { 919 main() {
861 B.a.x = 0; 920 B.a.x = 0;
862 }'''); 921 }''');
922 await computeAnalysisResult(source);
863 await assertErrors( 923 await assertErrors(
864 source, [StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER]); 924 source, [StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER]);
865 verify([source]); 925 verify([source]);
866 } 926 }
867 927
868 test_assignmentToFunction() async { 928 test_assignmentToFunction() async {
869 Source source = addSource(r''' 929 Source source = addSource(r'''
870 f() {} 930 f() {}
871 main() { 931 main() {
872 f = null; 932 f = null;
873 }'''); 933 }''');
934 await computeAnalysisResult(source);
874 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FUNCTION]); 935 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FUNCTION]);
875 verify([source]); 936 verify([source]);
876 } 937 }
877 938
878 test_assignmentToMethod() async { 939 test_assignmentToMethod() async {
879 Source source = addSource(r''' 940 Source source = addSource(r'''
880 class A { 941 class A {
881 m() {} 942 m() {}
882 } 943 }
883 f(A a) { 944 f(A a) {
884 a.m = () {}; 945 a.m = () {};
885 }'''); 946 }''');
947 await computeAnalysisResult(source);
886 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_METHOD]); 948 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_METHOD]);
887 verify([source]); 949 verify([source]);
888 } 950 }
889 951
890 test_assignmentToTypedef() async { 952 test_assignmentToTypedef() async {
891 Source source = addSource(''' 953 Source source = addSource('''
892 typedef void F(); 954 typedef void F();
893 main() { 955 main() {
894 F = null; 956 F = null;
895 } 957 }
896 '''); 958 ''');
959 await computeAnalysisResult(source);
897 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]); 960 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
898 } 961 }
899 962
900 test_assignmentToTypeParameter() async { 963 test_assignmentToTypeParameter() async {
901 Source source = addSource(''' 964 Source source = addSource('''
902 class C<T> { 965 class C<T> {
903 f() { 966 f() {
904 T = null; 967 T = null;
905 } 968 }
906 } 969 }
907 '''); 970 ''');
971 await computeAnalysisResult(source);
908 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]); 972 await assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
909 } 973 }
910 974
911 test_caseBlockNotTerminated() async { 975 test_caseBlockNotTerminated() async {
912 Source source = addSource(r''' 976 Source source = addSource(r'''
913 f(int p) { 977 f(int p) {
914 switch (p) { 978 switch (p) {
915 case 0: 979 case 0:
916 f(p); 980 f(p);
917 case 1: 981 case 1:
918 break; 982 break;
919 } 983 }
920 }'''); 984 }''');
985 await computeAnalysisResult(source);
921 await assertErrors(source, [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]); 986 await assertErrors(source, [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
922 verify([source]); 987 verify([source]);
923 } 988 }
924 989
925 test_castToNonType() async { 990 test_castToNonType() async {
926 Source source = addSource(r''' 991 Source source = addSource(r'''
927 var A = 0; 992 var A = 0;
928 f(String s) { var x = s as A; }'''); 993 f(String s) { var x = s as A; }''');
994 await computeAnalysisResult(source);
929 await assertErrors(source, [StaticWarningCode.CAST_TO_NON_TYPE]); 995 await assertErrors(source, [StaticWarningCode.CAST_TO_NON_TYPE]);
930 verify([source]); 996 verify([source]);
931 } 997 }
932 998
933 test_concreteClassWithAbstractMember() async { 999 test_concreteClassWithAbstractMember() async {
934 Source source = addSource(r''' 1000 Source source = addSource(r'''
935 class A { 1001 class A {
936 m(); 1002 m();
937 }'''); 1003 }''');
1004 await computeAnalysisResult(source);
938 await assertErrors( 1005 await assertErrors(
939 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]); 1006 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
940 verify([source]); 1007 verify([source]);
941 } 1008 }
942 1009
943 test_concreteClassWithAbstractMember_noSuchMethod_interface() async { 1010 test_concreteClassWithAbstractMember_noSuchMethod_interface() async {
944 Source source = addSource(r''' 1011 Source source = addSource(r'''
945 class I { 1012 class I {
946 noSuchMethod(v) => ''; 1013 noSuchMethod(v) => '';
947 } 1014 }
948 class A implements I { 1015 class A implements I {
949 m(); 1016 m();
950 }'''); 1017 }''');
1018 await computeAnalysisResult(source);
951 await assertErrors( 1019 await assertErrors(
952 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]); 1020 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
953 verify([source]); 1021 verify([source]);
954 } 1022 }
955 1023
956 test_conflictingDartImport() async { 1024 test_conflictingDartImport() async {
957 Source source = addSource(r''' 1025 Source source = addSource(r'''
958 import 'lib.dart'; 1026 import 'lib.dart';
959 import 'dart:async'; 1027 import 'dart:async';
960 Future f = null; 1028 Future f = null;
961 Stream s;'''); 1029 Stream s;''');
962 addNamedSource( 1030 addNamedSource(
963 "/lib.dart", 1031 "/lib.dart",
964 r''' 1032 r'''
965 library lib; 1033 library lib;
966 class Future {}'''); 1034 class Future {}''');
1035 await computeAnalysisResult(source);
967 await assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]); 1036 await assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]);
968 } 1037 }
969 1038
970 test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter() as ync { 1039 test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter() as ync {
971 Source source = addSource(r''' 1040 Source source = addSource(r'''
972 class A { 1041 class A {
973 static set v(x) {} 1042 static set v(x) {}
974 } 1043 }
975 class B extends A { 1044 class B extends A {
976 var v; 1045 var v;
977 }'''); 1046 }''');
1047 await computeAnalysisResult(source);
978 await assertErrors(source, 1048 await assertErrors(source,
979 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1049 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
980 verify([source]); 1050 verify([source]);
981 } 1051 }
982 1052
983 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_getter() a sync { 1053 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_getter() a sync {
984 Source source = addSource(r''' 1054 Source source = addSource(r'''
985 class A { 1055 class A {
986 static get v => 0; 1056 static get v => 0;
987 } 1057 }
988 class B extends A { 1058 class B extends A {
989 get v => 0; 1059 get v => 0;
990 }'''); 1060 }''');
1061 await computeAnalysisResult(source);
991 await assertErrors(source, 1062 await assertErrors(source,
992 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1063 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
993 verify([source]); 1064 verify([source]);
994 } 1065 }
995 1066
996 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_method() a sync { 1067 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_method() a sync {
997 Source source = addSource(r''' 1068 Source source = addSource(r'''
998 class A { 1069 class A {
999 static v() {} 1070 static v() {}
1000 } 1071 }
1001 class B extends A { 1072 class B extends A {
1002 get v => 0; 1073 get v => 0;
1003 }'''); 1074 }''');
1075 await computeAnalysisResult(source);
1004 await assertErrors(source, 1076 await assertErrors(source,
1005 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1077 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
1006 verify([source]); 1078 verify([source]);
1007 } 1079 }
1008 1080
1009 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_setter() a sync { 1081 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_setter() a sync {
1010 Source source = addSource(r''' 1082 Source source = addSource(r'''
1011 class A { 1083 class A {
1012 static set v(x) {} 1084 static set v(x) {}
1013 } 1085 }
1014 class B extends A { 1086 class B extends A {
1015 get v => 0; 1087 get v => 0;
1016 }'''); 1088 }''');
1089 await computeAnalysisResult(source);
1017 await assertErrors(source, 1090 await assertErrors(source,
1018 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1091 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
1019 verify([source]); 1092 verify([source]);
1020 } 1093 }
1021 1094
1022 test_conflictingInstanceGetterAndSuperclassMember_declGetter_indirect() async { 1095 test_conflictingInstanceGetterAndSuperclassMember_declGetter_indirect() async {
1023 Source source = addSource(r''' 1096 Source source = addSource(r'''
1024 class A { 1097 class A {
1025 static int v; 1098 static int v;
1026 } 1099 }
1027 class B extends A {} 1100 class B extends A {}
1028 class C extends B { 1101 class C extends B {
1029 get v => 0; 1102 get v => 0;
1030 }'''); 1103 }''');
1104 await computeAnalysisResult(source);
1031 await assertErrors(source, 1105 await assertErrors(source,
1032 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1106 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
1033 verify([source]); 1107 verify([source]);
1034 } 1108 }
1035 1109
1036 test_conflictingInstanceGetterAndSuperclassMember_declGetter_mixin() async { 1110 test_conflictingInstanceGetterAndSuperclassMember_declGetter_mixin() async {
1037 Source source = addSource(r''' 1111 Source source = addSource(r'''
1038 class M { 1112 class M {
1039 static int v; 1113 static int v;
1040 } 1114 }
1041 class B extends Object with M { 1115 class B extends Object with M {
1042 get v => 0; 1116 get v => 0;
1043 }'''); 1117 }''');
1118 await computeAnalysisResult(source);
1044 await assertErrors(source, 1119 await assertErrors(source,
1045 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1120 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
1046 verify([source]); 1121 verify([source]);
1047 } 1122 }
1048 1123
1049 test_conflictingInstanceGetterAndSuperclassMember_direct_field() async { 1124 test_conflictingInstanceGetterAndSuperclassMember_direct_field() async {
1050 Source source = addSource(r''' 1125 Source source = addSource(r'''
1051 class A { 1126 class A {
1052 static int v; 1127 static int v;
1053 } 1128 }
1054 class B extends A { 1129 class B extends A {
1055 get v => 0; 1130 get v => 0;
1056 }'''); 1131 }''');
1132 await computeAnalysisResult(source);
1057 await assertErrors(source, 1133 await assertErrors(source,
1058 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1134 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
1059 verify([source]); 1135 verify([source]);
1060 } 1136 }
1061 1137
1062 test_conflictingInstanceMethodSetter2() async { 1138 test_conflictingInstanceMethodSetter2() async {
1063 Source source = addSource(r''' 1139 Source source = addSource(r'''
1064 class A { 1140 class A {
1065 foo() {} 1141 foo() {}
1066 set foo(a) {} 1142 set foo(a) {}
1067 }'''); 1143 }''');
1144 await computeAnalysisResult(source);
1068 await assertErrors( 1145 await assertErrors(
1069 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER2]); 1146 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER2]);
1070 verify([source]); 1147 verify([source]);
1071 } 1148 }
1072 1149
1073 test_conflictingInstanceMethodSetter_sameClass() async { 1150 test_conflictingInstanceMethodSetter_sameClass() async {
1074 Source source = addSource(r''' 1151 Source source = addSource(r'''
1075 class A { 1152 class A {
1076 set foo(a) {} 1153 set foo(a) {}
1077 foo() {} 1154 foo() {}
1078 }'''); 1155 }''');
1156 await computeAnalysisResult(source);
1079 await assertErrors( 1157 await assertErrors(
1080 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]); 1158 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]);
1081 verify([source]); 1159 verify([source]);
1082 } 1160 }
1083 1161
1084 test_conflictingInstanceMethodSetter_setterInInterface() async { 1162 test_conflictingInstanceMethodSetter_setterInInterface() async {
1085 Source source = addSource(r''' 1163 Source source = addSource(r'''
1086 abstract class A { 1164 abstract class A {
1087 set foo(a); 1165 set foo(a);
1088 } 1166 }
1089 abstract class B implements A { 1167 abstract class B implements A {
1090 foo() {} 1168 foo() {}
1091 }'''); 1169 }''');
1170 await computeAnalysisResult(source);
1092 await assertErrors( 1171 await assertErrors(
1093 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]); 1172 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]);
1094 verify([source]); 1173 verify([source]);
1095 } 1174 }
1096 1175
1097 test_conflictingInstanceMethodSetter_setterInSuper() async { 1176 test_conflictingInstanceMethodSetter_setterInSuper() async {
1098 Source source = addSource(r''' 1177 Source source = addSource(r'''
1099 class A { 1178 class A {
1100 set foo(a) {} 1179 set foo(a) {}
1101 } 1180 }
1102 class B extends A { 1181 class B extends A {
1103 foo() {} 1182 foo() {}
1104 }'''); 1183 }''');
1184 await computeAnalysisResult(source);
1105 await assertErrors( 1185 await assertErrors(
1106 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]); 1186 source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]);
1107 verify([source]); 1187 verify([source]);
1108 } 1188 }
1109 1189
1110 test_conflictingInstanceSetterAndSuperclassMember() async { 1190 test_conflictingInstanceSetterAndSuperclassMember() async {
1111 Source source = addSource(r''' 1191 Source source = addSource(r'''
1112 class A { 1192 class A {
1113 static int v; 1193 static int v;
1114 } 1194 }
1115 class B extends A { 1195 class B extends A {
1116 set v(x) {} 1196 set v(x) {}
1117 }'''); 1197 }''');
1198 await computeAnalysisResult(source);
1118 await assertErrors(source, 1199 await assertErrors(source,
1119 [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER]); 1200 [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER]);
1120 verify([source]); 1201 verify([source]);
1121 } 1202 }
1122 1203
1123 test_conflictingStaticGetterAndInstanceSetter_mixin() async { 1204 test_conflictingStaticGetterAndInstanceSetter_mixin() async {
1124 Source source = addSource(r''' 1205 Source source = addSource(r'''
1125 class A { 1206 class A {
1126 set x(int p) {} 1207 set x(int p) {}
1127 } 1208 }
1128 class B extends Object with A { 1209 class B extends Object with A {
1129 static get x => 0; 1210 static get x => 0;
1130 }'''); 1211 }''');
1212 await computeAnalysisResult(source);
1131 await assertErrors(source, 1213 await assertErrors(source,
1132 [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]); 1214 [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]);
1133 verify([source]); 1215 verify([source]);
1134 } 1216 }
1135 1217
1136 test_conflictingStaticGetterAndInstanceSetter_superClass() async { 1218 test_conflictingStaticGetterAndInstanceSetter_superClass() async {
1137 Source source = addSource(r''' 1219 Source source = addSource(r'''
1138 class A { 1220 class A {
1139 set x(int p) {} 1221 set x(int p) {}
1140 } 1222 }
1141 class B extends A { 1223 class B extends A {
1142 static get x => 0; 1224 static get x => 0;
1143 }'''); 1225 }''');
1226 await computeAnalysisResult(source);
1144 await assertErrors(source, 1227 await assertErrors(source,
1145 [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]); 1228 [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]);
1146 verify([source]); 1229 verify([source]);
1147 } 1230 }
1148 1231
1149 test_conflictingStaticGetterAndInstanceSetter_thisClass() async { 1232 test_conflictingStaticGetterAndInstanceSetter_thisClass() async {
1150 Source source = addSource(r''' 1233 Source source = addSource(r'''
1151 class A { 1234 class A {
1152 static get x => 0; 1235 static get x => 0;
1153 set x(int p) {} 1236 set x(int p) {}
1154 }'''); 1237 }''');
1238 await computeAnalysisResult(source);
1155 await assertErrors(source, 1239 await assertErrors(source,
1156 [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]); 1240 [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]);
1157 verify([source]); 1241 verify([source]);
1158 } 1242 }
1159 1243
1160 test_conflictingStaticSetterAndInstanceMember_thisClass_getter() async { 1244 test_conflictingStaticSetterAndInstanceMember_thisClass_getter() async {
1161 Source source = addSource(r''' 1245 Source source = addSource(r'''
1162 class A { 1246 class A {
1163 get x => 0; 1247 get x => 0;
1164 static set x(int p) {} 1248 static set x(int p) {}
1165 }'''); 1249 }''');
1250 await computeAnalysisResult(source);
1166 await assertErrors(source, 1251 await assertErrors(source,
1167 [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER]); 1252 [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER]);
1168 verify([source]); 1253 verify([source]);
1169 } 1254 }
1170 1255
1171 test_conflictingStaticSetterAndInstanceMember_thisClass_method() async { 1256 test_conflictingStaticSetterAndInstanceMember_thisClass_method() async {
1172 Source source = addSource(r''' 1257 Source source = addSource(r'''
1173 class A { 1258 class A {
1174 x() {} 1259 x() {}
1175 static set x(int p) {} 1260 static set x(int p) {}
1176 }'''); 1261 }''');
1262 await computeAnalysisResult(source);
1177 await assertErrors(source, 1263 await assertErrors(source,
1178 [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER]); 1264 [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER]);
1179 verify([source]); 1265 verify([source]);
1180 } 1266 }
1181 1267
1182 test_constWithAbstractClass() async { 1268 test_constWithAbstractClass() async {
1183 Source source = addSource(r''' 1269 Source source = addSource(r'''
1184 abstract class A { 1270 abstract class A {
1185 const A(); 1271 const A();
1186 } 1272 }
1187 void f() { 1273 void f() {
1188 A a = const A(); 1274 A a = const A();
1189 }'''); 1275 }''');
1276 await computeAnalysisResult(source);
1190 await assertErrors(source, [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]); 1277 await assertErrors(source, [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]);
1191 verify([source]); 1278 verify([source]);
1192 } 1279 }
1193 1280
1194 test_equalKeysInMap() async { 1281 test_equalKeysInMap() async {
1195 Source source = addSource("var m = {'a' : 0, 'b' : 1, 'a' : 2};"); 1282 Source source = addSource("var m = {'a' : 0, 'b' : 1, 'a' : 2};");
1283 await computeAnalysisResult(source);
1196 await assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]); 1284 await assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]);
1197 verify([source]); 1285 verify([source]);
1198 } 1286 }
1199 1287
1200 test_equalKeysInMap_withEqualTypeParams() async { 1288 test_equalKeysInMap_withEqualTypeParams() async {
1201 Source source = addSource(r''' 1289 Source source = addSource(r'''
1202 class A<T> { 1290 class A<T> {
1203 const A(); 1291 const A();
1204 } 1292 }
1205 var m = {const A<int>(): 0, const A<int>(): 1};'''); 1293 var m = {const A<int>(): 0, const A<int>(): 1};''');
1294 await computeAnalysisResult(source);
1206 await assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]); 1295 await assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]);
1207 verify([source]); 1296 verify([source]);
1208 } 1297 }
1209 1298
1210 test_equalKeysInMap_withUnequalTypeParams() async { 1299 test_equalKeysInMap_withUnequalTypeParams() async {
1211 // No error should be produced because A<int> and A<num> are different 1300 // No error should be produced because A<int> and A<num> are different
1212 // types. 1301 // types.
1213 Source source = addSource(r''' 1302 Source source = addSource(r'''
1214 class A<T> { 1303 class A<T> {
1215 const A(); 1304 const A();
1216 } 1305 }
1217 var m = {const A<int>(): 0, const A<num>(): 1};'''); 1306 var m = {const A<int>(): 0, const A<num>(): 1};''');
1307 await computeAnalysisResult(source);
1218 await assertNoErrors(source); 1308 await assertNoErrors(source);
1219 verify([source]); 1309 verify([source]);
1220 } 1310 }
1221 1311
1222 test_exportDuplicatedLibraryNamed() async { 1312 test_exportDuplicatedLibraryNamed() async {
1223 Source source = addSource(r''' 1313 Source source = addSource(r'''
1224 library test; 1314 library test;
1225 export 'lib1.dart'; 1315 export 'lib1.dart';
1226 export 'lib2.dart';'''); 1316 export 'lib2.dart';''');
1227 addNamedSource("/lib1.dart", "library lib;"); 1317 addNamedSource("/lib1.dart", "library lib;");
1228 addNamedSource("/lib2.dart", "library lib;"); 1318 addNamedSource("/lib2.dart", "library lib;");
1319 await computeAnalysisResult(source);
1229 await assertErrors( 1320 await assertErrors(
1230 source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED]); 1321 source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED]);
1231 verify([source]); 1322 verify([source]);
1232 } 1323 }
1233 1324
1234 test_extraPositionalArguments() async { 1325 test_extraPositionalArguments() async {
1235 Source source = addSource(r''' 1326 Source source = addSource(r'''
1236 f() {} 1327 f() {}
1237 main() { 1328 main() {
1238 f(0, 1, '2'); 1329 f(0, 1, '2');
1239 }'''); 1330 }''');
1331 await computeAnalysisResult(source);
1240 await assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); 1332 await assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]);
1241 verify([source]); 1333 verify([source]);
1242 } 1334 }
1243 1335
1244 test_extraPositionalArguments_functionExpression() async { 1336 test_extraPositionalArguments_functionExpression() async {
1245 Source source = addSource(r''' 1337 Source source = addSource(r'''
1246 main() { 1338 main() {
1247 (int x) {} (0, 1); 1339 (int x) {} (0, 1);
1248 }'''); 1340 }''');
1341 await computeAnalysisResult(source);
1249 await assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); 1342 await assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]);
1250 verify([source]); 1343 verify([source]);
1251 } 1344 }
1252 1345
1253 test_fieldInitializedInInitializerAndDeclaration_final() async { 1346 test_fieldInitializedInInitializerAndDeclaration_final() async {
1254 Source source = addSource(r''' 1347 Source source = addSource(r'''
1255 class A { 1348 class A {
1256 final int x = 0; 1349 final int x = 0;
1257 A() : x = 1 {} 1350 A() : x = 1 {}
1258 }'''); 1351 }''');
1352 await computeAnalysisResult(source);
1259 await assertErrors(source, 1353 await assertErrors(source,
1260 [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]); 1354 [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
1261 verify([source]); 1355 verify([source]);
1262 } 1356 }
1263 1357
1264 test_fieldInitializerNotAssignable() async { 1358 test_fieldInitializerNotAssignable() async {
1265 Source source = addSource(r''' 1359 Source source = addSource(r'''
1266 class A { 1360 class A {
1267 int x; 1361 int x;
1268 A() : x = ''; 1362 A() : x = '';
1269 }'''); 1363 }''');
1364 await computeAnalysisResult(source);
1270 await assertErrors( 1365 await assertErrors(
1271 source, [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]); 1366 source, [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]);
1272 verify([source]); 1367 verify([source]);
1273 } 1368 }
1274 1369
1275 test_fieldInitializingFormalNotAssignable() async { 1370 test_fieldInitializingFormalNotAssignable() async {
1276 Source source = addSource(r''' 1371 Source source = addSource(r'''
1277 class A { 1372 class A {
1278 int x; 1373 int x;
1279 A(String this.x) {} 1374 A(String this.x) {}
1280 }'''); 1375 }''');
1376 await computeAnalysisResult(source);
1281 await assertErrors( 1377 await assertErrors(
1282 source, [StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE]); 1378 source, [StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE]);
1283 verify([source]); 1379 verify([source]);
1284 } 1380 }
1285 1381
1286 /** 1382 /**
1287 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the 1383 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the
1288 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid ed here to show 1384 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid ed here to show
1289 * coverage over all of the permutations of initializers in constructor declar ations. 1385 * coverage over all of the permutations of initializers in constructor declar ations.
1290 * 1386 *
1291 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of 1387 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of
1292 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w e use it instead of 1388 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w e use it instead of
1293 * the broader code 1389 * the broader code
1294 */ 1390 */
1295 test_finalInitializedInDeclarationAndConstructor_initializers() async { 1391 test_finalInitializedInDeclarationAndConstructor_initializers() async {
1296 Source source = addSource(r''' 1392 Source source = addSource(r'''
1297 class A { 1393 class A {
1298 final x = 0; 1394 final x = 0;
1299 A() : x = 0 {} 1395 A() : x = 0 {}
1300 }'''); 1396 }''');
1397 await computeAnalysisResult(source);
1301 await assertErrors(source, 1398 await assertErrors(source,
1302 [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]); 1399 [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
1303 verify([source]); 1400 verify([source]);
1304 } 1401 }
1305 1402
1306 test_finalInitializedInDeclarationAndConstructor_initializingFormal() async { 1403 test_finalInitializedInDeclarationAndConstructor_initializingFormal() async {
1307 Source source = addSource(r''' 1404 Source source = addSource(r'''
1308 class A { 1405 class A {
1309 final x = 0; 1406 final x = 0;
1310 A(this.x) {} 1407 A(this.x) {}
1311 }'''); 1408 }''');
1409 await computeAnalysisResult(source);
1312 await assertErrors(source, 1410 await assertErrors(source,
1313 [StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR]); 1411 [StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR]);
1314 verify([source]); 1412 verify([source]);
1315 } 1413 }
1316 1414
1317 test_finalNotInitialized_inConstructor_1() async { 1415 test_finalNotInitialized_inConstructor_1() async {
1318 Source source = addSource(r''' 1416 Source source = addSource(r'''
1319 class A { 1417 class A {
1320 final int x; 1418 final int x;
1321 A() {} 1419 A() {}
1322 }'''); 1420 }''');
1421 await computeAnalysisResult(source);
1323 await assertErrors( 1422 await assertErrors(
1324 source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1]); 1423 source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1]);
1325 verify([source]); 1424 verify([source]);
1326 } 1425 }
1327 1426
1328 test_finalNotInitialized_inConstructor_2() async { 1427 test_finalNotInitialized_inConstructor_2() async {
1329 Source source = addSource(r''' 1428 Source source = addSource(r'''
1330 class A { 1429 class A {
1331 final int a; 1430 final int a;
1332 final int b; 1431 final int b;
1333 A() {} 1432 A() {}
1334 }'''); 1433 }''');
1434 await computeAnalysisResult(source);
1335 await assertErrors( 1435 await assertErrors(
1336 source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2]); 1436 source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2]);
1337 verify([source]); 1437 verify([source]);
1338 } 1438 }
1339 1439
1340 test_finalNotInitialized_inConstructor_3() async { 1440 test_finalNotInitialized_inConstructor_3() async {
1341 Source source = addSource(r''' 1441 Source source = addSource(r'''
1342 class A { 1442 class A {
1343 final int a; 1443 final int a;
1344 final int b; 1444 final int b;
1345 final int c; 1445 final int c;
1346 A() {} 1446 A() {}
1347 }'''); 1447 }''');
1448 await computeAnalysisResult(source);
1348 await assertErrors( 1449 await assertErrors(
1349 source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS]); 1450 source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS]);
1350 verify([source]); 1451 verify([source]);
1351 } 1452 }
1352 1453
1353 test_finalNotInitialized_instanceField_final() async { 1454 test_finalNotInitialized_instanceField_final() async {
1354 Source source = addSource(r''' 1455 Source source = addSource(r'''
1355 class A { 1456 class A {
1356 final F; 1457 final F;
1357 }'''); 1458 }''');
1459 await computeAnalysisResult(source);
1358 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); 1460 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
1359 verify([source]); 1461 verify([source]);
1360 } 1462 }
1361 1463
1362 test_finalNotInitialized_instanceField_final_static() async { 1464 test_finalNotInitialized_instanceField_final_static() async {
1363 Source source = addSource(r''' 1465 Source source = addSource(r'''
1364 class A { 1466 class A {
1365 static final F; 1467 static final F;
1366 }'''); 1468 }''');
1469 await computeAnalysisResult(source);
1367 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); 1470 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
1368 verify([source]); 1471 verify([source]);
1369 } 1472 }
1370 1473
1371 test_finalNotInitialized_library_final() async { 1474 test_finalNotInitialized_library_final() async {
1372 Source source = addSource("final F;"); 1475 Source source = addSource("final F;");
1476 await computeAnalysisResult(source);
1373 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); 1477 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
1374 verify([source]); 1478 verify([source]);
1375 } 1479 }
1376 1480
1377 test_finalNotInitialized_local_final() async { 1481 test_finalNotInitialized_local_final() async {
1378 Source source = addSource(r''' 1482 Source source = addSource(r'''
1379 f() { 1483 f() {
1380 final int x; 1484 final int x;
1381 }'''); 1485 }''');
1486 await computeAnalysisResult(source);
1382 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); 1487 await assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
1383 verify([source]); 1488 verify([source]);
1384 } 1489 }
1385 1490
1386 test_functionWithoutCall_direct() async { 1491 test_functionWithoutCall_direct() async {
1387 Source source = addSource(r''' 1492 Source source = addSource(r'''
1388 class A implements Function { 1493 class A implements Function {
1389 }'''); 1494 }''');
1495 await computeAnalysisResult(source);
1390 await assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); 1496 await assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
1391 verify([source]); 1497 verify([source]);
1392 } 1498 }
1393 1499
1394 test_functionWithoutCall_indirect_extends() async { 1500 test_functionWithoutCall_indirect_extends() async {
1395 Source source = addSource(r''' 1501 Source source = addSource(r'''
1396 abstract class A implements Function { 1502 abstract class A implements Function {
1397 } 1503 }
1398 class B extends A { 1504 class B extends A {
1399 }'''); 1505 }''');
1506 await computeAnalysisResult(source);
1400 await assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); 1507 await assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
1401 verify([source]); 1508 verify([source]);
1402 } 1509 }
1403 1510
1404 test_functionWithoutCall_indirect_implements() async { 1511 test_functionWithoutCall_indirect_implements() async {
1405 Source source = addSource(r''' 1512 Source source = addSource(r'''
1406 abstract class A implements Function { 1513 abstract class A implements Function {
1407 } 1514 }
1408 class B implements A { 1515 class B implements A {
1409 }'''); 1516 }''');
1517 await computeAnalysisResult(source);
1410 await assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); 1518 await assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
1411 verify([source]); 1519 verify([source]);
1412 } 1520 }
1413 1521
1414 test_importDuplicatedLibraryNamed() async { 1522 test_importDuplicatedLibraryNamed() async {
1415 Source source = addSource(r''' 1523 Source source = addSource(r'''
1416 library test; 1524 library test;
1417 import 'lib1.dart'; 1525 import 'lib1.dart';
1418 import 'lib2.dart';'''); 1526 import 'lib2.dart';''');
1419 addNamedSource("/lib1.dart", "library lib;"); 1527 addNamedSource("/lib1.dart", "library lib;");
1420 addNamedSource("/lib2.dart", "library lib;"); 1528 addNamedSource("/lib2.dart", "library lib;");
1529 await computeAnalysisResult(source);
1421 await assertErrors(source, [ 1530 await assertErrors(source, [
1422 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED, 1531 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED,
1423 HintCode.UNUSED_IMPORT, 1532 HintCode.UNUSED_IMPORT,
1424 HintCode.UNUSED_IMPORT 1533 HintCode.UNUSED_IMPORT
1425 ]); 1534 ]);
1426 verify([source]); 1535 verify([source]);
1427 } 1536 }
1428 1537
1429 test_importOfNonLibrary() async { 1538 test_importOfNonLibrary() async {
1430 await resolveWithErrors(<String>[ 1539 await resolveWithErrors(<String>[
(...skipping 12 matching lines...) Expand all
1443 test_inconsistentMethodInheritanceGetterAndMethod() async { 1552 test_inconsistentMethodInheritanceGetterAndMethod() async {
1444 Source source = addSource(r''' 1553 Source source = addSource(r'''
1445 abstract class A { 1554 abstract class A {
1446 int x(); 1555 int x();
1447 } 1556 }
1448 abstract class B { 1557 abstract class B {
1449 int get x; 1558 int get x;
1450 } 1559 }
1451 class C implements A, B { 1560 class C implements A, B {
1452 }'''); 1561 }''');
1562 await computeAnalysisResult(source);
1453 await assertErrors(source, 1563 await assertErrors(source,
1454 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); 1564 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]);
1455 verify([source]); 1565 verify([source]);
1456 } 1566 }
1457 1567
1458 test_instanceMethodNameCollidesWithSuperclassStatic_field() async { 1568 test_instanceMethodNameCollidesWithSuperclassStatic_field() async {
1459 Source source = addSource(r''' 1569 Source source = addSource(r'''
1460 class A { 1570 class A {
1461 static var n; 1571 static var n;
1462 } 1572 }
1463 class B extends A { 1573 class B extends A {
1464 void n() {} 1574 void n() {}
1465 }'''); 1575 }''');
1576 await computeAnalysisResult(source);
1466 await assertErrors(source, [ 1577 await assertErrors(source, [
1467 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1578 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1468 ]); 1579 ]);
1469 verify([source]); 1580 verify([source]);
1470 } 1581 }
1471 1582
1472 test_instanceMethodNameCollidesWithSuperclassStatic_field2() async { 1583 test_instanceMethodNameCollidesWithSuperclassStatic_field2() async {
1473 Source source = addSource(r''' 1584 Source source = addSource(r'''
1474 class A { 1585 class A {
1475 static var n; 1586 static var n;
1476 } 1587 }
1477 class B extends A { 1588 class B extends A {
1478 } 1589 }
1479 class C extends B { 1590 class C extends B {
1480 void n() {} 1591 void n() {}
1481 }'''); 1592 }''');
1593 await computeAnalysisResult(source);
1482 await assertErrors(source, [ 1594 await assertErrors(source, [
1483 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1595 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1484 ]); 1596 ]);
1485 verify([source]); 1597 verify([source]);
1486 } 1598 }
1487 1599
1488 test_instanceMethodNameCollidesWithSuperclassStatic_getter() async { 1600 test_instanceMethodNameCollidesWithSuperclassStatic_getter() async {
1489 Source source = addSource(r''' 1601 Source source = addSource(r'''
1490 class A { 1602 class A {
1491 static get n {return 0;} 1603 static get n {return 0;}
1492 } 1604 }
1493 class B extends A { 1605 class B extends A {
1494 void n() {} 1606 void n() {}
1495 }'''); 1607 }''');
1608 await computeAnalysisResult(source);
1496 await assertErrors(source, [ 1609 await assertErrors(source, [
1497 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1610 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1498 ]); 1611 ]);
1499 verify([source]); 1612 verify([source]);
1500 } 1613 }
1501 1614
1502 test_instanceMethodNameCollidesWithSuperclassStatic_getter2() async { 1615 test_instanceMethodNameCollidesWithSuperclassStatic_getter2() async {
1503 Source source = addSource(r''' 1616 Source source = addSource(r'''
1504 class A { 1617 class A {
1505 static get n {return 0;} 1618 static get n {return 0;}
1506 } 1619 }
1507 class B extends A { 1620 class B extends A {
1508 } 1621 }
1509 class C extends B { 1622 class C extends B {
1510 void n() {} 1623 void n() {}
1511 }'''); 1624 }''');
1625 await computeAnalysisResult(source);
1512 await assertErrors(source, [ 1626 await assertErrors(source, [
1513 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1627 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1514 ]); 1628 ]);
1515 verify([source]); 1629 verify([source]);
1516 } 1630 }
1517 1631
1518 test_instanceMethodNameCollidesWithSuperclassStatic_interface() async { 1632 test_instanceMethodNameCollidesWithSuperclassStatic_interface() async {
1519 Source source = addSource(r''' 1633 Source source = addSource(r'''
1520 class Base { 1634 class Base {
1521 static foo() {} 1635 static foo() {}
1522 } 1636 }
1523 abstract class Ifc { 1637 abstract class Ifc {
1524 foo(); 1638 foo();
1525 } 1639 }
1526 class C extends Base implements Ifc { 1640 class C extends Base implements Ifc {
1527 foo() {} 1641 foo() {}
1528 } 1642 }
1529 '''); 1643 ''');
1644 await computeAnalysisResult(source);
1530 await assertErrors(source, [ 1645 await assertErrors(source, [
1531 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1646 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1532 ]); 1647 ]);
1533 verify([source]); 1648 verify([source]);
1534 } 1649 }
1535 1650
1536 test_instanceMethodNameCollidesWithSuperclassStatic_method() async { 1651 test_instanceMethodNameCollidesWithSuperclassStatic_method() async {
1537 Source source = addSource(r''' 1652 Source source = addSource(r'''
1538 class A { 1653 class A {
1539 static n () {} 1654 static n () {}
1540 } 1655 }
1541 class B extends A { 1656 class B extends A {
1542 void n() {} 1657 void n() {}
1543 }'''); 1658 }''');
1659 await computeAnalysisResult(source);
1544 await assertErrors(source, [ 1660 await assertErrors(source, [
1545 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1661 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1546 ]); 1662 ]);
1547 verify([source]); 1663 verify([source]);
1548 } 1664 }
1549 1665
1550 test_instanceMethodNameCollidesWithSuperclassStatic_method2() async { 1666 test_instanceMethodNameCollidesWithSuperclassStatic_method2() async {
1551 Source source = addSource(r''' 1667 Source source = addSource(r'''
1552 class A { 1668 class A {
1553 static n () {} 1669 static n () {}
1554 } 1670 }
1555 class B extends A { 1671 class B extends A {
1556 } 1672 }
1557 class C extends B { 1673 class C extends B {
1558 void n() {} 1674 void n() {}
1559 }'''); 1675 }''');
1676 await computeAnalysisResult(source);
1560 await assertErrors(source, [ 1677 await assertErrors(source, [
1561 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1678 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1562 ]); 1679 ]);
1563 verify([source]); 1680 verify([source]);
1564 } 1681 }
1565 1682
1566 test_instanceMethodNameCollidesWithSuperclassStatic_setter() async { 1683 test_instanceMethodNameCollidesWithSuperclassStatic_setter() async {
1567 Source source = addSource(r''' 1684 Source source = addSource(r'''
1568 class A { 1685 class A {
1569 static set n(int x) {} 1686 static set n(int x) {}
1570 } 1687 }
1571 class B extends A { 1688 class B extends A {
1572 void n() {} 1689 void n() {}
1573 }'''); 1690 }''');
1691 await computeAnalysisResult(source);
1574 await assertErrors(source, [ 1692 await assertErrors(source, [
1575 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1693 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1576 ]); 1694 ]);
1577 verify([source]); 1695 verify([source]);
1578 } 1696 }
1579 1697
1580 test_instanceMethodNameCollidesWithSuperclassStatic_setter2() async { 1698 test_instanceMethodNameCollidesWithSuperclassStatic_setter2() async {
1581 Source source = addSource(r''' 1699 Source source = addSource(r'''
1582 class A { 1700 class A {
1583 static set n(int x) {} 1701 static set n(int x) {}
1584 } 1702 }
1585 class B extends A { 1703 class B extends A {
1586 } 1704 }
1587 class C extends B { 1705 class C extends B {
1588 void n() {} 1706 void n() {}
1589 }'''); 1707 }''');
1708 await computeAnalysisResult(source);
1590 await assertErrors(source, [ 1709 await assertErrors(source, [
1591 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC 1710 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
1592 ]); 1711 ]);
1593 verify([source]); 1712 verify([source]);
1594 } 1713 }
1595 1714
1596 test_invalidGetterOverrideReturnType() async { 1715 test_invalidGetterOverrideReturnType() async {
1597 Source source = addSource(r''' 1716 Source source = addSource(r'''
1598 class A { 1717 class A {
1599 int get g { return 0; } 1718 int get g { return 0; }
1600 } 1719 }
1601 class B extends A { 1720 class B extends A {
1602 String get g { return 'a'; } 1721 String get g { return 'a'; }
1603 }'''); 1722 }''');
1723 await computeAnalysisResult(source);
1604 await assertErrors( 1724 await assertErrors(
1605 source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]); 1725 source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
1606 verify([source]); 1726 verify([source]);
1607 } 1727 }
1608 1728
1609 test_invalidGetterOverrideReturnType_implicit() async { 1729 test_invalidGetterOverrideReturnType_implicit() async {
1610 Source source = addSource(r''' 1730 Source source = addSource(r'''
1611 class A { 1731 class A {
1612 String f; 1732 String f;
1613 } 1733 }
1614 class B extends A { 1734 class B extends A {
1615 int f; 1735 int f;
1616 }'''); 1736 }''');
1737 await computeAnalysisResult(source);
1617 await assertErrors(source, [ 1738 await assertErrors(source, [
1618 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE, 1739 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE,
1619 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE 1740 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE
1620 ]); 1741 ]);
1621 verify([source]); 1742 verify([source]);
1622 } 1743 }
1623 1744
1624 test_invalidGetterOverrideReturnType_twoInterfaces() async { 1745 test_invalidGetterOverrideReturnType_twoInterfaces() async {
1625 // test from language/override_inheritance_field_test_11.dart 1746 // test from language/override_inheritance_field_test_11.dart
1626 Source source = addSource(r''' 1747 Source source = addSource(r'''
1627 abstract class I { 1748 abstract class I {
1628 int get getter => null; 1749 int get getter => null;
1629 } 1750 }
1630 abstract class J { 1751 abstract class J {
1631 num get getter => null; 1752 num get getter => null;
1632 } 1753 }
1633 abstract class A implements I, J {} 1754 abstract class A implements I, J {}
1634 class B extends A { 1755 class B extends A {
1635 String get getter => null; 1756 String get getter => null;
1636 }'''); 1757 }''');
1758 await computeAnalysisResult(source);
1637 await assertErrors( 1759 await assertErrors(
1638 source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]); 1760 source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
1639 verify([source]); 1761 verify([source]);
1640 } 1762 }
1641 1763
1642 test_invalidGetterOverrideReturnType_twoInterfaces_conflicting() async { 1764 test_invalidGetterOverrideReturnType_twoInterfaces_conflicting() async {
1643 Source source = addSource(r''' 1765 Source source = addSource(r'''
1644 abstract class I<U> { 1766 abstract class I<U> {
1645 U get g => null; 1767 U get g => null;
1646 } 1768 }
1647 abstract class J<V> { 1769 abstract class J<V> {
1648 V get g => null; 1770 V get g => null;
1649 } 1771 }
1650 class B implements I<int>, J<String> { 1772 class B implements I<int>, J<String> {
1651 double get g => null; 1773 double get g => null;
1652 }'''); 1774 }''');
1775 await computeAnalysisResult(source);
1653 await assertErrors( 1776 await assertErrors(
1654 source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]); 1777 source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
1655 verify([source]); 1778 verify([source]);
1656 } 1779 }
1657 1780
1658 test_invalidMethodOverrideNamedParamType() async { 1781 test_invalidMethodOverrideNamedParamType() async {
1659 Source source = addSource(r''' 1782 Source source = addSource(r'''
1660 class A { 1783 class A {
1661 m({int a}) {} 1784 m({int a}) {}
1662 } 1785 }
1663 class B implements A { 1786 class B implements A {
1664 m({String a}) {} 1787 m({String a}) {}
1665 }'''); 1788 }''');
1789 await computeAnalysisResult(source);
1666 await assertErrors( 1790 await assertErrors(
1667 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE]); 1791 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE]);
1668 verify([source]); 1792 verify([source]);
1669 } 1793 }
1670 1794
1671 test_invalidMethodOverrideNormalParamType_interface() async { 1795 test_invalidMethodOverrideNormalParamType_interface() async {
1672 Source source = addSource(r''' 1796 Source source = addSource(r'''
1673 class A { 1797 class A {
1674 m(int a) {} 1798 m(int a) {}
1675 } 1799 }
1676 class B implements A { 1800 class B implements A {
1677 m(String a) {} 1801 m(String a) {}
1678 }'''); 1802 }''');
1803 await computeAnalysisResult(source);
1679 await assertErrors( 1804 await assertErrors(
1680 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]); 1805 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
1681 verify([source]); 1806 verify([source]);
1682 } 1807 }
1683 1808
1684 test_invalidMethodOverrideNormalParamType_superclass() async { 1809 test_invalidMethodOverrideNormalParamType_superclass() async {
1685 Source source = addSource(r''' 1810 Source source = addSource(r'''
1686 class A { 1811 class A {
1687 m(int a) {} 1812 m(int a) {}
1688 } 1813 }
1689 class B extends A { 1814 class B extends A {
1690 m(String a) {} 1815 m(String a) {}
1691 }'''); 1816 }''');
1817 await computeAnalysisResult(source);
1692 await assertErrors( 1818 await assertErrors(
1693 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]); 1819 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
1694 verify([source]); 1820 verify([source]);
1695 } 1821 }
1696 1822
1697 test_invalidMethodOverrideNormalParamType_superclass_interface() async { 1823 test_invalidMethodOverrideNormalParamType_superclass_interface() async {
1698 Source source = addSource(r''' 1824 Source source = addSource(r'''
1699 abstract class I<U> { 1825 abstract class I<U> {
1700 m(U u) => null; 1826 m(U u) => null;
1701 } 1827 }
1702 abstract class J<V> { 1828 abstract class J<V> {
1703 m(V v) => null; 1829 m(V v) => null;
1704 } 1830 }
1705 class B extends I<int> implements J<String> { 1831 class B extends I<int> implements J<String> {
1706 m(double d) {} 1832 m(double d) {}
1707 }'''); 1833 }''');
1834 await computeAnalysisResult(source);
1708 await assertErrors( 1835 await assertErrors(
1709 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]); 1836 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
1710 verify([source]); 1837 verify([source]);
1711 } 1838 }
1712 1839
1713 test_invalidMethodOverrideNormalParamType_twoInterfaces() async { 1840 test_invalidMethodOverrideNormalParamType_twoInterfaces() async {
1714 Source source = addSource(r''' 1841 Source source = addSource(r'''
1715 abstract class I { 1842 abstract class I {
1716 m(int n); 1843 m(int n);
1717 } 1844 }
1718 abstract class J { 1845 abstract class J {
1719 m(num n); 1846 m(num n);
1720 } 1847 }
1721 abstract class A implements I, J {} 1848 abstract class A implements I, J {}
1722 class B extends A { 1849 class B extends A {
1723 m(String n) {} 1850 m(String n) {}
1724 }'''); 1851 }''');
1852 await computeAnalysisResult(source);
1725 await assertErrors( 1853 await assertErrors(
1726 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]); 1854 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
1727 verify([source]); 1855 verify([source]);
1728 } 1856 }
1729 1857
1730 test_invalidMethodOverrideNormalParamType_twoInterfaces_conflicting() async { 1858 test_invalidMethodOverrideNormalParamType_twoInterfaces_conflicting() async {
1731 // language/override_inheritance_generic_test/08 1859 // language/override_inheritance_generic_test/08
1732 Source source = addSource(r''' 1860 Source source = addSource(r'''
1733 abstract class I<U> { 1861 abstract class I<U> {
1734 m(U u) => null; 1862 m(U u) => null;
1735 } 1863 }
1736 abstract class J<V> { 1864 abstract class J<V> {
1737 m(V v) => null; 1865 m(V v) => null;
1738 } 1866 }
1739 class B implements I<int>, J<String> { 1867 class B implements I<int>, J<String> {
1740 m(double d) {} 1868 m(double d) {}
1741 }'''); 1869 }''');
1870 await computeAnalysisResult(source);
1742 await assertErrors( 1871 await assertErrors(
1743 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]); 1872 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
1744 verify([source]); 1873 verify([source]);
1745 } 1874 }
1746 1875
1747 test_invalidMethodOverrideOptionalParamType() async { 1876 test_invalidMethodOverrideOptionalParamType() async {
1748 Source source = addSource(r''' 1877 Source source = addSource(r'''
1749 class A { 1878 class A {
1750 m([int a]) {} 1879 m([int a]) {}
1751 } 1880 }
1752 class B implements A { 1881 class B implements A {
1753 m([String a]) {} 1882 m([String a]) {}
1754 }'''); 1883 }''');
1884 await computeAnalysisResult(source);
1755 await assertErrors(source, 1885 await assertErrors(source,
1756 [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE]); 1886 [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE]);
1757 verify([source]); 1887 verify([source]);
1758 } 1888 }
1759 1889
1760 test_invalidMethodOverrideOptionalParamType_twoInterfaces() async { 1890 test_invalidMethodOverrideOptionalParamType_twoInterfaces() async {
1761 Source source = addSource(r''' 1891 Source source = addSource(r'''
1762 abstract class I { 1892 abstract class I {
1763 m([int n]); 1893 m([int n]);
1764 } 1894 }
1765 abstract class J { 1895 abstract class J {
1766 m([num n]); 1896 m([num n]);
1767 } 1897 }
1768 abstract class A implements I, J {} 1898 abstract class A implements I, J {}
1769 class B extends A { 1899 class B extends A {
1770 m([String n]) {} 1900 m([String n]) {}
1771 }'''); 1901 }''');
1902 await computeAnalysisResult(source);
1772 await assertErrors(source, 1903 await assertErrors(source,
1773 [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE]); 1904 [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE]);
1774 verify([source]); 1905 verify([source]);
1775 } 1906 }
1776 1907
1777 test_invalidMethodOverrideReturnType_interface() async { 1908 test_invalidMethodOverrideReturnType_interface() async {
1778 Source source = addSource(r''' 1909 Source source = addSource(r'''
1779 class A { 1910 class A {
1780 int m() { return 0; } 1911 int m() { return 0; }
1781 } 1912 }
1782 class B implements A { 1913 class B implements A {
1783 String m() { return 'a'; } 1914 String m() { return 'a'; }
1784 }'''); 1915 }''');
1916 await computeAnalysisResult(source);
1785 await assertErrors( 1917 await assertErrors(
1786 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 1918 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
1787 verify([source]); 1919 verify([source]);
1788 } 1920 }
1789 1921
1790 test_invalidMethodOverrideReturnType_interface_grandparent() async { 1922 test_invalidMethodOverrideReturnType_interface_grandparent() async {
1791 Source source = addSource(r''' 1923 Source source = addSource(r'''
1792 abstract class A { 1924 abstract class A {
1793 int m(); 1925 int m();
1794 } 1926 }
1795 abstract class B implements A { 1927 abstract class B implements A {
1796 } 1928 }
1797 class C implements B { 1929 class C implements B {
1798 String m() { return 'a'; } 1930 String m() { return 'a'; }
1799 }'''); 1931 }''');
1932 await computeAnalysisResult(source);
1800 await assertErrors( 1933 await assertErrors(
1801 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 1934 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
1802 verify([source]); 1935 verify([source]);
1803 } 1936 }
1804 1937
1805 test_invalidMethodOverrideReturnType_mixin() async { 1938 test_invalidMethodOverrideReturnType_mixin() async {
1806 Source source = addSource(r''' 1939 Source source = addSource(r'''
1807 class A { 1940 class A {
1808 int m() { return 0; } 1941 int m() { return 0; }
1809 } 1942 }
1810 class B extends Object with A { 1943 class B extends Object with A {
1811 String m() { return 'a'; } 1944 String m() { return 'a'; }
1812 }'''); 1945 }''');
1946 await computeAnalysisResult(source);
1813 await assertErrors( 1947 await assertErrors(
1814 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 1948 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
1815 verify([source]); 1949 verify([source]);
1816 } 1950 }
1817 1951
1818 test_invalidMethodOverrideReturnType_superclass() async { 1952 test_invalidMethodOverrideReturnType_superclass() async {
1819 Source source = addSource(r''' 1953 Source source = addSource(r'''
1820 class A { 1954 class A {
1821 int m() { return 0; } 1955 int m() { return 0; }
1822 } 1956 }
1823 class B extends A { 1957 class B extends A {
1824 String m() { return 'a'; } 1958 String m() { return 'a'; }
1825 }'''); 1959 }''');
1960 await computeAnalysisResult(source);
1826 await assertErrors( 1961 await assertErrors(
1827 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 1962 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
1828 verify([source]); 1963 verify([source]);
1829 } 1964 }
1830 1965
1831 test_invalidMethodOverrideReturnType_superclass_grandparent() async { 1966 test_invalidMethodOverrideReturnType_superclass_grandparent() async {
1832 Source source = addSource(r''' 1967 Source source = addSource(r'''
1833 class A { 1968 class A {
1834 int m() { return 0; } 1969 int m() { return 0; }
1835 } 1970 }
1836 class B extends A { 1971 class B extends A {
1837 } 1972 }
1838 class C extends B { 1973 class C extends B {
1839 String m() { return 'a'; } 1974 String m() { return 'a'; }
1840 }'''); 1975 }''');
1976 await computeAnalysisResult(source);
1841 await assertErrors( 1977 await assertErrors(
1842 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 1978 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
1843 verify([source]); 1979 verify([source]);
1844 } 1980 }
1845 1981
1846 test_invalidMethodOverrideReturnType_twoInterfaces() async { 1982 test_invalidMethodOverrideReturnType_twoInterfaces() async {
1847 Source source = addSource(r''' 1983 Source source = addSource(r'''
1848 abstract class I { 1984 abstract class I {
1849 int m(); 1985 int m();
1850 } 1986 }
1851 abstract class J { 1987 abstract class J {
1852 num m(); 1988 num m();
1853 } 1989 }
1854 abstract class A implements I, J {} 1990 abstract class A implements I, J {}
1855 class B extends A { 1991 class B extends A {
1856 String m() => ''; 1992 String m() => '';
1857 }'''); 1993 }''');
1994 await computeAnalysisResult(source);
1858 await assertErrors( 1995 await assertErrors(
1859 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 1996 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
1860 verify([source]); 1997 verify([source]);
1861 } 1998 }
1862 1999
1863 test_invalidMethodOverrideReturnType_void() async { 2000 test_invalidMethodOverrideReturnType_void() async {
1864 Source source = addSource(r''' 2001 Source source = addSource(r'''
1865 class A { 2002 class A {
1866 int m() { return 0; } 2003 int m() { return 0; }
1867 } 2004 }
1868 class B extends A { 2005 class B extends A {
1869 void m() {} 2006 void m() {}
1870 }'''); 2007 }''');
2008 await computeAnalysisResult(source);
1871 await assertErrors( 2009 await assertErrors(
1872 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 2010 source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
1873 verify([source]); 2011 verify([source]);
1874 } 2012 }
1875 2013
1876 test_invalidOverride_defaultOverridesNonDefault() async { 2014 test_invalidOverride_defaultOverridesNonDefault() async {
1877 // If the base class provided an explicit value for a default parameter, 2015 // If the base class provided an explicit value for a default parameter,
1878 // then it is a static warning for the derived class to provide a different 2016 // then it is a static warning for the derived class to provide a different
1879 // value, even if implicitly. 2017 // value, even if implicitly.
1880 Source source = addSource(r''' 2018 Source source = addSource(r'''
1881 class A { 2019 class A {
1882 foo([x = 1]) {} 2020 foo([x = 1]) {}
1883 } 2021 }
1884 class B extends A { 2022 class B extends A {
1885 foo([x]) {} 2023 foo([x]) {}
1886 } 2024 }
1887 '''); 2025 ''');
2026 await computeAnalysisResult(source);
1888 await assertErrors(source, [ 2027 await assertErrors(source, [
1889 StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL 2028 StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL
1890 ]); 2029 ]);
1891 verify([source]); 2030 verify([source]);
1892 } 2031 }
1893 2032
1894 test_invalidOverride_defaultOverridesNonDefault_named() async { 2033 test_invalidOverride_defaultOverridesNonDefault_named() async {
1895 // If the base class provided an explicit value for a default parameter, 2034 // If the base class provided an explicit value for a default parameter,
1896 // then it is a static warning for the derived class to provide a different 2035 // then it is a static warning for the derived class to provide a different
1897 // value, even if implicitly. 2036 // value, even if implicitly.
1898 Source source = addSource(r''' 2037 Source source = addSource(r'''
1899 class A { 2038 class A {
1900 foo({x: 1}) {} 2039 foo({x: 1}) {}
1901 } 2040 }
1902 class B extends A { 2041 class B extends A {
1903 foo({x}) {} 2042 foo({x}) {}
1904 } 2043 }
1905 '''); 2044 ''');
2045 await computeAnalysisResult(source);
1906 await assertErrors(source, 2046 await assertErrors(source,
1907 [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED]); 2047 [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED]);
1908 verify([source]); 2048 verify([source]);
1909 } 2049 }
1910 2050
1911 test_invalidOverride_defaultOverridesNonDefaultNull() async { 2051 test_invalidOverride_defaultOverridesNonDefaultNull() async {
1912 // If the base class provided an explicit null value for a default 2052 // If the base class provided an explicit null value for a default
1913 // parameter, then it is ok for the derived class to let the default value 2053 // parameter, then it is ok for the derived class to let the default value
1914 // be implicit, because the implicit default value of null matches the 2054 // be implicit, because the implicit default value of null matches the
1915 // explicit default value of null. 2055 // explicit default value of null.
1916 Source source = addSource(r''' 2056 Source source = addSource(r'''
1917 class A { 2057 class A {
1918 foo([x = null]) {} 2058 foo([x = null]) {}
1919 } 2059 }
1920 class B extends A { 2060 class B extends A {
1921 foo([x]) {} 2061 foo([x]) {}
1922 } 2062 }
1923 '''); 2063 ''');
2064 await computeAnalysisResult(source);
1924 await assertNoErrors(source); 2065 await assertNoErrors(source);
1925 verify([source]); 2066 verify([source]);
1926 } 2067 }
1927 2068
1928 test_invalidOverride_defaultOverridesNonDefaultNull_named() async { 2069 test_invalidOverride_defaultOverridesNonDefaultNull_named() async {
1929 // If the base class provided an explicit null value for a default 2070 // If the base class provided an explicit null value for a default
1930 // parameter, then it is ok for the derived class to let the default value 2071 // parameter, then it is ok for the derived class to let the default value
1931 // be implicit, because the implicit default value of null matches the 2072 // be implicit, because the implicit default value of null matches the
1932 // explicit default value of null. 2073 // explicit default value of null.
1933 Source source = addSource(r''' 2074 Source source = addSource(r'''
1934 class A { 2075 class A {
1935 foo({x: null}) {} 2076 foo({x: null}) {}
1936 } 2077 }
1937 class B extends A { 2078 class B extends A {
1938 foo({x}) {} 2079 foo({x}) {}
1939 } 2080 }
1940 '''); 2081 ''');
2082 await computeAnalysisResult(source);
1941 await assertNoErrors(source); 2083 await assertNoErrors(source);
1942 verify([source]); 2084 verify([source]);
1943 } 2085 }
1944 2086
1945 test_invalidOverride_nonDefaultOverridesDefault() async { 2087 test_invalidOverride_nonDefaultOverridesDefault() async {
1946 // If the base class lets the default parameter be implicit, then it is ok 2088 // If the base class lets the default parameter be implicit, then it is ok
1947 // for the derived class to provide an explicit default value, even if it's 2089 // for the derived class to provide an explicit default value, even if it's
1948 // not null. 2090 // not null.
1949 Source source = addSource(r''' 2091 Source source = addSource(r'''
1950 class A { 2092 class A {
1951 foo([x]) {} 2093 foo([x]) {}
1952 } 2094 }
1953 class B extends A { 2095 class B extends A {
1954 foo([x = 1]) {} 2096 foo([x = 1]) {}
1955 } 2097 }
1956 '''); 2098 ''');
2099 await computeAnalysisResult(source);
1957 await assertNoErrors(source); 2100 await assertNoErrors(source);
1958 verify([source]); 2101 verify([source]);
1959 } 2102 }
1960 2103
1961 test_invalidOverride_nonDefaultOverridesDefault_named() async { 2104 test_invalidOverride_nonDefaultOverridesDefault_named() async {
1962 // If the base class lets the default parameter be implicit, then it is ok 2105 // If the base class lets the default parameter be implicit, then it is ok
1963 // for the derived class to provide an explicit default value, even if it's 2106 // for the derived class to provide an explicit default value, even if it's
1964 // not null. 2107 // not null.
1965 Source source = addSource(r''' 2108 Source source = addSource(r'''
1966 class A { 2109 class A {
1967 foo({x}) {} 2110 foo({x}) {}
1968 } 2111 }
1969 class B extends A { 2112 class B extends A {
1970 foo({x: 1}) {} 2113 foo({x: 1}) {}
1971 } 2114 }
1972 '''); 2115 ''');
2116 await computeAnalysisResult(source);
1973 await assertNoErrors(source); 2117 await assertNoErrors(source);
1974 verify([source]); 2118 verify([source]);
1975 } 2119 }
1976 2120
1977 test_invalidOverrideDifferentDefaultValues_named() async { 2121 test_invalidOverrideDifferentDefaultValues_named() async {
1978 Source source = addSource(r''' 2122 Source source = addSource(r'''
1979 class A { 2123 class A {
1980 m({int p : 0}) {} 2124 m({int p : 0}) {}
1981 } 2125 }
1982 class B extends A { 2126 class B extends A {
1983 m({int p : 1}) {} 2127 m({int p : 1}) {}
1984 }'''); 2128 }''');
2129 await computeAnalysisResult(source);
1985 await assertErrors(source, 2130 await assertErrors(source,
1986 [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED]); 2131 [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED]);
1987 verify([source]); 2132 verify([source]);
1988 } 2133 }
1989 2134
1990 test_invalidOverrideDifferentDefaultValues_positional() async { 2135 test_invalidOverrideDifferentDefaultValues_positional() async {
1991 Source source = addSource(r''' 2136 Source source = addSource(r'''
1992 class A { 2137 class A {
1993 m([int p = 0]) {} 2138 m([int p = 0]) {}
1994 } 2139 }
1995 class B extends A { 2140 class B extends A {
1996 m([int p = 1]) {} 2141 m([int p = 1]) {}
1997 }'''); 2142 }''');
2143 await computeAnalysisResult(source);
1998 await assertErrors(source, [ 2144 await assertErrors(source, [
1999 StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL 2145 StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL
2000 ]); 2146 ]);
2001 verify([source]); 2147 verify([source]);
2002 } 2148 }
2003 2149
2004 test_invalidOverrideNamed_fewerNamedParameters() async { 2150 test_invalidOverrideNamed_fewerNamedParameters() async {
2005 Source source = addSource(r''' 2151 Source source = addSource(r'''
2006 class A { 2152 class A {
2007 m({a, b}) {} 2153 m({a, b}) {}
2008 } 2154 }
2009 class B extends A { 2155 class B extends A {
2010 m({a}) {} 2156 m({a}) {}
2011 }'''); 2157 }''');
2158 await computeAnalysisResult(source);
2012 await assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); 2159 await assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]);
2013 verify([source]); 2160 verify([source]);
2014 } 2161 }
2015 2162
2016 test_invalidOverrideNamed_missingNamedParameter() async { 2163 test_invalidOverrideNamed_missingNamedParameter() async {
2017 Source source = addSource(r''' 2164 Source source = addSource(r'''
2018 class A { 2165 class A {
2019 m({a, b}) {} 2166 m({a, b}) {}
2020 } 2167 }
2021 class B extends A { 2168 class B extends A {
2022 m({a, c}) {} 2169 m({a, c}) {}
2023 }'''); 2170 }''');
2171 await computeAnalysisResult(source);
2024 await assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); 2172 await assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]);
2025 verify([source]); 2173 verify([source]);
2026 } 2174 }
2027 2175
2028 test_invalidOverridePositional_optional() async { 2176 test_invalidOverridePositional_optional() async {
2029 Source source = addSource(r''' 2177 Source source = addSource(r'''
2030 class A { 2178 class A {
2031 m([a, b]) {} 2179 m([a, b]) {}
2032 } 2180 }
2033 class B extends A { 2181 class B extends A {
2034 m([a]) {} 2182 m([a]) {}
2035 }'''); 2183 }''');
2184 await computeAnalysisResult(source);
2036 await assertErrors( 2185 await assertErrors(
2037 source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); 2186 source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
2038 verify([source]); 2187 verify([source]);
2039 } 2188 }
2040 2189
2041 test_invalidOverridePositional_optionalAndRequired() async { 2190 test_invalidOverridePositional_optionalAndRequired() async {
2042 Source source = addSource(r''' 2191 Source source = addSource(r'''
2043 class A { 2192 class A {
2044 m(a, b, [c, d]) {} 2193 m(a, b, [c, d]) {}
2045 } 2194 }
2046 class B extends A { 2195 class B extends A {
2047 m(a, b, [c]) {} 2196 m(a, b, [c]) {}
2048 }'''); 2197 }''');
2198 await computeAnalysisResult(source);
2049 await assertErrors( 2199 await assertErrors(
2050 source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); 2200 source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
2051 verify([source]); 2201 verify([source]);
2052 } 2202 }
2053 2203
2054 test_invalidOverridePositional_optionalAndRequired2() async { 2204 test_invalidOverridePositional_optionalAndRequired2() async {
2055 Source source = addSource(r''' 2205 Source source = addSource(r'''
2056 class A { 2206 class A {
2057 m(a, b, [c, d]) {} 2207 m(a, b, [c, d]) {}
2058 } 2208 }
2059 class B extends A { 2209 class B extends A {
2060 m(a, [c, d]) {} 2210 m(a, [c, d]) {}
2061 }'''); 2211 }''');
2212 await computeAnalysisResult(source);
2062 await assertErrors( 2213 await assertErrors(
2063 source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); 2214 source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
2064 verify([source]); 2215 verify([source]);
2065 } 2216 }
2066 2217
2067 test_invalidOverrideRequired() async { 2218 test_invalidOverrideRequired() async {
2068 Source source = addSource(r''' 2219 Source source = addSource(r'''
2069 class A { 2220 class A {
2070 m(a) {} 2221 m(a) {}
2071 } 2222 }
2072 class B extends A { 2223 class B extends A {
2073 m(a, b) {} 2224 m(a, b) {}
2074 }'''); 2225 }''');
2226 await computeAnalysisResult(source);
2075 await assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_REQUIRED]); 2227 await assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_REQUIRED]);
2076 verify([source]); 2228 verify([source]);
2077 } 2229 }
2078 2230
2079 test_invalidSetterOverrideNormalParamType() async { 2231 test_invalidSetterOverrideNormalParamType() async {
2080 Source source = addSource(r''' 2232 Source source = addSource(r'''
2081 class A { 2233 class A {
2082 void set s(int v) {} 2234 void set s(int v) {}
2083 } 2235 }
2084 class B extends A { 2236 class B extends A {
2085 void set s(String v) {} 2237 void set s(String v) {}
2086 }'''); 2238 }''');
2239 await computeAnalysisResult(source);
2087 await assertErrors( 2240 await assertErrors(
2088 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); 2241 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
2089 verify([source]); 2242 verify([source]);
2090 } 2243 }
2091 2244
2092 test_invalidSetterOverrideNormalParamType_superclass_interface() async { 2245 test_invalidSetterOverrideNormalParamType_superclass_interface() async {
2093 Source source = addSource(r''' 2246 Source source = addSource(r'''
2094 abstract class I { 2247 abstract class I {
2095 set setter14(int _) => null; 2248 set setter14(int _) => null;
2096 } 2249 }
2097 abstract class J { 2250 abstract class J {
2098 set setter14(num _) => null; 2251 set setter14(num _) => null;
2099 } 2252 }
2100 abstract class A extends I implements J {} 2253 abstract class A extends I implements J {}
2101 class B extends A { 2254 class B extends A {
2102 set setter14(String _) => null; 2255 set setter14(String _) => null;
2103 }'''); 2256 }''');
2257 await computeAnalysisResult(source);
2104 await assertErrors( 2258 await assertErrors(
2105 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); 2259 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
2106 verify([source]); 2260 verify([source]);
2107 } 2261 }
2108 2262
2109 test_invalidSetterOverrideNormalParamType_twoInterfaces() async { 2263 test_invalidSetterOverrideNormalParamType_twoInterfaces() async {
2110 // test from language/override_inheritance_field_test_34.dart 2264 // test from language/override_inheritance_field_test_34.dart
2111 Source source = addSource(r''' 2265 Source source = addSource(r'''
2112 abstract class I { 2266 abstract class I {
2113 set setter14(int _) => null; 2267 set setter14(int _) => null;
2114 } 2268 }
2115 abstract class J { 2269 abstract class J {
2116 set setter14(num _) => null; 2270 set setter14(num _) => null;
2117 } 2271 }
2118 abstract class A implements I, J {} 2272 abstract class A implements I, J {}
2119 class B extends A { 2273 class B extends A {
2120 set setter14(String _) => null; 2274 set setter14(String _) => null;
2121 }'''); 2275 }''');
2276 await computeAnalysisResult(source);
2122 await assertErrors( 2277 await assertErrors(
2123 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); 2278 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
2124 verify([source]); 2279 verify([source]);
2125 } 2280 }
2126 2281
2127 test_invalidSetterOverrideNormalParamType_twoInterfaces_conflicting() async { 2282 test_invalidSetterOverrideNormalParamType_twoInterfaces_conflicting() async {
2128 Source source = addSource(r''' 2283 Source source = addSource(r'''
2129 abstract class I<U> { 2284 abstract class I<U> {
2130 set s(U u) {} 2285 set s(U u) {}
2131 } 2286 }
2132 abstract class J<V> { 2287 abstract class J<V> {
2133 set s(V v) {} 2288 set s(V v) {}
2134 } 2289 }
2135 class B implements I<int>, J<String> { 2290 class B implements I<int>, J<String> {
2136 set s(double d) {} 2291 set s(double d) {}
2137 }'''); 2292 }''');
2293 await computeAnalysisResult(source);
2138 await assertErrors( 2294 await assertErrors(
2139 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); 2295 source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
2140 verify([source]); 2296 verify([source]);
2141 } 2297 }
2142 2298
2143 test_listElementTypeNotAssignable() async { 2299 test_listElementTypeNotAssignable() async {
2144 Source source = addSource("var v = <String> [42];"); 2300 Source source = addSource("var v = <String> [42];");
2301 await computeAnalysisResult(source);
2145 await assertErrors( 2302 await assertErrors(
2146 source, [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]); 2303 source, [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
2147 verify([source]); 2304 verify([source]);
2148 } 2305 }
2149 2306
2150 test_mapKeyTypeNotAssignable() async { 2307 test_mapKeyTypeNotAssignable() async {
2151 Source source = addSource("var v = <String, int > {1 : 2};"); 2308 Source source = addSource("var v = <String, int > {1 : 2};");
2309 await computeAnalysisResult(source);
2152 await assertErrors( 2310 await assertErrors(
2153 source, [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); 2311 source, [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
2154 verify([source]); 2312 verify([source]);
2155 } 2313 }
2156 2314
2157 test_mapValueTypeNotAssignable() async { 2315 test_mapValueTypeNotAssignable() async {
2158 Source source = addSource("var v = <String, String> {'a' : 2};"); 2316 Source source = addSource("var v = <String, String> {'a' : 2};");
2317 await computeAnalysisResult(source);
2159 await assertErrors( 2318 await assertErrors(
2160 source, [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); 2319 source, [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
2161 verify([source]); 2320 verify([source]);
2162 } 2321 }
2163 2322
2164 test_mismatchedAccessorTypes_class() async { 2323 test_mismatchedAccessorTypes_class() async {
2165 Source source = addSource(r''' 2324 Source source = addSource(r'''
2166 class A { 2325 class A {
2167 int get g { return 0; } 2326 int get g { return 0; }
2168 set g(String v) {} 2327 set g(String v) {}
2169 }'''); 2328 }''');
2329 await computeAnalysisResult(source);
2170 await assertErrors( 2330 await assertErrors(
2171 source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); 2331 source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
2172 verify([source]); 2332 verify([source]);
2173 } 2333 }
2174 2334
2175 test_mismatchedAccessorTypes_getterAndSuperSetter() async { 2335 test_mismatchedAccessorTypes_getterAndSuperSetter() async {
2176 Source source = addSource(r''' 2336 Source source = addSource(r'''
2177 class A { 2337 class A {
2178 int get g { return 0; } 2338 int get g { return 0; }
2179 } 2339 }
2180 class B extends A { 2340 class B extends A {
2181 set g(String v) {} 2341 set g(String v) {}
2182 }'''); 2342 }''');
2343 await computeAnalysisResult(source);
2183 await assertErrors(source, 2344 await assertErrors(source,
2184 [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE]); 2345 [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE]);
2185 verify([source]); 2346 verify([source]);
2186 } 2347 }
2187 2348
2188 test_mismatchedAccessorTypes_setterAndSuperGetter() async { 2349 test_mismatchedAccessorTypes_setterAndSuperGetter() async {
2189 Source source = addSource(r''' 2350 Source source = addSource(r'''
2190 class A { 2351 class A {
2191 set g(int v) {} 2352 set g(int v) {}
2192 } 2353 }
2193 class B extends A { 2354 class B extends A {
2194 String get g { return ''; } 2355 String get g { return ''; }
2195 }'''); 2356 }''');
2357 await computeAnalysisResult(source);
2196 await assertErrors(source, 2358 await assertErrors(source,
2197 [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE]); 2359 [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE]);
2198 verify([source]); 2360 verify([source]);
2199 } 2361 }
2200 2362
2201 test_mismatchedAccessorTypes_topLevel() async { 2363 test_mismatchedAccessorTypes_topLevel() async {
2202 Source source = addSource(r''' 2364 Source source = addSource(r'''
2203 int get g { return 0; } 2365 int get g { return 0; }
2204 set g(String v) {}'''); 2366 set g(String v) {}''');
2367 await computeAnalysisResult(source);
2205 await assertErrors( 2368 await assertErrors(
2206 source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); 2369 source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
2207 verify([source]); 2370 verify([source]);
2208 } 2371 }
2209 2372
2210 test_missingEnumConstantInSwitch() async { 2373 test_missingEnumConstantInSwitch() async {
2211 Source source = addSource(r''' 2374 Source source = addSource(r'''
2212 enum E { ONE, TWO, THREE, FOUR } 2375 enum E { ONE, TWO, THREE, FOUR }
2213 bool odd(E e) { 2376 bool odd(E e) {
2214 switch (e) { 2377 switch (e) {
2215 case E.ONE: 2378 case E.ONE:
2216 case E.THREE: return true; 2379 case E.THREE: return true;
2217 } 2380 }
2218 return false; 2381 return false;
2219 }'''); 2382 }''');
2383 await computeAnalysisResult(source);
2220 await assertErrors(source, [ 2384 await assertErrors(source, [
2221 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH, 2385 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH,
2222 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH 2386 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH
2223 ]); 2387 ]);
2224 verify([source]); 2388 verify([source]);
2225 } 2389 }
2226 2390
2227 test_mixedReturnTypes_localFunction() async { 2391 test_mixedReturnTypes_localFunction() async {
2228 Source source = addSource(r''' 2392 Source source = addSource(r'''
2229 class C { 2393 class C {
2230 m(int x) { 2394 m(int x) {
2231 return (int y) { 2395 return (int y) {
2232 if (y < 0) { 2396 if (y < 0) {
2233 return; 2397 return;
2234 } 2398 }
2235 return 0; 2399 return 0;
2236 }; 2400 };
2237 } 2401 }
2238 }'''); 2402 }''');
2403 await computeAnalysisResult(source);
2239 await assertErrors(source, [ 2404 await assertErrors(source, [
2240 StaticWarningCode.MIXED_RETURN_TYPES, 2405 StaticWarningCode.MIXED_RETURN_TYPES,
2241 StaticWarningCode.MIXED_RETURN_TYPES 2406 StaticWarningCode.MIXED_RETURN_TYPES
2242 ]); 2407 ]);
2243 verify([source]); 2408 verify([source]);
2244 } 2409 }
2245 2410
2246 test_mixedReturnTypes_method() async { 2411 test_mixedReturnTypes_method() async {
2247 Source source = addSource(r''' 2412 Source source = addSource(r'''
2248 class C { 2413 class C {
2249 m(int x) { 2414 m(int x) {
2250 if (x < 0) { 2415 if (x < 0) {
2251 return; 2416 return;
2252 } 2417 }
2253 return 0; 2418 return 0;
2254 } 2419 }
2255 }'''); 2420 }''');
2421 await computeAnalysisResult(source);
2256 await assertErrors(source, [ 2422 await assertErrors(source, [
2257 StaticWarningCode.MIXED_RETURN_TYPES, 2423 StaticWarningCode.MIXED_RETURN_TYPES,
2258 StaticWarningCode.MIXED_RETURN_TYPES 2424 StaticWarningCode.MIXED_RETURN_TYPES
2259 ]); 2425 ]);
2260 verify([source]); 2426 verify([source]);
2261 } 2427 }
2262 2428
2263 test_mixedReturnTypes_topLevelFunction() async { 2429 test_mixedReturnTypes_topLevelFunction() async {
2264 Source source = addSource(r''' 2430 Source source = addSource(r'''
2265 f(int x) { 2431 f(int x) {
2266 if (x < 0) { 2432 if (x < 0) {
2267 return; 2433 return;
2268 } 2434 }
2269 return 0; 2435 return 0;
2270 }'''); 2436 }''');
2437 await computeAnalysisResult(source);
2271 await assertErrors(source, [ 2438 await assertErrors(source, [
2272 StaticWarningCode.MIXED_RETURN_TYPES, 2439 StaticWarningCode.MIXED_RETURN_TYPES,
2273 StaticWarningCode.MIXED_RETURN_TYPES 2440 StaticWarningCode.MIXED_RETURN_TYPES
2274 ]); 2441 ]);
2275 verify([source]); 2442 verify([source]);
2276 } 2443 }
2277 2444
2278 test_newWithAbstractClass() async { 2445 test_newWithAbstractClass() async {
2279 Source source = addSource(r''' 2446 Source source = addSource(r'''
2280 abstract class A {} 2447 abstract class A {}
2281 void f() { 2448 void f() {
2282 A a = new A(); 2449 A a = new A();
2283 }'''); 2450 }''');
2451 await computeAnalysisResult(source);
2284 await assertErrors(source, [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]); 2452 await assertErrors(source, [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]);
2285 verify([source]); 2453 verify([source]);
2286 } 2454 }
2287 2455
2288 test_newWithInvalidTypeParameters() async { 2456 test_newWithInvalidTypeParameters() async {
2289 Source source = addSource(r''' 2457 Source source = addSource(r'''
2290 class A {} 2458 class A {}
2291 f() { return new A<A>(); }'''); 2459 f() { return new A<A>(); }''');
2460 await computeAnalysisResult(source);
2292 await assertErrors( 2461 await assertErrors(
2293 source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); 2462 source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
2294 verify([source]); 2463 verify([source]);
2295 } 2464 }
2296 2465
2297 test_newWithInvalidTypeParameters_tooFew() async { 2466 test_newWithInvalidTypeParameters_tooFew() async {
2298 Source source = addSource(r''' 2467 Source source = addSource(r'''
2299 class A {} 2468 class A {}
2300 class C<K, V> {} 2469 class C<K, V> {}
2301 f(p) { 2470 f(p) {
2302 return new C<A>(); 2471 return new C<A>();
2303 }'''); 2472 }''');
2473 await computeAnalysisResult(source);
2304 await assertErrors( 2474 await assertErrors(
2305 source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); 2475 source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
2306 verify([source]); 2476 verify([source]);
2307 } 2477 }
2308 2478
2309 test_newWithInvalidTypeParameters_tooMany() async { 2479 test_newWithInvalidTypeParameters_tooMany() async {
2310 Source source = addSource(r''' 2480 Source source = addSource(r'''
2311 class A {} 2481 class A {}
2312 class C<E> {} 2482 class C<E> {}
2313 f(p) { 2483 f(p) {
2314 return new C<A, A>(); 2484 return new C<A, A>();
2315 }'''); 2485 }''');
2486 await computeAnalysisResult(source);
2316 await assertErrors( 2487 await assertErrors(
2317 source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); 2488 source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
2318 verify([source]); 2489 verify([source]);
2319 } 2490 }
2320 2491
2321 test_newWithNonType() async { 2492 test_newWithNonType() async {
2322 Source source = addSource(r''' 2493 Source source = addSource(r'''
2323 var A = 0; 2494 var A = 0;
2324 void f() { 2495 void f() {
2325 var a = new A(); 2496 var a = new A();
2326 }'''); 2497 }''');
2498 await computeAnalysisResult(source);
2327 await assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]); 2499 await assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]);
2328 verify([source]); 2500 verify([source]);
2329 } 2501 }
2330 2502
2331 test_newWithNonType_fromLibrary() async { 2503 test_newWithNonType_fromLibrary() async {
2332 Source source1 = addNamedSource("/lib.dart", "class B {}"); 2504 Source source1 = addNamedSource("/lib.dart", "class B {}");
2333 Source source2 = addNamedSource( 2505 Source source2 = addNamedSource(
2334 "/lib2.dart", 2506 "/lib2.dart",
2335 r''' 2507 r'''
2336 import 'lib.dart' as lib; 2508 import 'lib.dart' as lib;
2337 void f() { 2509 void f() {
2338 var a = new lib.A(); 2510 var a = new lib.A();
2339 } 2511 }
2340 lib.B b;'''); 2512 lib.B b;''');
2513 await computeAnalysisResult(source1);
2514 await computeAnalysisResult(source2);
2341 await assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]); 2515 await assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]);
2342 verify([source1]); 2516 verify([source1]);
2343 } 2517 }
2344 2518
2345 test_newWithUndefinedConstructor() async { 2519 test_newWithUndefinedConstructor() async {
2346 Source source = addSource(r''' 2520 Source source = addSource(r'''
2347 class A { 2521 class A {
2348 A() {} 2522 A() {}
2349 } 2523 }
2350 f() { 2524 f() {
2351 new A.name(); 2525 new A.name();
2352 }'''); 2526 }''');
2527 await computeAnalysisResult(source);
2353 await assertErrors( 2528 await assertErrors(
2354 source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]); 2529 source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
2355 // no verify(), 'name' is not resolved 2530 // no verify(), 'name' is not resolved
2356 } 2531 }
2357 2532
2358 test_newWithUndefinedConstructorDefault() async { 2533 test_newWithUndefinedConstructorDefault() async {
2359 Source source = addSource(r''' 2534 Source source = addSource(r'''
2360 class A { 2535 class A {
2361 A.name() {} 2536 A.name() {}
2362 } 2537 }
2363 f() { 2538 f() {
2364 new A(); 2539 new A();
2365 }'''); 2540 }''');
2541 await computeAnalysisResult(source);
2366 await assertErrors( 2542 await assertErrors(
2367 source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]); 2543 source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]);
2368 verify([source]); 2544 verify([source]);
2369 } 2545 }
2370 2546
2371 test_nonAbstractClassInheritsAbstractMemberFivePlus() async { 2547 test_nonAbstractClassInheritsAbstractMemberFivePlus() async {
2372 Source source = addSource(r''' 2548 Source source = addSource(r'''
2373 abstract class A { 2549 abstract class A {
2374 m(); 2550 m();
2375 n(); 2551 n();
2376 o(); 2552 o();
2377 p(); 2553 p();
2378 q(); 2554 q();
2379 } 2555 }
2380 class C extends A { 2556 class C extends A {
2381 }'''); 2557 }''');
2558 await computeAnalysisResult(source);
2382 await assertErrors(source, [ 2559 await assertErrors(source, [
2383 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS 2560 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS
2384 ]); 2561 ]);
2385 verify([source]); 2562 verify([source]);
2386 } 2563 }
2387 2564
2388 test_nonAbstractClassInheritsAbstractMemberFour() async { 2565 test_nonAbstractClassInheritsAbstractMemberFour() async {
2389 Source source = addSource(r''' 2566 Source source = addSource(r'''
2390 abstract class A { 2567 abstract class A {
2391 m(); 2568 m();
2392 n(); 2569 n();
2393 o(); 2570 o();
2394 p(); 2571 p();
2395 } 2572 }
2396 class C extends A { 2573 class C extends A {
2397 }'''); 2574 }''');
2575 await computeAnalysisResult(source);
2398 await assertErrors(source, 2576 await assertErrors(source,
2399 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR]); 2577 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR]);
2400 verify([source]); 2578 verify([source]);
2401 } 2579 }
2402 2580
2403 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() asyn c { 2581 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() asyn c {
2404 // 15979 2582 // 15979
2405 Source source = addSource(r''' 2583 Source source = addSource(r'''
2406 abstract class M {} 2584 abstract class M {}
2407 abstract class A {} 2585 abstract class A {}
2408 abstract class I { 2586 abstract class I {
2409 m(); 2587 m();
2410 } 2588 }
2411 class B = A with M implements I;'''); 2589 class B = A with M implements I;''');
2590 await computeAnalysisResult(source);
2412 await assertErrors(source, 2591 await assertErrors(source,
2413 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2592 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2414 verify([source]); 2593 verify([source]);
2415 } 2594 }
2416 2595
2417 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() async { 2596 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() async {
2418 // 15979 2597 // 15979
2419 Source source = addSource(r''' 2598 Source source = addSource(r'''
2420 abstract class M { 2599 abstract class M {
2421 m(); 2600 m();
2422 } 2601 }
2423 abstract class A {} 2602 abstract class A {}
2424 class B = A with M;'''); 2603 class B = A with M;''');
2604 await computeAnalysisResult(source);
2425 await assertErrors(source, 2605 await assertErrors(source,
2426 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2606 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2427 verify([source]); 2607 verify([source]);
2428 } 2608 }
2429 2609
2430 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() asy nc { 2610 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() asy nc {
2431 // 15979 2611 // 15979
2432 Source source = addSource(r''' 2612 Source source = addSource(r'''
2433 class M {} 2613 class M {}
2434 abstract class A { 2614 abstract class A {
2435 m(); 2615 m();
2436 } 2616 }
2437 class B = A with M;'''); 2617 class B = A with M;''');
2618 await computeAnalysisResult(source);
2438 await assertErrors(source, 2619 await assertErrors(source,
2439 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2620 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2440 verify([source]); 2621 verify([source]);
2441 } 2622 }
2442 2623
2443 test_nonAbstractClassInheritsAbstractMemberOne_ensureCorrectFunctionSubtypeIsU sedInImplementation() async { 2624 test_nonAbstractClassInheritsAbstractMemberOne_ensureCorrectFunctionSubtypeIsU sedInImplementation() async {
2444 // 15028 2625 // 15028
2445 Source source = addSource(r''' 2626 Source source = addSource(r'''
2446 class C { 2627 class C {
2447 foo(int x) => x; 2628 foo(int x) => x;
2448 } 2629 }
2449 abstract class D { 2630 abstract class D {
2450 foo(x, [y]); 2631 foo(x, [y]);
2451 } 2632 }
2452 class E extends C implements D {}'''); 2633 class E extends C implements D {}''');
2634 await computeAnalysisResult(source);
2453 await assertErrors(source, 2635 await assertErrors(source,
2454 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2636 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2455 verify([source]); 2637 verify([source]);
2456 } 2638 }
2457 2639
2458 test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() async { 2640 test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() async {
2459 Source source = addSource(r''' 2641 Source source = addSource(r'''
2460 class I { 2642 class I {
2461 int get g {return 1;} 2643 int get g {return 1;}
2462 } 2644 }
2463 class C implements I { 2645 class C implements I {
2464 }'''); 2646 }''');
2647 await computeAnalysisResult(source);
2465 await assertErrors(source, 2648 await assertErrors(source,
2466 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2649 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2467 verify([source]); 2650 verify([source]);
2468 } 2651 }
2469 2652
2470 test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() async { 2653 test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() async {
2471 Source source = addSource(r''' 2654 Source source = addSource(r'''
2472 abstract class A { 2655 abstract class A {
2473 int get g; 2656 int get g;
2474 } 2657 }
2475 class C extends A { 2658 class C extends A {
2476 }'''); 2659 }''');
2660 await computeAnalysisResult(source);
2477 await assertErrors(source, 2661 await assertErrors(source,
2478 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2662 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2479 verify([source]); 2663 verify([source]);
2480 } 2664 }
2481 2665
2482 test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() async { 2666 test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() async {
2483 Source source = addSource(r''' 2667 Source source = addSource(r'''
2484 class I { 2668 class I {
2485 m(p) {} 2669 m(p) {}
2486 } 2670 }
2487 class C implements I { 2671 class C implements I {
2488 }'''); 2672 }''');
2673 await computeAnalysisResult(source);
2489 await assertErrors(source, 2674 await assertErrors(source,
2490 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2675 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2491 verify([source]); 2676 verify([source]);
2492 } 2677 }
2493 2678
2494 test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() async { 2679 test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() async {
2495 Source source = addSource(r''' 2680 Source source = addSource(r'''
2496 abstract class A { 2681 abstract class A {
2497 m(p); 2682 m(p);
2498 } 2683 }
2499 class C extends A { 2684 class C extends A {
2500 }'''); 2685 }''');
2686 await computeAnalysisResult(source);
2501 await assertErrors(source, 2687 await assertErrors(source,
2502 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2688 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2503 verify([source]); 2689 verify([source]);
2504 } 2690 }
2505 2691
2506 test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount() asy nc { 2692 test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount() asy nc {
2507 // 7640 2693 // 7640
2508 Source source = addSource(r''' 2694 Source source = addSource(r'''
2509 abstract class A { 2695 abstract class A {
2510 int x(int a); 2696 int x(int a);
2511 } 2697 }
2512 abstract class B { 2698 abstract class B {
2513 int x(int a, [int b]); 2699 int x(int a, [int b]);
2514 } 2700 }
2515 class C implements A, B { 2701 class C implements A, B {
2516 }'''); 2702 }''');
2703 await computeAnalysisResult(source);
2517 await assertErrors(source, 2704 await assertErrors(source,
2518 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2705 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2519 verify([source]); 2706 verify([source]);
2520 } 2707 }
2521 2708
2522 test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_getter() async { 2709 test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_getter() async {
2523 // 15001 2710 // 15001
2524 Source source = addSource(r''' 2711 Source source = addSource(r'''
2525 abstract class A { get g1; get g2; } 2712 abstract class A { get g1; get g2; }
2526 abstract class B implements A { get g1 => 1; } 2713 abstract class B implements A { get g1 => 1; }
2527 class C extends Object with B {}'''); 2714 class C extends Object with B {}''');
2715 await computeAnalysisResult(source);
2528 await assertErrors(source, 2716 await assertErrors(source,
2529 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2717 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2530 } 2718 }
2531 2719
2532 test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_method() async { 2720 test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_method() async {
2533 // 15001 2721 // 15001
2534 Source source = addSource(r''' 2722 Source source = addSource(r'''
2535 abstract class A { m1(); m2(); } 2723 abstract class A { m1(); m2(); }
2536 abstract class B implements A { m1() => 1; } 2724 abstract class B implements A { m1() => 1; }
2537 class C extends Object with B {}'''); 2725 class C extends Object with B {}''');
2726 await computeAnalysisResult(source);
2538 await assertErrors(source, 2727 await assertErrors(source,
2539 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2728 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2540 } 2729 }
2541 2730
2542 test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_setter() async { 2731 test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_setter() async {
2543 // 15001 2732 // 15001
2544 Source source = addSource(r''' 2733 Source source = addSource(r'''
2545 abstract class A { set s1(v); set s2(v); } 2734 abstract class A { set s1(v); set s2(v); }
2546 abstract class B implements A { set s1(v) {} } 2735 abstract class B implements A { set s1(v) {} }
2547 class C extends Object with B {}'''); 2736 class C extends Object with B {}''');
2737 await computeAnalysisResult(source);
2548 await assertErrors(source, 2738 await assertErrors(source,
2549 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2739 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2550 } 2740 }
2551 2741
2552 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_interface() async { 2742 test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_interface() async {
2553 // 15979 2743 // 15979
2554 Source source = addSource(r''' 2744 Source source = addSource(r'''
2555 class I { 2745 class I {
2556 noSuchMethod(v) => ''; 2746 noSuchMethod(v) => '';
2557 } 2747 }
2558 abstract class A { 2748 abstract class A {
2559 m(); 2749 m();
2560 } 2750 }
2561 class B extends A implements I { 2751 class B extends A implements I {
2562 }'''); 2752 }''');
2753 await computeAnalysisResult(source);
2563 await assertErrors(source, 2754 await assertErrors(source,
2564 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2755 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2565 verify([source]); 2756 verify([source]);
2566 } 2757 }
2567 2758
2568 test_nonAbstractClassInheritsAbstractMemberOne_setter_and_implicitSetter() asy nc { 2759 test_nonAbstractClassInheritsAbstractMemberOne_setter_and_implicitSetter() asy nc {
2569 // test from language/override_inheritance_abstract_test_14.dart 2760 // test from language/override_inheritance_abstract_test_14.dart
2570 Source source = addSource(r''' 2761 Source source = addSource(r'''
2571 abstract class A { 2762 abstract class A {
2572 set field(_); 2763 set field(_);
2573 } 2764 }
2574 abstract class I { 2765 abstract class I {
2575 var field; 2766 var field;
2576 } 2767 }
2577 class B extends A implements I { 2768 class B extends A implements I {
2578 get field => 0; 2769 get field => 0;
2579 }'''); 2770 }''');
2771 await computeAnalysisResult(source);
2580 await assertErrors(source, 2772 await assertErrors(source,
2581 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2773 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2582 verify([source]); 2774 verify([source]);
2583 } 2775 }
2584 2776
2585 test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() async { 2777 test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() async {
2586 Source source = addSource(r''' 2778 Source source = addSource(r'''
2587 class I { 2779 class I {
2588 set s(int i) {} 2780 set s(int i) {}
2589 } 2781 }
2590 class C implements I { 2782 class C implements I {
2591 }'''); 2783 }''');
2784 await computeAnalysisResult(source);
2592 await assertErrors(source, 2785 await assertErrors(source,
2593 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2786 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2594 verify([source]); 2787 verify([source]);
2595 } 2788 }
2596 2789
2597 test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() async { 2790 test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() async {
2598 Source source = addSource(r''' 2791 Source source = addSource(r'''
2599 abstract class A { 2792 abstract class A {
2600 set s(int i); 2793 set s(int i);
2601 } 2794 }
2602 class C extends A { 2795 class C extends A {
2603 }'''); 2796 }''');
2797 await computeAnalysisResult(source);
2604 await assertErrors(source, 2798 await assertErrors(source,
2605 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2799 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2606 verify([source]); 2800 verify([source]);
2607 } 2801 }
2608 2802
2609 test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() async { 2803 test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() async {
2610 // bug 11154 2804 // bug 11154
2611 Source source = addSource(r''' 2805 Source source = addSource(r'''
2612 class A { 2806 class A {
2613 get a => 'a'; 2807 get a => 'a';
2614 } 2808 }
2615 abstract class B implements A { 2809 abstract class B implements A {
2616 get b => 'b'; 2810 get b => 'b';
2617 } 2811 }
2618 class C extends B { 2812 class C extends B {
2619 }'''); 2813 }''');
2814 await computeAnalysisResult(source);
2620 await assertErrors(source, 2815 await assertErrors(source,
2621 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2816 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2622 verify([source]); 2817 verify([source]);
2623 } 2818 }
2624 2819
2625 test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingG etter() async { 2820 test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingG etter() async {
2626 // 16133 2821 // 16133
2627 Source source = addSource(r''' 2822 Source source = addSource(r'''
2628 class I { 2823 class I {
2629 var v; 2824 var v;
2630 } 2825 }
2631 class C implements I { 2826 class C implements I {
2632 set v(_) {} 2827 set v(_) {}
2633 }'''); 2828 }''');
2829 await computeAnalysisResult(source);
2634 await assertErrors(source, 2830 await assertErrors(source,
2635 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2831 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2636 verify([source]); 2832 verify([source]);
2637 } 2833 }
2638 2834
2639 test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingS etter() async { 2835 test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingS etter() async {
2640 // 16133 2836 // 16133
2641 Source source = addSource(r''' 2837 Source source = addSource(r'''
2642 class I { 2838 class I {
2643 var v; 2839 var v;
2644 } 2840 }
2645 class C implements I { 2841 class C implements I {
2646 get v => 1; 2842 get v => 1;
2647 }'''); 2843 }''');
2844 await computeAnalysisResult(source);
2648 await assertErrors(source, 2845 await assertErrors(source,
2649 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2846 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2650 verify([source]); 2847 verify([source]);
2651 } 2848 }
2652 2849
2653 test_nonAbstractClassInheritsAbstractMemberThree() async { 2850 test_nonAbstractClassInheritsAbstractMemberThree() async {
2654 Source source = addSource(r''' 2851 Source source = addSource(r'''
2655 abstract class A { 2852 abstract class A {
2656 m(); 2853 m();
2657 n(); 2854 n();
2658 o(); 2855 o();
2659 } 2856 }
2660 class C extends A { 2857 class C extends A {
2661 }'''); 2858 }''');
2859 await computeAnalysisResult(source);
2662 await assertErrors(source, 2860 await assertErrors(source,
2663 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE]); 2861 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE]);
2664 verify([source]); 2862 verify([source]);
2665 } 2863 }
2666 2864
2667 test_nonAbstractClassInheritsAbstractMemberTwo() async { 2865 test_nonAbstractClassInheritsAbstractMemberTwo() async {
2668 Source source = addSource(r''' 2866 Source source = addSource(r'''
2669 abstract class A { 2867 abstract class A {
2670 m(); 2868 m();
2671 n(); 2869 n();
2672 } 2870 }
2673 class C extends A { 2871 class C extends A {
2674 }'''); 2872 }''');
2873 await computeAnalysisResult(source);
2675 await assertErrors(source, 2874 await assertErrors(source,
2676 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]); 2875 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
2677 verify([source]); 2876 verify([source]);
2678 } 2877 }
2679 2878
2680 test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromInterface_missingB oth() async { 2879 test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromInterface_missingB oth() async {
2681 // 16133 2880 // 16133
2682 Source source = addSource(r''' 2881 Source source = addSource(r'''
2683 class I { 2882 class I {
2684 var v; 2883 var v;
2685 } 2884 }
2686 class C implements I { 2885 class C implements I {
2687 }'''); 2886 }''');
2887 await computeAnalysisResult(source);
2688 await assertErrors(source, 2888 await assertErrors(source,
2689 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]); 2889 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
2690 verify([source]); 2890 verify([source]);
2691 } 2891 }
2692 2892
2693 test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromMixin_missingBoth( ) async { 2893 test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromMixin_missingBoth( ) async {
2694 // 26411 2894 // 26411
2695 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); 2895 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
2696 Source source = addSource(r''' 2896 Source source = addSource(r'''
2697 class A { 2897 class A {
2698 int f; 2898 int f;
2699 } 2899 }
2700 class B extends A {} 2900 class B extends A {}
2701 class C extends Object with B {} 2901 class C extends Object with B {}
2702 '''); 2902 ''');
2903 await computeAnalysisResult(source);
2703 await assertErrors(source, 2904 await assertErrors(source,
2704 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]); 2905 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
2705 verify([source]); 2906 verify([source]);
2706 } 2907 }
2707 2908
2708 test_nonTypeInCatchClause_noElement() async { 2909 test_nonTypeInCatchClause_noElement() async {
2709 Source source = addSource(r''' 2910 Source source = addSource(r'''
2710 f() { 2911 f() {
2711 try { 2912 try {
2712 } on T catch (e) { 2913 } on T catch (e) {
2713 } 2914 }
2714 }'''); 2915 }''');
2916 await computeAnalysisResult(source);
2715 await assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); 2917 await assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
2716 verify([source]); 2918 verify([source]);
2717 } 2919 }
2718 2920
2719 test_nonTypeInCatchClause_notType() async { 2921 test_nonTypeInCatchClause_notType() async {
2720 Source source = addSource(r''' 2922 Source source = addSource(r'''
2721 var T = 0; 2923 var T = 0;
2722 f() { 2924 f() {
2723 try { 2925 try {
2724 } on T catch (e) { 2926 } on T catch (e) {
2725 } 2927 }
2726 }'''); 2928 }''');
2929 await computeAnalysisResult(source);
2727 await assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); 2930 await assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
2728 verify([source]); 2931 verify([source]);
2729 } 2932 }
2730 2933
2731 test_nonVoidReturnForOperator() async { 2934 test_nonVoidReturnForOperator() async {
2732 Source source = addSource(r''' 2935 Source source = addSource(r'''
2733 class A { 2936 class A {
2734 int operator []=(a, b) { return a; } 2937 int operator []=(a, b) { return a; }
2735 }'''); 2938 }''');
2939 await computeAnalysisResult(source);
2736 await assertErrors( 2940 await assertErrors(
2737 source, [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]); 2941 source, [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]);
2738 verify([source]); 2942 verify([source]);
2739 } 2943 }
2740 2944
2741 test_nonVoidReturnForSetter_function() async { 2945 test_nonVoidReturnForSetter_function() async {
2742 Source source = addSource(r''' 2946 Source source = addSource(r'''
2743 int set x(int v) { 2947 int set x(int v) {
2744 return 42; 2948 return 42;
2745 }'''); 2949 }''');
2950 await computeAnalysisResult(source);
2746 await assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); 2951 await assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
2747 verify([source]); 2952 verify([source]);
2748 } 2953 }
2749 2954
2750 test_nonVoidReturnForSetter_method() async { 2955 test_nonVoidReturnForSetter_method() async {
2751 Source source = addSource(r''' 2956 Source source = addSource(r'''
2752 class A { 2957 class A {
2753 int set x(int v) { 2958 int set x(int v) {
2754 return 42; 2959 return 42;
2755 } 2960 }
2756 }'''); 2961 }''');
2962 await computeAnalysisResult(source);
2757 await assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); 2963 await assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
2758 verify([source]); 2964 verify([source]);
2759 } 2965 }
2760 2966
2761 test_notAType() async { 2967 test_notAType() async {
2762 Source source = addSource(r''' 2968 Source source = addSource(r'''
2763 f() {} 2969 f() {}
2764 main() { 2970 main() {
2765 f v = null; 2971 f v = null;
2766 }'''); 2972 }''');
2973 await computeAnalysisResult(source);
2767 await assertErrors(source, [StaticWarningCode.NOT_A_TYPE]); 2974 await assertErrors(source, [StaticWarningCode.NOT_A_TYPE]);
2768 verify([source]); 2975 verify([source]);
2769 } 2976 }
2770 2977
2771 test_notEnoughRequiredArguments() async { 2978 test_notEnoughRequiredArguments() async {
2772 Source source = addSource(r''' 2979 Source source = addSource(r'''
2773 f(int a, String b) {} 2980 f(int a, String b) {}
2774 main() { 2981 main() {
2775 f(); 2982 f();
2776 }'''); 2983 }''');
2984 await computeAnalysisResult(source);
2777 await assertErrors( 2985 await assertErrors(
2778 source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); 2986 source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
2779 verify([source]); 2987 verify([source]);
2780 } 2988 }
2781 2989
2782 test_notEnoughRequiredArguments_functionExpression() async { 2990 test_notEnoughRequiredArguments_functionExpression() async {
2783 Source source = addSource(r''' 2991 Source source = addSource(r'''
2784 main() { 2992 main() {
2785 (int x) {} (); 2993 (int x) {} ();
2786 }'''); 2994 }''');
2995 await computeAnalysisResult(source);
2787 await assertErrors( 2996 await assertErrors(
2788 source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); 2997 source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
2789 verify([source]); 2998 verify([source]);
2790 } 2999 }
2791 3000
2792 test_notEnoughRequiredArguments_getterReturningFunction() async { 3001 test_notEnoughRequiredArguments_getterReturningFunction() async {
2793 Source source = addSource(r''' 3002 Source source = addSource(r'''
2794 typedef Getter(self); 3003 typedef Getter(self);
2795 Getter getter = (x) => x; 3004 Getter getter = (x) => x;
2796 main() { 3005 main() {
2797 getter(); 3006 getter();
2798 }'''); 3007 }''');
3008 await computeAnalysisResult(source);
2799 await assertErrors( 3009 await assertErrors(
2800 source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); 3010 source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
2801 verify([source]); 3011 verify([source]);
2802 } 3012 }
2803 3013
2804 test_partOfDifferentLibrary() async { 3014 test_partOfDifferentLibrary() async {
2805 Source source = addSource(r''' 3015 Source source = addSource(r'''
2806 library lib; 3016 library lib;
2807 part 'part.dart';'''); 3017 part 'part.dart';''');
2808 addNamedSource("/part.dart", "part of lub;"); 3018 addNamedSource("/part.dart", "part of lub;");
3019 await computeAnalysisResult(source);
2809 await assertErrors(source, [StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]); 3020 await assertErrors(source, [StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]);
2810 verify([source]); 3021 verify([source]);
2811 } 3022 }
2812 3023
2813 test_redirectToInvalidFunctionType() async { 3024 test_redirectToInvalidFunctionType() async {
2814 Source source = addSource(r''' 3025 Source source = addSource(r'''
2815 class A implements B { 3026 class A implements B {
2816 A(int p) {} 3027 A(int p) {}
2817 } 3028 }
2818 class B { 3029 class B {
2819 factory B() = A; 3030 factory B() = A;
2820 }'''); 3031 }''');
3032 await computeAnalysisResult(source);
2821 await assertErrors( 3033 await assertErrors(
2822 source, [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]); 3034 source, [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]);
2823 verify([source]); 3035 verify([source]);
2824 } 3036 }
2825 3037
2826 test_redirectToInvalidReturnType() async { 3038 test_redirectToInvalidReturnType() async {
2827 Source source = addSource(r''' 3039 Source source = addSource(r'''
2828 class A { 3040 class A {
2829 A() {} 3041 A() {}
2830 } 3042 }
2831 class B { 3043 class B {
2832 factory B() = A; 3044 factory B() = A;
2833 }'''); 3045 }''');
3046 await computeAnalysisResult(source);
2834 await assertErrors( 3047 await assertErrors(
2835 source, [StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]); 3048 source, [StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]);
2836 verify([source]); 3049 verify([source]);
2837 } 3050 }
2838 3051
2839 test_redirectToMissingConstructor_named() async { 3052 test_redirectToMissingConstructor_named() async {
2840 Source source = addSource(r''' 3053 Source source = addSource(r'''
2841 class A implements B{ 3054 class A implements B{
2842 A() {} 3055 A() {}
2843 } 3056 }
2844 class B { 3057 class B {
2845 factory B() = A.name; 3058 factory B() = A.name;
2846 }'''); 3059 }''');
3060 await computeAnalysisResult(source);
2847 await assertErrors( 3061 await assertErrors(
2848 source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); 3062 source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
2849 } 3063 }
2850 3064
2851 test_redirectToMissingConstructor_unnamed() async { 3065 test_redirectToMissingConstructor_unnamed() async {
2852 Source source = addSource(r''' 3066 Source source = addSource(r'''
2853 class A implements B{ 3067 class A implements B{
2854 A.name() {} 3068 A.name() {}
2855 } 3069 }
2856 class B { 3070 class B {
2857 factory B() = A; 3071 factory B() = A;
2858 }'''); 3072 }''');
3073 await computeAnalysisResult(source);
2859 await assertErrors( 3074 await assertErrors(
2860 source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); 3075 source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
2861 } 3076 }
2862 3077
2863 test_redirectToNonClass_notAType() async { 3078 test_redirectToNonClass_notAType() async {
2864 Source source = addSource(r''' 3079 Source source = addSource(r'''
2865 class B { 3080 class B {
2866 int A; 3081 int A;
2867 factory B() = A; 3082 factory B() = A;
2868 }'''); 3083 }''');
3084 await computeAnalysisResult(source);
2869 await assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); 3085 await assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]);
2870 verify([source]); 3086 verify([source]);
2871 } 3087 }
2872 3088
2873 test_redirectToNonClass_undefinedIdentifier() async { 3089 test_redirectToNonClass_undefinedIdentifier() async {
2874 Source source = addSource(r''' 3090 Source source = addSource(r'''
2875 class B { 3091 class B {
2876 factory B() = A; 3092 factory B() = A;
2877 }'''); 3093 }''');
3094 await computeAnalysisResult(source);
2878 await assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); 3095 await assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]);
2879 verify([source]); 3096 verify([source]);
2880 } 3097 }
2881 3098
2882 test_returnWithoutValue_async() async { 3099 test_returnWithoutValue_async() async {
2883 Source source = addSource(''' 3100 Source source = addSource('''
2884 import 'dart:async'; 3101 import 'dart:async';
2885 Future<int> f() async { 3102 Future<int> f() async {
2886 return; 3103 return;
2887 } 3104 }
2888 '''); 3105 ''');
3106 await computeAnalysisResult(source);
2889 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); 3107 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
2890 verify([source]); 3108 verify([source]);
2891 } 3109 }
2892 3110
2893 test_returnWithoutValue_factoryConstructor() async { 3111 test_returnWithoutValue_factoryConstructor() async {
2894 Source source = addSource("class A { factory A() { return; } }"); 3112 Source source = addSource("class A { factory A() { return; } }");
3113 await computeAnalysisResult(source);
2895 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); 3114 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
2896 verify([source]); 3115 verify([source]);
2897 } 3116 }
2898 3117
2899 test_returnWithoutValue_function() async { 3118 test_returnWithoutValue_function() async {
2900 Source source = addSource("int f() { return; }"); 3119 Source source = addSource("int f() { return; }");
3120 await computeAnalysisResult(source);
2901 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); 3121 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
2902 verify([source]); 3122 verify([source]);
2903 } 3123 }
2904 3124
2905 test_returnWithoutValue_method() async { 3125 test_returnWithoutValue_method() async {
2906 Source source = addSource("class A { int m() { return; } }"); 3126 Source source = addSource("class A { int m() { return; } }");
3127 await computeAnalysisResult(source);
2907 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); 3128 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
2908 verify([source]); 3129 verify([source]);
2909 } 3130 }
2910 3131
2911 test_returnWithoutValue_mixedReturnTypes_function() async { 3132 test_returnWithoutValue_mixedReturnTypes_function() async {
2912 // Tests that only the RETURN_WITHOUT_VALUE warning is created, and no 3133 // Tests that only the RETURN_WITHOUT_VALUE warning is created, and no
2913 // MIXED_RETURN_TYPES are created. 3134 // MIXED_RETURN_TYPES are created.
2914 Source source = addSource(r''' 3135 Source source = addSource(r'''
2915 int f(int x) { 3136 int f(int x) {
2916 if (x < 0) { 3137 if (x < 0) {
2917 return 1; 3138 return 1;
2918 } 3139 }
2919 return; 3140 return;
2920 }'''); 3141 }''');
3142 await computeAnalysisResult(source);
2921 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); 3143 await assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
2922 verify([source]); 3144 verify([source]);
2923 } 3145 }
2924 3146
2925 test_staticAccessToInstanceMember_method_invocation() async { 3147 test_staticAccessToInstanceMember_method_invocation() async {
2926 Source source = addSource(r''' 3148 Source source = addSource(r'''
2927 class A { 3149 class A {
2928 m() {} 3150 m() {}
2929 } 3151 }
2930 main() { 3152 main() {
2931 A.m(); 3153 A.m();
2932 }'''); 3154 }''');
3155 await computeAnalysisResult(source);
2933 await assertErrors( 3156 await assertErrors(
2934 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); 3157 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
2935 verify([source]); 3158 verify([source]);
2936 } 3159 }
2937 3160
2938 test_staticAccessToInstanceMember_method_reference() async { 3161 test_staticAccessToInstanceMember_method_reference() async {
2939 Source source = addSource(r''' 3162 Source source = addSource(r'''
2940 class A { 3163 class A {
2941 m() {} 3164 m() {}
2942 } 3165 }
2943 main() { 3166 main() {
2944 A.m; 3167 A.m;
2945 }'''); 3168 }''');
3169 await computeAnalysisResult(source);
2946 await assertErrors( 3170 await assertErrors(
2947 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); 3171 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
2948 verify([source]); 3172 verify([source]);
2949 } 3173 }
2950 3174
2951 test_staticAccessToInstanceMember_propertyAccess_field() async { 3175 test_staticAccessToInstanceMember_propertyAccess_field() async {
2952 Source source = addSource(r''' 3176 Source source = addSource(r'''
2953 class A { 3177 class A {
2954 var f; 3178 var f;
2955 } 3179 }
2956 main() { 3180 main() {
2957 A.f; 3181 A.f;
2958 }'''); 3182 }''');
3183 await computeAnalysisResult(source);
2959 await assertErrors( 3184 await assertErrors(
2960 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); 3185 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
2961 verify([source]); 3186 verify([source]);
2962 } 3187 }
2963 3188
2964 test_staticAccessToInstanceMember_propertyAccess_getter() async { 3189 test_staticAccessToInstanceMember_propertyAccess_getter() async {
2965 Source source = addSource(r''' 3190 Source source = addSource(r'''
2966 class A { 3191 class A {
2967 get f => 42; 3192 get f => 42;
2968 } 3193 }
2969 main() { 3194 main() {
2970 A.f; 3195 A.f;
2971 }'''); 3196 }''');
3197 await computeAnalysisResult(source);
2972 await assertErrors( 3198 await assertErrors(
2973 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); 3199 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
2974 verify([source]); 3200 verify([source]);
2975 } 3201 }
2976 3202
2977 test_staticAccessToInstanceMember_propertyAccess_setter() async { 3203 test_staticAccessToInstanceMember_propertyAccess_setter() async {
2978 Source source = addSource(r''' 3204 Source source = addSource(r'''
2979 class A { 3205 class A {
2980 set f(x) {} 3206 set f(x) {}
2981 } 3207 }
2982 main() { 3208 main() {
2983 A.f = 42; 3209 A.f = 42;
2984 }'''); 3210 }''');
3211 await computeAnalysisResult(source);
2985 await assertErrors( 3212 await assertErrors(
2986 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); 3213 source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
2987 verify([source]); 3214 verify([source]);
2988 } 3215 }
2989 3216
2990 test_switchExpressionNotAssignable() async { 3217 test_switchExpressionNotAssignable() async {
2991 Source source = addSource(r''' 3218 Source source = addSource(r'''
2992 f(int p) { 3219 f(int p) {
2993 switch (p) { 3220 switch (p) {
2994 case 'a': break; 3221 case 'a': break;
2995 } 3222 }
2996 }'''); 3223 }''');
3224 await computeAnalysisResult(source);
2997 await assertErrors( 3225 await assertErrors(
2998 source, [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]); 3226 source, [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]);
2999 verify([source]); 3227 verify([source]);
3000 } 3228 }
3001 3229
3002 test_typeAnnotationDeferredClass_asExpression() async { 3230 test_typeAnnotationDeferredClass_asExpression() async {
3003 await resolveWithErrors(<String>[ 3231 await resolveWithErrors(<String>[
3004 r''' 3232 r'''
3005 library lib1; 3233 library lib1;
3006 class A {}''', 3234 class A {}''',
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 3413
3186 test_typeAnnotationGenericFunctionParameter_localFunction() async { 3414 test_typeAnnotationGenericFunctionParameter_localFunction() async {
3187 Source source = addSource(r''' 3415 Source source = addSource(r'''
3188 class A { 3416 class A {
3189 void method() { 3417 void method() {
3190 T local<T>(Object t) { 3418 T local<T>(Object t) {
3191 return (t is T) ? t : null; 3419 return (t is T) ? t : null;
3192 } 3420 }
3193 } 3421 }
3194 }'''); 3422 }''');
3423 await computeAnalysisResult(source);
3195 await assertErrors( 3424 await assertErrors(
3196 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); 3425 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
3197 verify([source]); 3426 verify([source]);
3198 } 3427 }
3199 3428
3200 test_typeAnnotationGenericFunctionParameter_method() async { 3429 test_typeAnnotationGenericFunctionParameter_method() async {
3201 Source source = addSource(r''' 3430 Source source = addSource(r'''
3202 class A { 3431 class A {
3203 T method<T>(Object t) { 3432 T method<T>(Object t) {
3204 return (t is T) ? t : null; 3433 return (t is T) ? t : null;
3205 } 3434 }
3206 }'''); 3435 }''');
3436 await computeAnalysisResult(source);
3207 await assertErrors( 3437 await assertErrors(
3208 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); 3438 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
3209 verify([source]); 3439 verify([source]);
3210 } 3440 }
3211 3441
3212 test_typeAnnotationGenericFunctionParameter_topLevelFunction() async { 3442 test_typeAnnotationGenericFunctionParameter_topLevelFunction() async {
3213 Source source = addSource(r''' 3443 Source source = addSource(r'''
3214 T function<T>(Object t) { 3444 T function<T>(Object t) {
3215 return (t is T) ? t : null; 3445 return (t is T) ? t : null;
3216 }'''); 3446 }''');
3447 await computeAnalysisResult(source);
3217 await assertErrors( 3448 await assertErrors(
3218 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); 3449 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
3219 verify([source]); 3450 verify([source]);
3220 } 3451 }
3221 3452
3222 test_typeParameterReferencedByStatic_field() async { 3453 test_typeParameterReferencedByStatic_field() async {
3223 Source source = addSource(r''' 3454 Source source = addSource(r'''
3224 class A<K> { 3455 class A<K> {
3225 static K k; 3456 static K k;
3226 }'''); 3457 }''');
3458 await computeAnalysisResult(source);
3227 await assertErrors( 3459 await assertErrors(
3228 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); 3460 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
3229 verify([source]); 3461 verify([source]);
3230 } 3462 }
3231 3463
3232 test_typeParameterReferencedByStatic_getter() async { 3464 test_typeParameterReferencedByStatic_getter() async {
3233 Source source = addSource(r''' 3465 Source source = addSource(r'''
3234 class A<K> { 3466 class A<K> {
3235 static K get k => null; 3467 static K get k => null;
3236 }'''); 3468 }''');
3469 await computeAnalysisResult(source);
3237 await assertErrors( 3470 await assertErrors(
3238 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); 3471 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
3239 verify([source]); 3472 verify([source]);
3240 } 3473 }
3241 3474
3242 test_typeParameterReferencedByStatic_methodBodyReference() async { 3475 test_typeParameterReferencedByStatic_methodBodyReference() async {
3243 Source source = addSource(r''' 3476 Source source = addSource(r'''
3244 class A<K> { 3477 class A<K> {
3245 static m() { 3478 static m() {
3246 K k; 3479 K k;
3247 } 3480 }
3248 }'''); 3481 }''');
3482 await computeAnalysisResult(source);
3249 await assertErrors( 3483 await assertErrors(
3250 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); 3484 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
3251 verify([source]); 3485 verify([source]);
3252 } 3486 }
3253 3487
3254 test_typeParameterReferencedByStatic_methodParameter() async { 3488 test_typeParameterReferencedByStatic_methodParameter() async {
3255 Source source = addSource(r''' 3489 Source source = addSource(r'''
3256 class A<K> { 3490 class A<K> {
3257 static m(K k) {} 3491 static m(K k) {}
3258 }'''); 3492 }''');
3493 await computeAnalysisResult(source);
3259 await assertErrors( 3494 await assertErrors(
3260 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); 3495 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
3261 verify([source]); 3496 verify([source]);
3262 } 3497 }
3263 3498
3264 test_typeParameterReferencedByStatic_methodReturn() async { 3499 test_typeParameterReferencedByStatic_methodReturn() async {
3265 Source source = addSource(r''' 3500 Source source = addSource(r'''
3266 class A<K> { 3501 class A<K> {
3267 static K m() { return null; } 3502 static K m() { return null; }
3268 }'''); 3503 }''');
3504 await computeAnalysisResult(source);
3269 await assertErrors( 3505 await assertErrors(
3270 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); 3506 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
3271 verify([source]); 3507 verify([source]);
3272 } 3508 }
3273 3509
3274 test_typeParameterReferencedByStatic_setter() async { 3510 test_typeParameterReferencedByStatic_setter() async {
3275 Source source = addSource(r''' 3511 Source source = addSource(r'''
3276 class A<K> { 3512 class A<K> {
3277 static set s(K k) {} 3513 static set s(K k) {}
3278 }'''); 3514 }''');
3515 await computeAnalysisResult(source);
3279 await assertErrors( 3516 await assertErrors(
3280 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); 3517 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
3281 verify([source]); 3518 verify([source]);
3282 } 3519 }
3283 3520
3284 test_typePromotion_functionType_arg_InterToDyn() async { 3521 test_typePromotion_functionType_arg_InterToDyn() async {
3285 Source source = addSource(r''' 3522 Source source = addSource(r'''
3286 typedef FuncDyn(x); 3523 typedef FuncDyn(x);
3287 typedef FuncA(A a); 3524 typedef FuncA(A a);
3288 class A {} 3525 class A {}
3289 class B {} 3526 class B {}
3290 main(FuncA f) { 3527 main(FuncA f) {
3291 if (f is FuncDyn) { 3528 if (f is FuncDyn) {
3292 f(new B()); 3529 f(new B());
3293 } 3530 }
3294 }'''); 3531 }''');
3532 await computeAnalysisResult(source);
3295 await assertErrors( 3533 await assertErrors(
3296 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 3534 source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
3297 } 3535 }
3298 3536
3299 test_typeTestNonType() async { 3537 test_typeTestNonType() async {
3300 Source source = addSource(r''' 3538 Source source = addSource(r'''
3301 var A = 0; 3539 var A = 0;
3302 f(var p) { 3540 f(var p) {
3303 if (p is A) { 3541 if (p is A) {
3304 } 3542 }
3305 }'''); 3543 }''');
3544 await computeAnalysisResult(source);
3306 await assertErrors(source, [StaticWarningCode.TYPE_TEST_WITH_NON_TYPE]); 3545 await assertErrors(source, [StaticWarningCode.TYPE_TEST_WITH_NON_TYPE]);
3307 verify([source]); 3546 verify([source]);
3308 } 3547 }
3309 3548
3310 test_typeTestWithUndefinedName() async { 3549 test_typeTestWithUndefinedName() async {
3311 Source source = addSource(r''' 3550 Source source = addSource(r'''
3312 f(var p) { 3551 f(var p) {
3313 if (p is A) { 3552 if (p is A) {
3314 } 3553 }
3315 }'''); 3554 }''');
3555 await computeAnalysisResult(source);
3316 await assertErrors( 3556 await assertErrors(
3317 source, [StaticWarningCode.TYPE_TEST_WITH_UNDEFINED_NAME]); 3557 source, [StaticWarningCode.TYPE_TEST_WITH_UNDEFINED_NAME]);
3318 verify([source]); 3558 verify([source]);
3319 } 3559 }
3320 3560
3321 test_undefinedClass_instanceCreation() async { 3561 test_undefinedClass_instanceCreation() async {
3322 Source source = addSource("f() { new C(); }"); 3562 Source source = addSource("f() { new C(); }");
3563 await computeAnalysisResult(source);
3323 await assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); 3564 await assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
3324 } 3565 }
3325 3566
3326 test_undefinedClass_variableDeclaration() async { 3567 test_undefinedClass_variableDeclaration() async {
3327 Source source = addSource("f() { C c; }"); 3568 Source source = addSource("f() { C c; }");
3569 await computeAnalysisResult(source);
3328 await assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); 3570 await assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
3329 } 3571 }
3330 3572
3331 test_undefinedClassBoolean_variableDeclaration() async { 3573 test_undefinedClassBoolean_variableDeclaration() async {
3332 Source source = addSource("f() { boolean v; }"); 3574 Source source = addSource("f() { boolean v; }");
3575 await computeAnalysisResult(source);
3333 await assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); 3576 await assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]);
3334 } 3577 }
3335 3578
3336 test_undefinedGetter_fromLibrary() async { 3579 test_undefinedGetter_fromLibrary() async {
3337 Source source1 = addNamedSource("/lib.dart", ""); 3580 Source source1 = addNamedSource("/lib.dart", "");
3338 Source source2 = addNamedSource( 3581 Source source2 = addNamedSource(
3339 "/lib2.dart", 3582 "/lib2.dart",
3340 r''' 3583 r'''
3341 import 'lib.dart' as lib; 3584 import 'lib.dart' as lib;
3342 void f() { 3585 void f() {
3343 var g = lib.gg; 3586 var g = lib.gg;
3344 }'''); 3587 }''');
3588 await computeAnalysisResult(source1);
3589 await computeAnalysisResult(source2);
3345 await assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]); 3590 await assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]);
3346 verify([source1]); 3591 verify([source1]);
3347 } 3592 }
3348 3593
3349 test_undefinedIdentifier_for() async { 3594 test_undefinedIdentifier_for() async {
3350 Source source = addSource(r''' 3595 Source source = addSource(r'''
3351 f(var l) { 3596 f(var l) {
3352 for (e in l) { 3597 for (e in l) {
3353 } 3598 }
3354 }'''); 3599 }''');
3600 await computeAnalysisResult(source);
3355 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3601 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3356 } 3602 }
3357 3603
3358 test_undefinedIdentifier_function() async { 3604 test_undefinedIdentifier_function() async {
3359 Source source = addSource("int a() => b;"); 3605 Source source = addSource("int a() => b;");
3606 await computeAnalysisResult(source);
3360 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3607 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3361 } 3608 }
3362 3609
3363 test_undefinedIdentifier_importCore_withShow() async { 3610 test_undefinedIdentifier_importCore_withShow() async {
3364 Source source = addSource(r''' 3611 Source source = addSource(r'''
3365 import 'dart:core' show List; 3612 import 'dart:core' show List;
3366 main() { 3613 main() {
3367 List; 3614 List;
3368 String; 3615 String;
3369 }'''); 3616 }''');
3617 await computeAnalysisResult(source);
3370 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3618 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3371 } 3619 }
3372 3620
3373 test_undefinedIdentifier_initializer() async { 3621 test_undefinedIdentifier_initializer() async {
3374 Source source = addSource("var a = b;"); 3622 Source source = addSource("var a = b;");
3623 await computeAnalysisResult(source);
3375 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3624 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3376 } 3625 }
3377 3626
3378 test_undefinedIdentifier_methodInvocation() async { 3627 test_undefinedIdentifier_methodInvocation() async {
3379 Source source = addSource("f() { C.m(); }"); 3628 Source source = addSource("f() { C.m(); }");
3629 await computeAnalysisResult(source);
3380 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3630 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3381 } 3631 }
3382 3632
3383 test_undefinedIdentifier_private_getter() async { 3633 test_undefinedIdentifier_private_getter() async {
3384 addNamedSource( 3634 addNamedSource(
3385 "/lib.dart", 3635 "/lib.dart",
3386 r''' 3636 r'''
3387 library lib; 3637 library lib;
3388 class A { 3638 class A {
3389 var _foo; 3639 var _foo;
3390 }'''); 3640 }''');
3391 Source source = addSource(r''' 3641 Source source = addSource(r'''
3392 import 'lib.dart'; 3642 import 'lib.dart';
3393 class B extends A { 3643 class B extends A {
3394 test() { 3644 test() {
3395 var v = _foo; 3645 var v = _foo;
3396 } 3646 }
3397 }'''); 3647 }''');
3648 await computeAnalysisResult(source);
3398 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3649 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3399 } 3650 }
3400 3651
3401 test_undefinedIdentifier_private_setter() async { 3652 test_undefinedIdentifier_private_setter() async {
3402 addNamedSource( 3653 addNamedSource(
3403 "/lib.dart", 3654 "/lib.dart",
3404 r''' 3655 r'''
3405 library lib; 3656 library lib;
3406 class A { 3657 class A {
3407 var _foo; 3658 var _foo;
3408 }'''); 3659 }''');
3409 Source source = addSource(r''' 3660 Source source = addSource(r'''
3410 import 'lib.dart'; 3661 import 'lib.dart';
3411 class B extends A { 3662 class B extends A {
3412 test() { 3663 test() {
3413 _foo = 42; 3664 _foo = 42;
3414 } 3665 }
3415 }'''); 3666 }''');
3667 await computeAnalysisResult(source);
3416 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3668 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3417 } 3669 }
3418 3670
3419 test_undefinedIdentifierAwait_function() async { 3671 test_undefinedIdentifierAwait_function() async {
3420 Source source = addSource("void a() { await; }"); 3672 Source source = addSource("void a() { await; }");
3673 await computeAnalysisResult(source);
3421 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT]); 3674 await assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT]);
3422 } 3675 }
3423 3676
3424 test_undefinedNamedParameter() async { 3677 test_undefinedNamedParameter() async {
3425 Source source = addSource(r''' 3678 Source source = addSource(r'''
3426 f({a, b}) {} 3679 f({a, b}) {}
3427 main() { 3680 main() {
3428 f(c: 1); 3681 f(c: 1);
3429 }'''); 3682 }''');
3683 await computeAnalysisResult(source);
3430 await assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); 3684 await assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]);
3431 // no verify(), 'c' is not resolved 3685 // no verify(), 'c' is not resolved
3432 } 3686 }
3433 3687
3434 test_undefinedSetter() async { 3688 test_undefinedSetter() async {
3435 addNamedSource("/lib.dart", ""); 3689 addNamedSource("/lib.dart", "");
3436 Source source2 = addNamedSource( 3690 Source source2 = addNamedSource(
3437 "/lib2.dart", 3691 "/lib2.dart",
3438 r''' 3692 r'''
3439 import 'lib.dart' as lib; 3693 import 'lib.dart' as lib;
3440 void f() { 3694 void f() {
3441 lib.gg = null; 3695 lib.gg = null;
3442 }'''); 3696 }''');
3697 await computeAnalysisResult(source2);
3443 await assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]); 3698 await assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]);
3444 } 3699 }
3445 3700
3446 test_undefinedStaticMethodOrGetter_getter() async { 3701 test_undefinedStaticMethodOrGetter_getter() async {
3447 Source source = addSource(r''' 3702 Source source = addSource(r'''
3448 class C {} 3703 class C {}
3449 f(var p) { 3704 f(var p) {
3450 f(C.m); 3705 f(C.m);
3451 }'''); 3706 }''');
3707 await computeAnalysisResult(source);
3452 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); 3708 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
3453 } 3709 }
3454 3710
3455 test_undefinedStaticMethodOrGetter_getter_inSuperclass() async { 3711 test_undefinedStaticMethodOrGetter_getter_inSuperclass() async {
3456 Source source = addSource(r''' 3712 Source source = addSource(r'''
3457 class S { 3713 class S {
3458 static int get g => 0; 3714 static int get g => 0;
3459 } 3715 }
3460 class C extends S {} 3716 class C extends S {}
3461 f(var p) { 3717 f(var p) {
3462 f(C.g); 3718 f(C.g);
3463 }'''); 3719 }''');
3720 await computeAnalysisResult(source);
3464 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); 3721 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
3465 } 3722 }
3466 3723
3467 test_undefinedStaticMethodOrGetter_method() async { 3724 test_undefinedStaticMethodOrGetter_method() async {
3468 Source source = addSource(r''' 3725 Source source = addSource(r'''
3469 class C {} 3726 class C {}
3470 f(var p) { 3727 f(var p) {
3471 f(C.m()); 3728 f(C.m());
3472 }'''); 3729 }''');
3730 await computeAnalysisResult(source);
3473 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); 3731 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
3474 } 3732 }
3475 3733
3476 test_undefinedStaticMethodOrGetter_method_inSuperclass() async { 3734 test_undefinedStaticMethodOrGetter_method_inSuperclass() async {
3477 Source source = addSource(r''' 3735 Source source = addSource(r'''
3478 class S { 3736 class S {
3479 static m() {} 3737 static m() {}
3480 } 3738 }
3481 class C extends S {} 3739 class C extends S {}
3482 f(var p) { 3740 f(var p) {
3483 f(C.m()); 3741 f(C.m());
3484 }'''); 3742 }''');
3743 await computeAnalysisResult(source);
3485 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); 3744 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
3486 } 3745 }
3487 3746
3488 test_undefinedStaticMethodOrGetter_setter_inSuperclass() async { 3747 test_undefinedStaticMethodOrGetter_setter_inSuperclass() async {
3489 Source source = addSource(r''' 3748 Source source = addSource(r'''
3490 class S { 3749 class S {
3491 static set s(int i) {} 3750 static set s(int i) {}
3492 } 3751 }
3493 class C extends S {} 3752 class C extends S {}
3494 f(var p) { 3753 f(var p) {
3495 f(C.s = 1); 3754 f(C.s = 1);
3496 }'''); 3755 }''');
3756 await computeAnalysisResult(source);
3497 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); 3757 await assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
3498 } 3758 }
3499 3759
3500 test_voidReturnForGetter() async { 3760 test_voidReturnForGetter() async {
3501 Source source = addSource(r''' 3761 Source source = addSource(r'''
3502 class S { 3762 class S {
3503 void get value {} 3763 void get value {}
3504 }'''); 3764 }''');
3765 await computeAnalysisResult(source);
3505 await assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); 3766 await assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]);
3506 } 3767 }
3507 } 3768 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698