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

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

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

Powered by Google App Engine
This is Rietveld 408576698