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

Side by Side Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2108823002: fix #26122, classify strong mode errors correctly (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix expectations, remove unncessary code in CLI/server Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.task.strong.checker_test; 5 library analyzer.test.src.task.strong.checker_test;
6 6
7 import '../../../reflective_tests.dart'; 7 import '../../../reflective_tests.dart';
8 import 'strong_test_helper.dart'; 8 import 'strong_test_helper.dart';
9 9
10 void main() { 10 void main() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 test() { 74 test() {
75 A a = new A(); 75 A a = new A();
76 B b = new B(); 76 B b = new B();
77 var c = foo(); 77 var c = foo();
78 a = a * b; 78 a = a * b;
79 a = a * /*info:DYNAMIC_CAST*/c; 79 a = a * /*info:DYNAMIC_CAST*/c;
80 a = a / b; 80 a = a / b;
81 a = a ~/ b; 81 a = a ~/ b;
82 a = a % b; 82 a = a % b;
83 a = a + b; 83 a = a + b;
84 a = a + /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; 84 a = a + /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a;
85 a = a - b; 85 a = a - b;
86 b = /*error:INVALID_ASSIGNMENT*/b - b; 86 b = /*error:INVALID_ASSIGNMENT*/b - b;
87 a = a << b; 87 a = a << b;
88 a = a >> b; 88 a = a >> b;
89 a = a & b; 89 a = a & b;
90 a = a ^ b; 90 a = a ^ b;
91 a = a | b; 91 a = a | b;
92 c = (/*info:DYNAMIC_INVOKE*/c + b); 92 c = (/*info:DYNAMIC_INVOKE*/c + b);
93 93
94 String x = 'hello'; 94 String x = 'hello';
95 int y = 42; 95 int y = 42;
96 x = x + x; 96 x = x + x;
97 x = x + /*info:DYNAMIC_CAST*/c; 97 x = x + /*info:DYNAMIC_CAST*/c;
98 x = x + /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y; 98 x = x + /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y;
99 99
100 bool p = true; 100 bool p = true;
101 p = p && p; 101 p = p && p;
102 p = p && /*info:DYNAMIC_CAST*/c; 102 p = p && /*info:DYNAMIC_CAST*/c;
103 p = (/*info:DYNAMIC_CAST*/c) && p; 103 p = (/*info:DYNAMIC_CAST*/c) && p;
104 p = (/*info:DYNAMIC_CAST*/c) && /*info:DYNAMIC_CAST*/c; 104 p = (/*info:DYNAMIC_CAST*/c) && /*info:DYNAMIC_CAST*/c;
105 p = /*error:NON_BOOL_OPERAND*/y && p; 105 p = /*error:NON_BOOL_OPERAND*/y && p;
106 p = c == y; 106 p = c == y;
107 107
108 a = a[b]; 108 a = a[b];
109 a = a[/*info:DYNAMIC_CAST*/c]; 109 a = a[/*info:DYNAMIC_CAST*/c];
110 c = (/*info:DYNAMIC_INVOKE*/c[b]); 110 c = (/*info:DYNAMIC_INVOKE*/c[b]);
111 a[/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y]; 111 a[/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y];
112 } 112 }
113 '''); 113 ''');
114 } 114 }
115 115
116 void test_castsInConditions() { 116 void test_castsInConditions() {
117 checkFile(''' 117 checkFile('''
118 main() { 118 main() {
119 bool b = true; 119 bool b = true;
120 num x = b ? 1 : 2.3; 120 num x = b ? 1 : 2.3;
121 int y = /*info:ASSIGNMENT_CAST*/b ? 1 : 2.3; 121 int y = /*info:ASSIGNMENT_CAST*/b ? 1 : 2.3;
(...skipping 27 matching lines...) Expand all
149 class A {} 149 class A {}
150 class B {} 150 class B {}
151 151
152 abstract class I1 { 152 abstract class I1 {
153 m(A a); 153 m(A a);
154 } 154 }
155 abstract class Base implements I1 {} 155 abstract class Base implements I1 {}
156 156
157 class T1 extends Base { 157 class T1 extends Base {
158 /*error:INVALID_METHOD_OVERRIDE*/m( 158 /*error:INVALID_METHOD_OVERRIDE*/m(
159 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 159 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
160 } 160 }
161 '''); 161 ''');
162 } 162 }
163 163
164 void test_classOverrideOfGrandInterface_interfaceOfConcreteSuperclass() { 164 void test_classOverrideOfGrandInterface_interfaceOfConcreteSuperclass() {
165 checkFile(''' 165 checkFile('''
166 class A {} 166 class A {}
167 class B {} 167 class B {}
168 168
169 abstract class I1 { 169 abstract class I1 {
170 m(A a); 170 m(A a);
171 } 171 }
172 172
173 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/Base 173 class /*error:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/Base
174 implements I1 {} 174 implements I1 {}
175 175
176 class T1 extends Base { 176 class T1 extends Base {
177 // not reported technically because if the class is concrete, 177 // not reported technically because if the class is concrete,
178 // it should implement all its interfaces and hence it is 178 // it should implement all its interfaces and hence it is
179 // sufficient to check overrides against it. 179 // sufficient to check overrides against it.
180 m(/*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 180 m(/*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
181 } 181 }
182 '''); 182 ''');
183 } 183 }
184 184
185 void test_classOverrideOfGrandInterface_interfaceOfInterfaceOfChild() { 185 void test_classOverrideOfGrandInterface_interfaceOfInterfaceOfChild() {
186 checkFile(''' 186 checkFile('''
187 class A {} 187 class A {}
188 class B {} 188 class B {}
189 189
190 abstract class I1 { 190 abstract class I1 {
191 m(A a); 191 m(A a);
192 } 192 }
193 abstract class I2 implements I1 {} 193 abstract class I2 implements I1 {}
194 194
195 class T1 implements I2 { 195 class T1 implements I2 {
196 /*error:INVALID_METHOD_OVERRIDE*/m( 196 /*error:INVALID_METHOD_OVERRIDE*/m(
197 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 197 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
198 } 198 }
199 '''); 199 ''');
200 } 200 }
201 201
202 void test_classOverrideOfGrandInterface_mixinOfInterfaceOfChild() { 202 void test_classOverrideOfGrandInterface_mixinOfInterfaceOfChild() {
203 checkFile(''' 203 checkFile('''
204 class A {} 204 class A {}
205 class B {} 205 class B {}
206 206
207 abstract class M1 { 207 abstract class M1 {
208 m(A a); 208 m(A a);
209 } 209 }
210 abstract class I2 extends Object with M1 {} 210 abstract class I2 extends Object with M1 {}
211 211
212 class T1 implements I2 { 212 class T1 implements I2 {
213 /*error:INVALID_METHOD_OVERRIDE*/m( 213 /*error:INVALID_METHOD_OVERRIDE*/m(
214 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 214 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
215 } 215 }
216 '''); 216 ''');
217 } 217 }
218 218
219 void test_classOverrideOfGrandInterface_superclassOfInterfaceOfChild() { 219 void test_classOverrideOfGrandInterface_superclassOfInterfaceOfChild() {
220 checkFile(''' 220 checkFile('''
221 class A {} 221 class A {}
222 class B {} 222 class B {}
223 223
224 abstract class I1 { 224 abstract class I1 {
225 m(A a); 225 m(A a);
226 } 226 }
227 abstract class I2 extends I1 {} 227 abstract class I2 extends I1 {}
228 228
229 class T1 implements I2 { 229 class T1 implements I2 {
230 /*error:INVALID_METHOD_OVERRIDE*/m( 230 /*error:INVALID_METHOD_OVERRIDE*/m(
231 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 231 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
232 } 232 }
233 '''); 233 ''');
234 } 234 }
235 235
236 void test_compoundAssignments() { 236 void test_compoundAssignments() {
237 checkFile(''' 237 checkFile('''
238 class A { 238 class A {
239 A operator *(B b) => null; 239 A operator *(B b) => null;
240 A operator /(B b) => null; 240 A operator /(B b) => null;
241 A operator ~/(B b) => null; 241 A operator ~/(B b) => null;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 A a = new A(); 287 A a = new A();
288 B b = new B(); 288 B b = new B();
289 var c = foo(); 289 var c = foo();
290 a = a * b; 290 a = a * b;
291 a *= b; 291 a *= b;
292 a *= /*info:DYNAMIC_CAST*/c; 292 a *= /*info:DYNAMIC_CAST*/c;
293 a /= b; 293 a /= b;
294 a ~/= b; 294 a ~/= b;
295 a %= b; 295 a %= b;
296 a += b; 296 a += b;
297 a += /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; 297 a += /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a;
298 a -= b; 298 a -= b;
299 /*error:STATIC_TYPE_ERROR*/b -= /*error:INVALID_ASSIGNMENT*/b; 299 /*error:STATIC_TYPE_ERROR*/b -= /*error:INVALID_ASSIGNMENT*/b;
300 a <<= b; 300 a <<= b;
301 a >>= b; 301 a >>= b;
302 a &= b; 302 a &= b;
303 a ^= b; 303 a ^= b;
304 a |= b; 304 a |= b;
305 /*info:DYNAMIC_INVOKE*/c += b; 305 /*info:DYNAMIC_INVOKE*/c += b;
306 306
307 var d = new D(); 307 var d = new D();
308 a[b] += d; 308 a[b] += d;
309 a[/*info:DYNAMIC_CAST*/c] += d; 309 a[/*info:DYNAMIC_CAST*/c] += d;
310 a[/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/z] += d; 310 a[/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/z] += d;
311 a[b] += /*info:DYNAMIC_CAST*/c; 311 a[b] += /*info:DYNAMIC_CAST*/c;
312 a[b] += /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/z; 312 a[b] += /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/z;
313 /*info:DYNAMIC_INVOKE,info:DYNAMIC_INVOKE*/c[b] += d; 313 /*info:DYNAMIC_INVOKE,info:DYNAMIC_INVOKE*/c[b] += d;
314 } 314 }
315 '''); 315 ''');
316 } 316 }
317 317
318 void test_constructorInvalid() { 318 void test_constructorInvalid() {
319 // Regression test for https://github.com/dart-lang/sdk/issues/26695 319 // Regression test for https://github.com/dart-lang/sdk/issues/26695
320 checkFile(''' 320 checkFile('''
321 class A { 321 class A {
322 B({ /*error:FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR*/this.test: 1.0 }) {} 322 B({ /*error:FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR*/this.test: 1.0 }) {}
323 final double test = 0.0; 323 final double test = 0.0;
324 } 324 }
325 '''); 325 ''');
326 } 326 }
327 327
328 void test_constructors() { 328 void test_constructors() {
329 checkFile(''' 329 checkFile('''
330 const num z = 25; 330 const num z = 25;
331 Object obj = "world"; 331 Object obj = "world";
332 332
333 class A { 333 class A {
334 int x; 334 int x;
335 String y; 335 String y;
336 336
337 A(this.x) : this.y = /*warning:FIELD_INITIALIZER_NOT_ASSIGNABLE*/42; 337 A(this.x) : this.y = /*error:FIELD_INITIALIZER_NOT_ASSIGNABLE*/42;
338 338
339 A.c1(p): this.x = /*info:DOWN_CAST_IMPLICIT*/z, this.y = /*info:DYNAMIC_CAST*/ p; 339 A.c1(p): this.x = /*info:DOWN_CAST_IMPLICIT*/z, this.y = /*info:DYNAMIC_CAST*/ p;
340 340
341 A.c2(this.x, this.y); 341 A.c2(this.x, this.y);
342 342
343 A.c3(/*error:INVALID_PARAMETER_DECLARATION*/num this.x, String this.y); 343 A.c3(/*error:INVALID_PARAMETER_DECLARATION*/num this.x, String this.y);
344 } 344 }
345 345
346 class B extends A { 346 class B extends A {
347 B() : super(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello"); 347 B() : super(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
348 348
349 B.c2(int x, String y) : super.c2(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y, 349 B.c2(int x, String y) : super.c2(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y,
350 /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/x); 350 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/x);
351 351
352 B.c3(num x, Object y) : super.c3(x, /*info:DOWN_CAST_IMPLICIT*/y); 352 B.c3(num x, Object y) : super.c3(x, /*info:DOWN_CAST_IMPLICIT*/y);
353 } 353 }
354 354
355 void main() { 355 void main() {
356 A a = new A.c2(/*info:DOWN_CAST_IMPLICIT*/z, /*warning:ARGUMENT_TYPE_NOT_ASSI GNABLE*/z); 356 A a = new A.c2(/*info:DOWN_CAST_IMPLICIT*/z, /*error:ARGUMENT_TYPE_NOT_ASSIGN ABLE*/z);
357 var b = new B.c2(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", /*info:DOWN _CAST_IMPLICIT*/obj); 357 var b = new B.c2(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", /*info:DOWN_C AST_IMPLICIT*/obj);
358 } 358 }
359 '''); 359 ''');
360 } 360 }
361 361
362 void test_conversionAndDynamicInvoke() { 362 void test_conversionAndDynamicInvoke() {
363 addFile( 363 addFile(
364 ''' 364 '''
365 dynamic toString = (int x) => x + 42; 365 dynamic toString = (int x) => x + 42;
366 dynamic hashCode = "hello"; 366 dynamic hashCode = "hello";
367 ''', 367 ''',
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 450 }
451 void main() { 451 void main() {
452 { 452 {
453 B f = new B(); 453 B f = new B();
454 int x; 454 int x;
455 double y; 455 double y;
456 x = f(3); 456 x = f(3);
457 x = /*error:INVALID_ASSIGNMENT*/f.col(3.0); 457 x = /*error:INVALID_ASSIGNMENT*/f.col(3.0);
458 y = /*error:INVALID_ASSIGNMENT*/f(3); 458 y = /*error:INVALID_ASSIGNMENT*/f(3);
459 y = f.col(3.0); 459 y = f.col(3.0);
460 f(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3.0); 460 f(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3.0);
461 f.col(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 461 f.col(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
462 } 462 }
463 { 463 {
464 Function f = new B(); 464 Function f = new B();
465 int x; 465 int x;
466 double y; 466 double y;
467 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); 467 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3);
468 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE, info:INVALID_ASSIGNMENT*/f.col (3.0); 468 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE, info:INVALID_ASSIGNMENT*/f.col (3.0);
469 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); 469 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3);
470 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f.col(3.0); 470 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f.col(3.0);
471 /*info:DYNAMIC_INVOKE*/f(3.0); 471 /*info:DYNAMIC_INVOKE*/f(3.0);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 B f4; 553 B f4;
554 } 554 }
555 555
556 class Child extends Base { 556 class Child extends Base {
557 /*error:INVALID_FIELD_OVERRIDE,error:INVALID_METHOD_OVERRIDE*/A get f1 => null ; 557 /*error:INVALID_FIELD_OVERRIDE,error:INVALID_METHOD_OVERRIDE*/A get f1 => null ;
558 /*error:INVALID_FIELD_OVERRIDE*/C get f2 => null; 558 /*error:INVALID_FIELD_OVERRIDE*/C get f2 => null;
559 /*error:INVALID_FIELD_OVERRIDE*/get f3 => null; 559 /*error:INVALID_FIELD_OVERRIDE*/get f3 => null;
560 /*error:INVALID_FIELD_OVERRIDE,error:INVALID_METHOD_OVERRIDE*/dynamic get f4 = > null; 560 /*error:INVALID_FIELD_OVERRIDE,error:INVALID_METHOD_OVERRIDE*/dynamic get f4 = > null;
561 } 561 }
562 562
563 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR*/Child2 impleme nts Base { 563 class /*error:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR*/Child2 implement s Base {
564 /*error:INVALID_METHOD_OVERRIDE*/A get f1 => null; 564 /*error:INVALID_METHOD_OVERRIDE*/A get f1 => null;
565 C get f2 => null; 565 C get f2 => null;
566 get f3 => null; 566 get f3 => null;
567 /*error:INVALID_METHOD_OVERRIDE*/dynamic get f4 => null; 567 /*error:INVALID_METHOD_OVERRIDE*/dynamic get f4 => null;
568 } 568 }
569 '''); 569 ''');
570 } 570 }
571 571
572 void test_fieldOverride_fuzzyArrows() { 572 void test_fieldOverride_fuzzyArrows() {
573 checkFile(''' 573 checkFile('''
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 checkFile(''' 1767 checkFile('''
1768 class A {} 1768 class A {}
1769 class B extends A {} 1769 class B extends A {}
1770 1770
1771 class Base<T extends B> { 1771 class Base<T extends B> {
1772 T foo() => null; 1772 T foo() => null;
1773 } 1773 }
1774 1774
1775 class Derived<S extends A> extends Base<B> { 1775 class Derived<S extends A> extends Base<B> {
1776 /*error:INVALID_METHOD_OVERRIDE*/S 1776 /*error:INVALID_METHOD_OVERRIDE*/S
1777 /*warning:INVALID_METHOD_OVERRIDE_RETURN_TYPE*/foo() => null; 1777 /*error:INVALID_METHOD_OVERRIDE_RETURN_TYPE*/foo() => null;
1778 } 1778 }
1779 1779
1780 class Derived2<S extends B> extends Base<B> { 1780 class Derived2<S extends B> extends Base<B> {
1781 S foo() => null; 1781 S foo() => null;
1782 } 1782 }
1783 '''); 1783 ''');
1784 } 1784 }
1785 1785
1786 void test_genericFunctionWrongNumberOfArguments() { 1786 void test_genericFunctionWrongNumberOfArguments() {
1787 checkFile(r''' 1787 checkFile(r'''
1788 /*=T*/ foo/*<T>*/(/*=T*/ x, /*=T*/ y) => x; 1788 /*=T*/ foo/*<T>*/(/*=T*/ x, /*=T*/ y) => x;
1789 /*=T*/ bar/*<T>*/({/*=T*/ x, /*=T*/ y}) => x; 1789 /*=T*/ bar/*<T>*/({/*=T*/ x, /*=T*/ y}) => x;
1790 1790
1791 main() { 1791 main() {
1792 String x; 1792 String x;
1793 // resolving these shouldn't crash. 1793 // resolving these shouldn't crash.
1794 foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/(1, 2, 3); 1794 foo/*error:EXTRA_POSITIONAL_ARGUMENTS*/(1, 2, 3);
1795 x = foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/('1', '2', '3'); 1795 x = foo/*error:EXTRA_POSITIONAL_ARGUMENTS*/('1', '2', '3');
1796 foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*/(1); 1796 foo/*error:NOT_ENOUGH_REQUIRED_ARGUMENTS*/(1);
1797 x = foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*/('1'); 1797 x = foo/*error:NOT_ENOUGH_REQUIRED_ARGUMENTS*/('1');
1798 x = /*info:DYNAMIC_CAST*/foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/(1, 2, 3); 1798 x = /*info:DYNAMIC_CAST*/foo/*error:EXTRA_POSITIONAL_ARGUMENTS*/(1, 2, 3);
1799 x = /*info:DYNAMIC_CAST*/foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*/(1); 1799 x = /*info:DYNAMIC_CAST*/foo/*error:NOT_ENOUGH_REQUIRED_ARGUMENTS*/(1);
1800 1800
1801 // named arguments 1801 // named arguments
1802 bar(y: 1, x: 2, /*warning:UNDEFINED_NAMED_PARAMETER*/z: 3); 1802 bar(y: 1, x: 2, /*error:UNDEFINED_NAMED_PARAMETER*/z: 3);
1803 x = bar(/*warning:UNDEFINED_NAMED_PARAMETER*/z: '1', x: '2', y: '3'); 1803 x = bar(/*error:UNDEFINED_NAMED_PARAMETER*/z: '1', x: '2', y: '3');
1804 bar(y: 1); 1804 bar(y: 1);
1805 x = bar(x: '1', /*warning:UNDEFINED_NAMED_PARAMETER*/z: 42); 1805 x = bar(x: '1', /*error:UNDEFINED_NAMED_PARAMETER*/z: 42);
1806 x = /*info:DYNAMIC_CAST*/bar(y: 1, x: 2, /*warning:UNDEFINED_NAMED_PARAMETER*/ z: 3); 1806 x = /*info:DYNAMIC_CAST*/bar(y: 1, x: 2, /*error:UNDEFINED_NAMED_PARAMETER*/z: 3);
1807 x = /*info:DYNAMIC_CAST*/bar(x: 1); 1807 x = /*info:DYNAMIC_CAST*/bar(x: 1);
1808 } 1808 }
1809 '''); 1809 ''');
1810 } 1810 }
1811 1811
1812 void test_genericMethodOverride() { 1812 void test_genericMethodOverride() {
1813 checkFile(''' 1813 checkFile('''
1814 class Future<T> { 1814 class Future<T> {
1815 /*=S*/ then/*<S>*/(/*=S*/ onValue(T t)) => null; 1815 /*=S*/ then/*<S>*/(/*=S*/ onValue(T t)) => null;
1816 } 1816 }
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 checkFile(''' 2160 checkFile('''
2161 class A {} 2161 class A {}
2162 class B {} 2162 class B {}
2163 2163
2164 class Base { 2164 class Base {
2165 A f; 2165 A f;
2166 } 2166 }
2167 2167
2168 class T1 extends Base { 2168 class T1 extends Base {
2169 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_FIE LD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/B get 2169 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_FIE LD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/B get
2170 /*warning:INVALID_GETTER_OVERRIDE_RETURN_TYPE*/f => null; 2170 /*error:INVALID_GETTER_OVERRIDE_RETURN_TYPE*/f => null;
2171 } 2171 }
2172 2172
2173 class T2 extends Base { 2173 class T2 extends Base {
2174 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_FIE LD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/set f( 2174 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_FIE LD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/set f(
2175 /*warning:INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE*/B b) => null; 2175 /*error:INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE*/B b) => null;
2176 } 2176 }
2177 2177
2178 class T3 extends Base { 2178 class T3 extends Base {
2179 /*error:INVALID_FIELD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/final B 2179 /*error:INVALID_FIELD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/final B
2180 /*warning:FINAL_NOT_INITIALIZED, warning:INVALID_GETTER_OVERRIDE_RETURN_TY PE*/f; 2180 /*warning:FINAL_NOT_INITIALIZED, error:INVALID_GETTER_OVERRIDE_RETURN_TYPE */f;
2181 } 2181 }
2182 class T4 extends Base { 2182 class T4 extends Base {
2183 // two: one for the getter one for the setter. 2183 // two: one for the getter one for the setter.
2184 /*error:INVALID_FIELD_OVERRIDE, error:INVALID_METHOD_OVERRIDE, error:INVALID_M ETHOD_OVERRIDE*/B 2184 /*error:INVALID_FIELD_OVERRIDE, error:INVALID_METHOD_OVERRIDE, error:INVALID_M ETHOD_OVERRIDE*/B
2185 /*warning:INVALID_GETTER_OVERRIDE_RETURN_TYPE, warning:INVALID_SETTER_OVER RIDE_NORMAL_PARAM_TYPE*/f; 2185 /*error:INVALID_GETTER_OVERRIDE_RETURN_TYPE, error:INVALID_SETTER_OVERRIDE _NORMAL_PARAM_TYPE*/f;
2186 } 2186 }
2187 2187
2188 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/T5 implements B ase { 2188 class /*error:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/T5 implements Bas e {
2189 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_MET HOD_OVERRIDE*/B get 2189 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_MET HOD_OVERRIDE*/B get
2190 /*warning:INVALID_GETTER_OVERRIDE_RETURN_TYPE*/f => null; 2190 /*error:INVALID_GETTER_OVERRIDE_RETURN_TYPE*/f => null;
2191 } 2191 }
2192 2192
2193 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/T6 implements B ase { 2193 class /*error:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/T6 implements Bas e {
2194 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_MET HOD_OVERRIDE*/set f( 2194 /*warning:MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, error:INVALID_MET HOD_OVERRIDE*/set f(
2195 /*warning:INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE*/B b) => null; 2195 /*error:INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE*/B b) => null;
2196 } 2196 }
2197 2197
2198 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/T7 implements B ase { 2198 class /*error:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/T7 implements Bas e {
2199 /*error:INVALID_METHOD_OVERRIDE*/final B 2199 /*error:INVALID_METHOD_OVERRIDE*/final B
2200 /*warning:INVALID_GETTER_OVERRIDE_RETURN_TYPE*/f = null; 2200 /*error:INVALID_GETTER_OVERRIDE_RETURN_TYPE*/f = null;
2201 } 2201 }
2202 class T8 implements Base { 2202 class T8 implements Base {
2203 // two: one for the getter one for the setter. 2203 // two: one for the getter one for the setter.
2204 /*error:INVALID_METHOD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/B 2204 /*error:INVALID_METHOD_OVERRIDE, error:INVALID_METHOD_OVERRIDE*/B
2205 /*warning:INVALID_GETTER_OVERRIDE_RETURN_TYPE, warning:INVALID_SETTER_OVER RIDE_NORMAL_PARAM_TYPE*/f; 2205 /*error:INVALID_GETTER_OVERRIDE_RETURN_TYPE, error:INVALID_SETTER_OVERRIDE _NORMAL_PARAM_TYPE*/f;
2206 } 2206 }
2207 '''); 2207 ''');
2208 } 2208 }
2209 2209
2210 void test_invalidOverrides_childOverride2() { 2210 void test_invalidOverrides_childOverride2() {
2211 checkFile(''' 2211 checkFile('''
2212 class A {} 2212 class A {}
2213 class B {} 2213 class B {}
2214 2214
2215 class Base { 2215 class Base {
2216 m(A a) {} 2216 m(A a) {}
2217 } 2217 }
2218 2218
2219 class Test extends Base { 2219 class Test extends Base {
2220 /*error:INVALID_METHOD_OVERRIDE*/m( 2220 /*error:INVALID_METHOD_OVERRIDE*/m(
2221 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2221 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2222 } 2222 }
2223 '''); 2223 ''');
2224 } 2224 }
2225 2225
2226 void test_invalidOverrides_classOverrideOfInterface() { 2226 void test_invalidOverrides_classOverrideOfInterface() {
2227 checkFile(''' 2227 checkFile('''
2228 class A {} 2228 class A {}
2229 class B {} 2229 class B {}
2230 2230
2231 abstract class I { 2231 abstract class I {
2232 m(A a); 2232 m(A a);
2233 } 2233 }
2234 2234
2235 class T1 implements I { 2235 class T1 implements I {
2236 /*error:INVALID_METHOD_OVERRIDE*/m( 2236 /*error:INVALID_METHOD_OVERRIDE*/m(
2237 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2237 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2238 } 2238 }
2239 '''); 2239 ''');
2240 } 2240 }
2241 2241
2242 void test_invalidOverrides_doubleOverride() { 2242 void test_invalidOverrides_doubleOverride() {
2243 checkFile(''' 2243 checkFile('''
2244 class A {} 2244 class A {}
2245 class B {} 2245 class B {}
2246 2246
2247 class Grandparent { 2247 class Grandparent {
2248 m(A a) {} 2248 m(A a) {}
2249 } 2249 }
2250 class Parent extends Grandparent { 2250 class Parent extends Grandparent {
2251 m(A a) {} 2251 m(A a) {}
2252 } 2252 }
2253 2253
2254 class Test extends Parent { 2254 class Test extends Parent {
2255 // Reported only once 2255 // Reported only once
2256 /*error:INVALID_METHOD_OVERRIDE*/m( 2256 /*error:INVALID_METHOD_OVERRIDE*/m(
2257 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2257 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2258 } 2258 }
2259 '''); 2259 ''');
2260 } 2260 }
2261 2261
2262 void test_invalidOverrides_doubleOverride2() { 2262 void test_invalidOverrides_doubleOverride2() {
2263 checkFile(''' 2263 checkFile('''
2264 class A {} 2264 class A {}
2265 class B {} 2265 class B {}
2266 2266
2267 class Grandparent { 2267 class Grandparent {
2268 m(A a) {} 2268 m(A a) {}
2269 } 2269 }
2270 class Parent extends Grandparent { 2270 class Parent extends Grandparent {
2271 /*error:INVALID_METHOD_OVERRIDE*/m( 2271 /*error:INVALID_METHOD_OVERRIDE*/m(
2272 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2272 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2273 } 2273 }
2274 2274
2275 class Test extends Parent { 2275 class Test extends Parent {
2276 m(B a) {} 2276 m(B a) {}
2277 } 2277 }
2278 '''); 2278 ''');
2279 } 2279 }
2280 2280
2281 void test_invalidOverrides_grandChildOverride() { 2281 void test_invalidOverrides_grandChildOverride() {
2282 checkFile(''' 2282 checkFile('''
2283 class A {} 2283 class A {}
2284 class B {} 2284 class B {}
2285 2285
2286 class Grandparent { 2286 class Grandparent {
2287 m(A a) {} 2287 m(A a) {}
2288 int x; 2288 int x;
2289 } 2289 }
2290 class Parent extends Grandparent { 2290 class Parent extends Grandparent {
2291 } 2291 }
2292 2292
2293 class Test extends Parent { 2293 class Test extends Parent {
2294 /*error:INVALID_METHOD_OVERRIDE*/m( 2294 /*error:INVALID_METHOD_OVERRIDE*/m(
2295 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2295 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2296 /*error:INVALID_FIELD_OVERRIDE*/int x; 2296 /*error:INVALID_FIELD_OVERRIDE*/int x;
2297 } 2297 }
2298 '''); 2298 ''');
2299 } 2299 }
2300 2300
2301 void test_invalidOverrides_mixinOverrideOfInterface() { 2301 void test_invalidOverrides_mixinOverrideOfInterface() {
2302 checkFile(''' 2302 checkFile('''
2303 class A {} 2303 class A {}
2304 class B {} 2304 class B {}
2305 2305
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 2616
2617 void test_mixinOverrideOfGrandInterface_interfaceOfConcreteSuperclass() { 2617 void test_mixinOverrideOfGrandInterface_interfaceOfConcreteSuperclass() {
2618 checkFile(''' 2618 checkFile('''
2619 class A {} 2619 class A {}
2620 class B {} 2620 class B {}
2621 2621
2622 abstract class I1 { 2622 abstract class I1 {
2623 m(A a); 2623 m(A a);
2624 } 2624 }
2625 2625
2626 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/Base 2626 class /*error:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/Base
2627 implements I1 {} 2627 implements I1 {}
2628 2628
2629 class M { 2629 class M {
2630 m(B a) {} 2630 m(B a) {}
2631 } 2631 }
2632 2632
2633 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base 2633 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base
2634 with M {} 2634 with M {}
2635 '''); 2635 ''');
2636 } 2636 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 } 2791 }
2792 2792
2793 class Base { 2793 class Base {
2794 m(B a) {} 2794 m(B a) {}
2795 } 2795 }
2796 2796
2797 // Note: no error reported in `extends Base` to avoid duplicating 2797 // Note: no error reported in `extends Base` to avoid duplicating
2798 // the error in T1. 2798 // the error in T1.
2799 class T1 extends Base implements I1 { 2799 class T1 extends Base implements I1 {
2800 /*error:INVALID_METHOD_OVERRIDE*/m( 2800 /*error:INVALID_METHOD_OVERRIDE*/m(
2801 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2801 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2802 } 2802 }
2803 2803
2804 // If there is no error in the class, we do report the error at 2804 // If there is no error in the class, we do report the error at
2805 // the base class: 2805 // the base class:
2806 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T2 2806 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T2
2807 /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base 2807 /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base
2808 implements I1 {} 2808 implements I1 {}
2809 '''); 2809 ''');
2810 } 2810 }
2811 2811
2812 void 2812 void
2813 test_noDuplicateReportsFromOverridingInterfaces_typeAndMixinOverrideSameMe thodInInterface() { 2813 test_noDuplicateReportsFromOverridingInterfaces_typeAndMixinOverrideSameMe thodInInterface() {
2814 checkFile(''' 2814 checkFile('''
2815 class A {} 2815 class A {}
2816 class B {} 2816 class B {}
2817 2817
2818 abstract class I1 { 2818 abstract class I1 {
2819 m(A a); 2819 m(A a);
2820 } 2820 }
2821 2821
2822 class M { 2822 class M {
2823 m(B a) {} 2823 m(B a) {}
2824 } 2824 }
2825 2825
2826 class T1 extends Object with M implements I1 { 2826 class T1 extends Object with M implements I1 {
2827 /*error:INVALID_METHOD_OVERRIDE*/m( 2827 /*error:INVALID_METHOD_OVERRIDE*/m(
2828 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2828 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2829 } 2829 }
2830 2830
2831 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T2 2831 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T2
2832 extends Object with /*error:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M 2832 extends Object with /*error:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M
2833 implements I1 {} 2833 implements I1 {}
2834 '''); 2834 ''');
2835 } 2835 }
2836 2836
2837 void 2837 void
2838 test_noDuplicateReportsFromOverridingInterfaces_typeOverridesSomeMethodInM ultipleInterfaces() { 2838 test_noDuplicateReportsFromOverridingInterfaces_typeOverridesSomeMethodInM ultipleInterfaces() {
2839 checkFile(''' 2839 checkFile('''
2840 class A {} 2840 class A {}
2841 class B {} 2841 class B {}
2842 2842
2843 abstract class I1 { 2843 abstract class I1 {
2844 m(A a); 2844 m(A a);
2845 } 2845 }
2846 abstract class I2 implements I1 { 2846 abstract class I2 implements I1 {
2847 m(A a); 2847 m(A a);
2848 } 2848 }
2849 2849
2850 class Base {} 2850 class Base {}
2851 2851
2852 class T1 implements I2 { 2852 class T1 implements I2 {
2853 /*error:INVALID_METHOD_OVERRIDE*/m( 2853 /*error:INVALID_METHOD_OVERRIDE*/m(
2854 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 2854 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
2855 } 2855 }
2856 '''); 2856 ''');
2857 } 2857 }
2858 2858
2859 void test_nullCoalescingOperator() { 2859 void test_nullCoalescingOperator() {
2860 checkFile(''' 2860 checkFile('''
2861 class A {} 2861 class A {}
2862 class C<T> {} 2862 class C<T> {}
2863 main() { 2863 main() {
2864 A a, b; 2864 A a, b;
(...skipping 21 matching lines...) Expand all
2886 2886
2887 int _m1() => null; 2887 int _m1() => null;
2888 } 2888 }
2889 2889
2890 class GrandChild extends main.Child { 2890 class GrandChild extends main.Child {
2891 /*error:INVALID_FIELD_OVERRIDE*/var _f2; 2891 /*error:INVALID_FIELD_OVERRIDE*/var _f2;
2892 /*error:INVALID_FIELD_OVERRIDE*/var _f3; 2892 /*error:INVALID_FIELD_OVERRIDE*/var _f3;
2893 var _f4; 2893 var _f4;
2894 2894
2895 /*error:INVALID_METHOD_OVERRIDE*/String 2895 /*error:INVALID_METHOD_OVERRIDE*/String
2896 /*warning:INVALID_METHOD_OVERRIDE_RETURN_TYPE*/_m1() => null; 2896 /*error:INVALID_METHOD_OVERRIDE_RETURN_TYPE*/_m1() => null;
2897 } 2897 }
2898 ''', 2898 ''',
2899 name: '/helper.dart'); 2899 name: '/helper.dart');
2900 checkFile(''' 2900 checkFile('''
2901 import 'helper.dart' as helper; 2901 import 'helper.dart' as helper;
2902 2902
2903 class Child extends helper.Base { 2903 class Child extends helper.Base {
2904 /*error:INVALID_FIELD_OVERRIDE*/var f1; 2904 /*error:INVALID_FIELD_OVERRIDE*/var f1;
2905 var _f2; 2905 var _f2;
2906 var _f4; 2906 var _f4;
2907 2907
2908 String _m1() => null; 2908 String _m1() => null;
2909 } 2909 }
2910 '''); 2910 ''');
2911 } 2911 }
2912 2912
2913 void test_redirectingConstructor() { 2913 void test_redirectingConstructor() {
2914 checkFile(''' 2914 checkFile('''
2915 class A { 2915 class A {
2916 A(A x) {} 2916 A(A x) {}
2917 A.two() : this(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 2917 A.two() : this(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
2918 } 2918 }
2919 '''); 2919 ''');
2920 } 2920 }
2921 2921
2922 void test_relaxedCasts() { 2922 void test_relaxedCasts() {
2923 checkFile(''' 2923 checkFile('''
2924 class A {} 2924 class A {}
2925 2925
2926 class L<T> {} 2926 class L<T> {}
2927 class M<T> extends L<T> {} 2927 class M<T> extends L<T> {}
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 checkFile(''' 3107 checkFile('''
3108 class A {} 3108 class A {}
3109 class B {} 3109 class B {}
3110 3110
3111 abstract class I1 { 3111 abstract class I1 {
3112 m(A a); 3112 m(A a);
3113 } 3113 }
3114 3114
3115 abstract class Base implements I1 { 3115 abstract class Base implements I1 {
3116 /*error:INVALID_METHOD_OVERRIDE*/m( 3116 /*error:INVALID_METHOD_OVERRIDE*/m(
3117 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 3117 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
3118 } 3118 }
3119 3119
3120 class T1 extends Base { 3120 class T1 extends Base {
3121 // we consider the base class incomplete because it is 3121 // we consider the base class incomplete because it is
3122 // abstract, so we report the error here too. 3122 // abstract, so we report the error here too.
3123 // TODO(sigmund): consider tracking overrides in a fine-grain 3123 // TODO(sigmund): consider tracking overrides in a fine-grain
3124 // manner, then this and the double-overrides would not be 3124 // manner, then this and the double-overrides would not be
3125 // reported. 3125 // reported.
3126 /*error:INVALID_METHOD_OVERRIDE*/m(B a) {} 3126 /*error:INVALID_METHOD_OVERRIDE*/m(B a) {}
3127 } 3127 }
3128 '''); 3128 ''');
3129 } 3129 }
3130 3130
3131 void test_superclassOverrideOfGrandInterface_interfaceOfConcreteSuperclass() { 3131 void test_superclassOverrideOfGrandInterface_interfaceOfConcreteSuperclass() {
3132 checkFile(''' 3132 checkFile('''
3133 class A {} 3133 class A {}
3134 class B {} 3134 class B {}
3135 3135
3136 abstract class I1 { 3136 abstract class I1 {
3137 m(A a); 3137 m(A a);
3138 } 3138 }
3139 3139
3140 class Base implements I1 { 3140 class Base implements I1 {
3141 /*error:INVALID_METHOD_OVERRIDE*/m( 3141 /*error:INVALID_METHOD_OVERRIDE*/m(
3142 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} 3142 /*error:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {}
3143 } 3143 }
3144 3144
3145 class T1 extends Base { 3145 class T1 extends Base {
3146 m(B a) {} 3146 m(B a) {}
3147 } 3147 }
3148 '''); 3148 ''');
3149 } 3149 }
3150 3150
3151 void test_superclassOverrideOfGrandInterface_interfaceOfInterfaceOfChild() { 3151 void test_superclassOverrideOfGrandInterface_interfaceOfInterfaceOfChild() {
3152 checkFile(''' 3152 checkFile('''
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T1 3204 class /*error:INCONSISTENT_METHOD_INHERITANCE*/T1
3205 /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base 3205 /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base
3206 implements I2 {} 3206 implements I2 {}
3207 '''); 3207 ''');
3208 } 3208 }
3209 3209
3210 void test_superConstructor() { 3210 void test_superConstructor() {
3211 checkFile(''' 3211 checkFile('''
3212 class A { A(A x) {} } 3212 class A { A(A x) {} }
3213 class B extends A { 3213 class B extends A {
3214 B() : super(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 3214 B() : super(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
3215 } 3215 }
3216 '''); 3216 ''');
3217 } 3217 }
3218 3218
3219 void test_ternaryOperator() { 3219 void test_ternaryOperator() {
3220 checkFile(''' 3220 checkFile('''
3221 abstract class Comparable<T> { 3221 abstract class Comparable<T> {
3222 int compareTo(T other); 3222 int compareTo(T other);
3223 static int compare(Comparable a, Comparable b) => a.compareTo(b); 3223 static int compare(Comparable a, Comparable b) => a.compareTo(b);
3224 } 3224 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3265 } 3265 }
3266 3266
3267 void test_typeCheckingLiterals() { 3267 void test_typeCheckingLiterals() {
3268 checkFile(''' 3268 checkFile('''
3269 test() { 3269 test() {
3270 num n = 3; 3270 num n = 3;
3271 int i = 3; 3271 int i = 3;
3272 String s = "hello"; 3272 String s = "hello";
3273 { 3273 {
3274 List<int> l = <int>[i]; 3274 List<int> l = <int>[i];
3275 l = <int>[/*warning:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/s]; 3275 l = <int>[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/s];
3276 l = <int>[/*info:DOWN_CAST_IMPLICIT*/n]; 3276 l = <int>[/*info:DOWN_CAST_IMPLICIT*/n];
3277 l = <int>[i, /*info:DOWN_CAST_IMPLICIT*/n, /*warning:LIST_ELEMENT_TYPE_NOT_ ASSIGNABLE*/s]; 3277 l = <int>[i, /*info:DOWN_CAST_IMPLICIT*/n, /*error:LIST_ELEMENT_TYPE_NOT_AS SIGNABLE*/s];
3278 } 3278 }
3279 { 3279 {
3280 List l = /*info:INFERRED_TYPE_LITERAL*/[i]; 3280 List l = /*info:INFERRED_TYPE_LITERAL*/[i];
3281 l = /*info:INFERRED_TYPE_LITERAL*/[s]; 3281 l = /*info:INFERRED_TYPE_LITERAL*/[s];
3282 l = /*info:INFERRED_TYPE_LITERAL*/[n]; 3282 l = /*info:INFERRED_TYPE_LITERAL*/[n];
3283 l = /*info:INFERRED_TYPE_LITERAL*/[i, n, s]; 3283 l = /*info:INFERRED_TYPE_LITERAL*/[i, n, s];
3284 } 3284 }
3285 { 3285 {
3286 Map<String, int> m = <String, int>{s: i}; 3286 Map<String, int> m = <String, int>{s: i};
3287 m = <String, int>{s: /*warning:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s}; 3287 m = <String, int>{s: /*error:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s};
3288 m = <String, int>{s: /*info:DOWN_CAST_IMPLICIT*/n}; 3288 m = <String, int>{s: /*info:DOWN_CAST_IMPLICIT*/n};
3289 m = <String, int>{s: i, 3289 m = <String, int>{s: i,
3290 s: /*info:DOWN_CAST_IMPLICIT*/n, 3290 s: /*info:DOWN_CAST_IMPLICIT*/n,
3291 s: /*warning:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s}; 3291 s: /*error:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s};
3292 } 3292 }
3293 // TODO(leafp): We can't currently test for key errors since the 3293 // TODO(leafp): We can't currently test for key errors since the
3294 // error marker binds to the entire entry. 3294 // error marker binds to the entire entry.
3295 { 3295 {
3296 Map m = /*info:INFERRED_TYPE_LITERAL*/{s: i}; 3296 Map m = /*info:INFERRED_TYPE_LITERAL*/{s: i};
3297 m = /*info:INFERRED_TYPE_LITERAL*/{s: s}; 3297 m = /*info:INFERRED_TYPE_LITERAL*/{s: s};
3298 m = /*info:INFERRED_TYPE_LITERAL*/{s: n}; 3298 m = /*info:INFERRED_TYPE_LITERAL*/{s: n};
3299 m = /*info:INFERRED_TYPE_LITERAL*/ 3299 m = /*info:INFERRED_TYPE_LITERAL*/
3300 {s: i, 3300 {s: i,
3301 s: n, 3301 s: n,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 checkFile(''' 3507 checkFile('''
3508 class Foo { 3508 class Foo {
3509 Foo() : /*error:REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR*/this.init(); 3509 Foo() : /*error:REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR*/this.init();
3510 } 3510 }
3511 '''); 3511 ''');
3512 } 3512 }
3513 3513
3514 void test_unboundTypeName() { 3514 void test_unboundTypeName() {
3515 checkFile(''' 3515 checkFile('''
3516 void main() { 3516 void main() {
3517 /*warning:UNDEFINED_CLASS should be error*/AToB y; 3517 /*error:UNDEFINED_CLASS*/AToB y;
3518 } 3518 }
3519 '''); 3519 ''');
3520 } 3520 }
3521 3521
3522 void test_unboundVariable() { 3522 void test_unboundVariable() {
3523 checkFile(''' 3523 checkFile('''
3524 void main() { 3524 void main() {
3525 dynamic y = /*warning:UNDEFINED_IDENTIFIER should be error*/unboundVariable; 3525 dynamic y = /*error:UNDEFINED_IDENTIFIER*/unboundVariable;
3526 } 3526 }
3527 '''); 3527 ''');
3528 } 3528 }
3529 3529
3530 void test_voidSubtyping() { 3530 void test_voidSubtyping() {
3531 // Regression test for https://github.com/dart-lang/sdk/issues/25069 3531 // Regression test for https://github.com/dart-lang/sdk/issues/25069
3532 checkFile(''' 3532 checkFile('''
3533 typedef int Foo(); 3533 typedef int Foo();
3534 void foo() {} 3534 void foo() {}
3535 void main () { 3535 void main () {
3536 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); 3536 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo();
3537 } 3537 }
3538 '''); 3538 ''');
3539 } 3539 }
3540 } 3540 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698