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

Side by Side Diff: tests/compiler/dart2js/override_inheritance_test.dart

Issue 2990223002: Reformat untouched files. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'package:async_helper/async_helper.dart'; 6 import 'package:async_helper/async_helper.dart';
7 import 'compiler_helper.dart'; 7 import 'compiler_helper.dart';
8 import 'package:compiler/src/resolution/class_members.dart' show MembersCreator; 8 import 'package:compiler/src/resolution/class_members.dart' show MembersCreator;
9 9
10 main() { 10 main() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 """), 72 """),
73 check(""" 73 check("""
74 class A { 74 class A {
75 method(a, b, c, d) => null; // testRequiredParameters:3 75 method(a, b, c, d) => null; // testRequiredParameters:3
76 } 76 }
77 class Class extends A { 77 class Class extends A {
78 method(b, a, d, c) => null; // testRequiredParameters:4 78 method(b, a, d, c) => null; // testRequiredParameters:4
79 } 79 }
80 """), 80 """),
81 check( 81 check("""
82 """
83 class A { 82 class A {
84 method() => null; // testRequiredParameters:5 83 method() => null; // testRequiredParameters:5
85 } 84 }
86 class Class extends A { 85 class Class extends A {
87 method(a) => null; // testRequiredParameters:6 86 method(a) => null; // testRequiredParameters:6
88 } 87 }
89 """, 88 """,
90 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 89 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
91 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 90 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
92 check( 91 check("""
93 """
94 class A { 92 class A {
95 method() => null; // testRequiredParameters:7 93 method() => null; // testRequiredParameters:7
96 } 94 }
97 class Class implements A { 95 class Class implements A {
98 method(a) => null; // testRequiredParameters:8 96 method(a) => null; // testRequiredParameters:8
99 } 97 }
100 """, 98 """,
101 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 99 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
102 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 100 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
103 check( 101 check("""
104 """
105 class A { 102 class A {
106 method(a, b, c) => null; // testRequiredParameters:9 103 method(a, b, c) => null; // testRequiredParameters:9
107 } 104 }
108 class Class extends A { 105 class Class extends A {
109 method(a, b, c, d) => null; // testRequiredParameters:10 106 method(a, b, c, d) => null; // testRequiredParameters:10
110 } 107 }
111 """, 108 """,
112 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 109 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
113 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 110 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
114 ]); 111 ]);
(...skipping 26 matching lines...) Expand all
141 } 138 }
142 """), 139 """),
143 check(""" 140 check("""
144 class A { 141 class A {
145 method([a]) => null; // testPositionalParameters:7 142 method([a]) => null; // testPositionalParameters:7
146 } 143 }
147 class Class extends A { 144 class Class extends A {
148 method([a]) => null; // testPositionalParameters:8 145 method([a]) => null; // testPositionalParameters:8
149 } 146 }
150 """), 147 """),
151 check( 148 check("""
152 """
153 class A { 149 class A {
154 method(a) => null; // testPositionalParameters:9 150 method(a) => null; // testPositionalParameters:9
155 } 151 }
156 class Class extends A { 152 class Class extends A {
157 method() => null; // testPositionalParameters:10 153 method() => null; // testPositionalParameters:10
158 } 154 }
159 """, 155 """,
160 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 156 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
161 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 157 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
162 check( 158 check("""
163 """
164 class A { 159 class A {
165 method(a, [b]) => null; // testPositionalParameters:11 160 method(a, [b]) => null; // testPositionalParameters:11
166 } 161 }
167 class Class extends A { 162 class Class extends A {
168 method(a) => null; // testPositionalParameters:12 163 method(a) => null; // testPositionalParameters:12
169 } 164 }
170 """, 165 """,
171 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 166 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
172 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 167 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
173 check( 168 check("""
174 """
175 class A { 169 class A {
176 method(a, [b]) => null; // testPositionalParameters:13 170 method(a, [b]) => null; // testPositionalParameters:13
177 } 171 }
178 class Class extends A { 172 class Class extends A {
179 method([a]) => null; // testPositionalParameters:14 173 method([a]) => null; // testPositionalParameters:14
180 } 174 }
181 """, 175 """,
182 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 176 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
183 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 177 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
184 check( 178 check("""
185 """
186 class A { 179 class A {
187 method(a, b, [c, d, e]) => null; // testPositionalParameters:15 180 method(a, b, [c, d, e]) => null; // testPositionalParameters:15
188 } 181 }
189 class Class extends A { 182 class Class extends A {
190 method([a, b, c, d]) => null; // testPositionalParameters:16 183 method([a, b, c, d]) => null; // testPositionalParameters:16
191 } 184 }
192 """, 185 """,
193 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 186 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
194 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 187 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
195 ]); 188 ]);
(...skipping 26 matching lines...) Expand all
222 } 215 }
223 """), 216 """),
224 check(""" 217 check("""
225 class A { 218 class A {
226 method(d, {a, b, c}) => null; // testNamedParameters:7 219 method(d, {a, b, c}) => null; // testNamedParameters:7
227 } 220 }
228 class Class extends A { 221 class Class extends A {
229 method(e, {b, c, a, d}) => null; // testNamedParameters:8 222 method(e, {b, c, a, d}) => null; // testNamedParameters:8
230 } 223 }
231 """), 224 """),
232 check( 225 check("""
233 """
234 class A { 226 class A {
235 method({a}) => null; // testNamedParameters:9 227 method({a}) => null; // testNamedParameters:9
236 } 228 }
237 class Class extends A { 229 class Class extends A {
238 method() => null; // testNamedParameters:10 230 method() => null; // testNamedParameters:10
239 } 231 }
240 """, 232 """,
241 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 233 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
242 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 234 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
243 check( 235 check("""
244 """
245 class A { 236 class A {
246 method({a, b}) => null; // testNamedParameters:11 237 method({a, b}) => null; // testNamedParameters:11
247 } 238 }
248 class Class extends A { 239 class Class extends A {
249 method({b}) => null; // testNamedParameters:12 240 method({b}) => null; // testNamedParameters:12
250 } 241 }
251 """, 242 """,
252 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 243 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
253 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 244 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
254 check( 245 check("""
255 """
256 class A { 246 class A {
257 method({a, b, c, d}) => null; // testNamedParameters:13 247 method({a, b, c, d}) => null; // testNamedParameters:13
258 } 248 }
259 class Class extends A { 249 class Class extends A {
260 method({a, e, d, c}) => null; // testNamedParameters:14 250 method({a, e, d, c}) => null; // testNamedParameters:14
261 } 251 }
262 """, 252 """,
263 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 253 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
264 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 254 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
265 ]); 255 ]);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 295
306 check(""" 296 check("""
307 class A { 297 class A {
308 void method() {} // testNotSubtype:9 298 void method() {} // testNotSubtype:9
309 } 299 }
310 class Class extends A { 300 class Class extends A {
311 int method() => null; // testNotSubtype:10 301 int method() => null; // testNotSubtype:10
312 } 302 }
313 """), 303 """),
314 304
315 check( 305 check("""
316 """
317 class A { 306 class A {
318 int method() => null; // testNotSubtype:11 307 int method() => null; // testNotSubtype:11
319 } 308 }
320 class Class extends A { 309 class Class extends A {
321 void method() {} // testNotSubtype:12 310 void method() {} // testNotSubtype:12
322 } 311 }
323 """, 312 """,
324 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 313 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
325 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 314 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
326 315
(...skipping 14 matching lines...) Expand all
341 method(int a) => null; // testNotSubtype:16 330 method(int a) => null; // testNotSubtype:16
342 } 331 }
343 class B extends A { 332 class B extends A {
344 method(a) => null; // testNotSubtype:17 333 method(a) => null; // testNotSubtype:17
345 } 334 }
346 class Class extends B { 335 class Class extends B {
347 method(String a) => null; // testNotSubtype:18 336 method(String a) => null; // testNotSubtype:18
348 } 337 }
349 """), 338 """),
350 339
351 check( 340 check("""
352 """
353 class A { 341 class A {
354 method(int a) => null; // testNotSubtype:19 342 method(int a) => null; // testNotSubtype:19
355 } 343 }
356 class Class extends A { 344 class Class extends A {
357 method(String a) => null; // testNotSubtype:20 345 method(String a) => null; // testNotSubtype:20
358 } 346 }
359 """, 347 """,
360 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 348 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
361 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 349 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
362 350
363 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed. 351 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
364 check( 352 check("""
365 """
366 class A { 353 class A {
367 method(int a) => null; // testNotSubtype:23 354 method(int a) => null; // testNotSubtype:23
368 } 355 }
369 class B { 356 class B {
370 method(num a) => null; // testNotSubtype:24 357 method(num a) => null; // testNotSubtype:24
371 } 358 }
372 abstract class C implements A, B { 359 abstract class C implements A, B {
373 } 360 }
374 class Class implements C { 361 class Class implements C {
375 method(double a) => null; // testNotSubtype:25 362 method(double a) => null; // testNotSubtype:25
376 } 363 }
377 """, 364 """,
378 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 365 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
379 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 366 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
380 367
381 check( 368 check("""
382 """
383 class A { 369 class A {
384 method(num a) => null; // testNotSubtype:29 370 method(num a) => null; // testNotSubtype:29
385 } 371 }
386 class B { 372 class B {
387 method(int a) => null; // testNotSubtype:30 373 method(int a) => null; // testNotSubtype:30
388 } 374 }
389 abstract class C implements A, B { 375 abstract class C implements A, B {
390 } 376 }
391 class Class implements C { 377 class Class implements C {
392 method(double a) => null; // testNotSubtype:31 378 method(double a) => null; // testNotSubtype:31
393 } 379 }
394 """, 380 """,
395 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 381 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
396 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 382 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
397 383
398 check( 384 check("""
399 """
400 class A { 385 class A {
401 method(int a) => null; // testNotSubtype:26 386 method(int a) => null; // testNotSubtype:26
402 } 387 }
403 class B { 388 class B {
404 method(num a) => null; // testNotSubtype:27 389 method(num a) => null; // testNotSubtype:27
405 } 390 }
406 abstract class C implements A, B { 391 abstract class C implements A, B {
407 } 392 }
408 class Class implements C { 393 class Class implements C {
409 method(String a) => null; // testNotSubtype:28 394 method(String a) => null; // testNotSubtype:28
410 } 395 }
411 """, 396 """, warnings: [
412 warnings: [ 397 MessageKind.INVALID_OVERRIDE_METHOD,
413 MessageKind.INVALID_OVERRIDE_METHOD, 398 MessageKind.INVALID_OVERRIDE_METHOD
414 MessageKind.INVALID_OVERRIDE_METHOD 399 ], infos: [
415 ], 400 MessageKind.INVALID_OVERRIDDEN_METHOD,
416 infos: [ 401 MessageKind.INVALID_OVERRIDDEN_METHOD
417 MessageKind.INVALID_OVERRIDDEN_METHOD, 402 ]),
418 MessageKind.INVALID_OVERRIDDEN_METHOD
419 ]),
420 ]); 403 ]);
421 } 404 }
422 405
423 Future testGetterNotSubtype() { 406 Future testGetterNotSubtype() {
424 return Future.wait([ 407 return Future.wait([
425 check(""" 408 check("""
426 class A { 409 class A {
427 get getter => null; // testGetterNotSubtype:1 410 get getter => null; // testGetterNotSubtype:1
428 } 411 }
429 class Class extends A { 412 class Class extends A {
(...skipping 21 matching lines...) Expand all
451 434
452 check(""" 435 check("""
453 class A { 436 class A {
454 int get getter => null; // testGetterNotSubtype:7 437 int get getter => null; // testGetterNotSubtype:7
455 } 438 }
456 class Class extends A { 439 class Class extends A {
457 num get getter => null; // testGetterNotSubtype:8 440 num get getter => null; // testGetterNotSubtype:8
458 } 441 }
459 """), 442 """),
460 443
461 check( 444 check("""
462 """
463 class A { 445 class A {
464 int get getter => null; // testGetterNotSubtype:9 446 int get getter => null; // testGetterNotSubtype:9
465 } 447 }
466 class Class extends A { 448 class Class extends A {
467 double get getter => null; // testGetterNotSubtype:10 449 double get getter => null; // testGetterNotSubtype:10
468 } 450 }
469 """, 451 """,
470 warnings: MessageKind.INVALID_OVERRIDE_GETTER, 452 warnings: MessageKind.INVALID_OVERRIDE_GETTER,
471 infos: MessageKind.INVALID_OVERRIDDEN_GETTER), 453 infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
472 454
473 check(""" 455 check("""
474 class A { 456 class A {
475 int get getter => null; // testGetterNotSubtype:11 457 int get getter => null; // testGetterNotSubtype:11
476 } 458 }
477 class B extends A { 459 class B extends A {
478 num get getter => null; // testGetterNotSubtype:12 460 num get getter => null; // testGetterNotSubtype:12
479 } 461 }
480 class Class extends B { 462 class Class extends B {
481 double get getter => null; // testGetterNotSubtype:13 463 double get getter => null; // testGetterNotSubtype:13
482 } 464 }
483 """), 465 """),
484 466
485 check( 467 check("""
486 """
487 class A { 468 class A {
488 int get getter => null; // testGetterNotSubtype:14 469 int get getter => null; // testGetterNotSubtype:14
489 } 470 }
490 class B { 471 class B {
491 num get getter => null; // testGetterNotSubtype:15 472 num get getter => null; // testGetterNotSubtype:15
492 } 473 }
493 class Class extends A implements B { 474 class Class extends A implements B {
494 double get getter => null; // testGetterNotSubtype:16 475 double get getter => null; // testGetterNotSubtype:16
495 } 476 }
496 """, 477 """,
497 warnings: MessageKind.INVALID_OVERRIDE_GETTER, 478 warnings: MessageKind.INVALID_OVERRIDE_GETTER,
498 infos: MessageKind.INVALID_OVERRIDDEN_GETTER), 479 infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
499 480
500 check( 481 check("""
501 """
502 class A { 482 class A {
503 int get getter => null; // testGetterNotSubtype:17 483 int get getter => null; // testGetterNotSubtype:17
504 } 484 }
505 class B { 485 class B {
506 String get getter => null; // testGetterNotSubtype:18 486 String get getter => null; // testGetterNotSubtype:18
507 } 487 }
508 class Class extends A implements B { 488 class Class extends A implements B {
509 double get getter => null; // testGetterNotSubtype:19 489 double get getter => null; // testGetterNotSubtype:19
510 } 490 }
511 """, 491 """, warnings: [
512 warnings: [ 492 MessageKind.INVALID_OVERRIDE_GETTER,
513 MessageKind.INVALID_OVERRIDE_GETTER, 493 MessageKind.INVALID_OVERRIDE_GETTER
514 MessageKind.INVALID_OVERRIDE_GETTER 494 ], infos: [
515 ], 495 MessageKind.INVALID_OVERRIDDEN_GETTER,
516 infos: [ 496 MessageKind.INVALID_OVERRIDDEN_GETTER
517 MessageKind.INVALID_OVERRIDDEN_GETTER, 497 ]),
518 MessageKind.INVALID_OVERRIDDEN_GETTER
519 ]),
520 498
521 check( 499 check("""
522 """
523 class A { 500 class A {
524 int get getter => null; // testGetterNotSubtype:20 501 int get getter => null; // testGetterNotSubtype:20
525 } 502 }
526 class B { 503 class B {
527 String get getter => null; // testGetterNotSubtype:21 504 String get getter => null; // testGetterNotSubtype:21
528 } 505 }
529 class Class implements A, B { 506 class Class implements A, B {
530 double get getter => null; // testGetterNotSubtype:22 507 double get getter => null; // testGetterNotSubtype:22
531 } 508 }
532 """, 509 """, warnings: [
533 warnings: [ 510 MessageKind.INVALID_OVERRIDE_GETTER,
534 MessageKind.INVALID_OVERRIDE_GETTER, 511 MessageKind.INVALID_OVERRIDE_GETTER
535 MessageKind.INVALID_OVERRIDE_GETTER 512 ], infos: [
536 ], 513 MessageKind.INVALID_OVERRIDDEN_GETTER,
537 infos: [ 514 MessageKind.INVALID_OVERRIDDEN_GETTER
538 MessageKind.INVALID_OVERRIDDEN_GETTER, 515 ]),
539 MessageKind.INVALID_OVERRIDDEN_GETTER
540 ]),
541 516
542 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed. 517 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
543 check( 518 check("""
544 """
545 class A { 519 class A {
546 int get getter => null; // testGetterNotSubtype:23 520 int get getter => null; // testGetterNotSubtype:23
547 } 521 }
548 class B { 522 class B {
549 num get getter => null; // testGetterNotSubtype:24 523 num get getter => null; // testGetterNotSubtype:24
550 } 524 }
551 abstract class C implements A, B { 525 abstract class C implements A, B {
552 } 526 }
553 class Class implements C { 527 class Class implements C {
554 double get getter => null; // testGetterNotSubtype:25 528 double get getter => null; // testGetterNotSubtype:25
555 } 529 }
556 """, 530 """,
557 warnings: MessageKind.INVALID_OVERRIDE_GETTER, 531 warnings: MessageKind.INVALID_OVERRIDE_GETTER,
558 infos: MessageKind.INVALID_OVERRIDDEN_GETTER), 532 infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
559 533
560 check( 534 check("""
561 """
562 class A { 535 class A {
563 int get getter => null; // testGetterNotSubtype:26 536 int get getter => null; // testGetterNotSubtype:26
564 } 537 }
565 class B { 538 class B {
566 num get getter => null; // testGetterNotSubtype:27 539 num get getter => null; // testGetterNotSubtype:27
567 } 540 }
568 abstract class C implements A, B { 541 abstract class C implements A, B {
569 } 542 }
570 class Class implements C { 543 class Class implements C {
571 String get getter => null; // testGetterNotSubtype:28 544 String get getter => null; // testGetterNotSubtype:28
572 } 545 }
573 """, 546 """, warnings: [
574 warnings: [ 547 MessageKind.INVALID_OVERRIDE_GETTER,
575 MessageKind.INVALID_OVERRIDE_GETTER, 548 MessageKind.INVALID_OVERRIDE_GETTER
576 MessageKind.INVALID_OVERRIDE_GETTER 549 ], infos: [
577 ], 550 MessageKind.INVALID_OVERRIDDEN_GETTER,
578 infos: [ 551 MessageKind.INVALID_OVERRIDDEN_GETTER
579 MessageKind.INVALID_OVERRIDDEN_GETTER, 552 ]),
580 MessageKind.INVALID_OVERRIDDEN_GETTER
581 ]),
582 ]); 553 ]);
583 } 554 }
584 555
585 Future testGenericNotSubtype() { 556 Future testGenericNotSubtype() {
586 return Future.wait([ 557 return Future.wait([
587 check(""" 558 check("""
588 class A<T> { 559 class A<T> {
589 method(T t) => null; // testGenericNotSubtype:1 560 method(T t) => null; // testGenericNotSubtype:1
590 } 561 }
591 class Class<S> extends A<S> { 562 class Class<S> extends A<S> {
(...skipping 15 matching lines...) Expand all
607 method(T t) => null; // testGenericNotSubtype:5 578 method(T t) => null; // testGenericNotSubtype:5
608 } 579 }
609 class B<S> { 580 class B<S> {
610 method(S s) => null; // testGenericNotSubtype:6 581 method(S s) => null; // testGenericNotSubtype:6
611 } 582 }
612 class Class extends A<double> implements B<int> { 583 class Class extends A<double> implements B<int> {
613 method(num i) => null; // testGenericNotSubtype:7 584 method(num i) => null; // testGenericNotSubtype:7
614 } 585 }
615 """), 586 """),
616 587
617 check( 588 check("""
618 """
619 class A<T> { 589 class A<T> {
620 method(T t) => null; // testGenericNotSubtype:8 590 method(T t) => null; // testGenericNotSubtype:8
621 } 591 }
622 class Class<S> extends A<S> { 592 class Class<S> extends A<S> {
623 method(int i) => null; // testGenericNotSubtype:9 593 method(int i) => null; // testGenericNotSubtype:9
624 } 594 }
625 """, 595 """,
626 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 596 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
627 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 597 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
628 598
629 check(""" 599 check("""
630 class A<T> { 600 class A<T> {
631 method(T t) => null; // testGenericNotSubtype:10 601 method(T t) => null; // testGenericNotSubtype:10
632 } 602 }
633 class B<S> extends A<S> { 603 class B<S> extends A<S> {
634 604
635 } 605 }
636 class Class<U> extends B<U> { 606 class Class<U> extends B<U> {
637 method(U u) => null; // testGenericNotSubtype:11 607 method(U u) => null; // testGenericNotSubtype:11
638 } 608 }
639 """), 609 """),
640 610
641 check( 611 check("""
642 """
643 class A<T> { 612 class A<T> {
644 method(T t) => null; // testGenericNotSubtype:12 613 method(T t) => null; // testGenericNotSubtype:12
645 } 614 }
646 class B<S> { 615 class B<S> {
647 method(S s) => null; // testGenericNotSubtype:13 616 method(S s) => null; // testGenericNotSubtype:13
648 } 617 }
649 class Class<U> extends A<U> implements B<num> { 618 class Class<U> extends A<U> implements B<num> {
650 method(int i) => null; // testGenericNotSubtype:14 619 method(int i) => null; // testGenericNotSubtype:14
651 } 620 }
652 """, 621 """,
653 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 622 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
654 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 623 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
655 624
656 check( 625 check("""
657 """
658 class A<T> { 626 class A<T> {
659 method(T t) => null; // testGenericNotSubtype:15 627 method(T t) => null; // testGenericNotSubtype:15
660 } 628 }
661 class B<S> { 629 class B<S> {
662 method(S s) => null; // testGenericNotSubtype:16 630 method(S s) => null; // testGenericNotSubtype:16
663 } 631 }
664 class Class extends A<int> implements B<String> { 632 class Class extends A<int> implements B<String> {
665 method(double d) => null; // testGenericNotSubtype:17 633 method(double d) => null; // testGenericNotSubtype:17
666 } 634 }
667 """, 635 """, warnings: [
668 warnings: [ 636 MessageKind.INVALID_OVERRIDE_METHOD,
669 MessageKind.INVALID_OVERRIDE_METHOD, 637 MessageKind.INVALID_OVERRIDE_METHOD
670 MessageKind.INVALID_OVERRIDE_METHOD 638 ], infos: [
671 ], 639 MessageKind.INVALID_OVERRIDDEN_METHOD,
672 infos: [ 640 MessageKind.INVALID_OVERRIDDEN_METHOD
673 MessageKind.INVALID_OVERRIDDEN_METHOD, 641 ]),
674 MessageKind.INVALID_OVERRIDDEN_METHOD
675 ]),
676 642
677 check( 643 check("""
678 """
679 class A<T> { 644 class A<T> {
680 method(T t) => null; // testGenericNotSubtype:18 645 method(T t) => null; // testGenericNotSubtype:18
681 } 646 }
682 class B<S> { 647 class B<S> {
683 method(S s) => null; // testGenericNotSubtype:19 648 method(S s) => null; // testGenericNotSubtype:19
684 } 649 }
685 class Class implements A<int>, B<String> { 650 class Class implements A<int>, B<String> {
686 method(double d) => null; // testGenericNotSubtype:20 651 method(double d) => null; // testGenericNotSubtype:20
687 } 652 }
688 """, 653 """, warnings: [
689 warnings: [ 654 MessageKind.INVALID_OVERRIDE_METHOD,
690 MessageKind.INVALID_OVERRIDE_METHOD, 655 MessageKind.INVALID_OVERRIDE_METHOD
691 MessageKind.INVALID_OVERRIDE_METHOD 656 ], infos: [
692 ], 657 MessageKind.INVALID_OVERRIDDEN_METHOD,
693 infos: [ 658 MessageKind.INVALID_OVERRIDDEN_METHOD
694 MessageKind.INVALID_OVERRIDDEN_METHOD, 659 ]),
695 MessageKind.INVALID_OVERRIDDEN_METHOD
696 ]),
697 660
698 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed. 661 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
699 check( 662 check("""
700 """
701 class A<T> { 663 class A<T> {
702 method(T t) => null; // testGenericNotSubtype:21 664 method(T t) => null; // testGenericNotSubtype:21
703 } 665 }
704 class B<S> { 666 class B<S> {
705 method(S s) => null; // testGenericNotSubtype:22 667 method(S s) => null; // testGenericNotSubtype:22
706 } 668 }
707 abstract class C implements A<int>, B<num> { 669 abstract class C implements A<int>, B<num> {
708 } 670 }
709 class Class implements C { 671 class Class implements C {
710 method(double d) => null; // testGenericNotSubtype:23 672 method(double d) => null; // testGenericNotSubtype:23
711 } 673 }
712 """, 674 """,
713 warnings: MessageKind.INVALID_OVERRIDE_METHOD, 675 warnings: MessageKind.INVALID_OVERRIDE_METHOD,
714 infos: MessageKind.INVALID_OVERRIDDEN_METHOD), 676 infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
715 677
716 check( 678 check("""
717 """
718 class A<T> { 679 class A<T> {
719 method(T t) => null; // testGenericNotSubtype:24 680 method(T t) => null; // testGenericNotSubtype:24
720 } 681 }
721 class B<S> { 682 class B<S> {
722 method(S s) => null; // testGenericNotSubtype:25 683 method(S s) => null; // testGenericNotSubtype:25
723 } 684 }
724 abstract class C implements A<int>, B<num> { 685 abstract class C implements A<int>, B<num> {
725 } 686 }
726 class Class implements C { 687 class Class implements C {
727 method(String s) => null; // testGenericNotSubtype:26 688 method(String s) => null; // testGenericNotSubtype:26
728 } 689 }
729 """, 690 """, warnings: [
730 warnings: [ 691 MessageKind.INVALID_OVERRIDE_METHOD,
731 MessageKind.INVALID_OVERRIDE_METHOD, 692 MessageKind.INVALID_OVERRIDE_METHOD
732 MessageKind.INVALID_OVERRIDE_METHOD 693 ], infos: [
733 ], 694 MessageKind.INVALID_OVERRIDDEN_METHOD,
734 infos: [ 695 MessageKind.INVALID_OVERRIDDEN_METHOD
735 MessageKind.INVALID_OVERRIDDEN_METHOD, 696 ]),
736 MessageKind.INVALID_OVERRIDDEN_METHOD
737 ]),
738 ]); 697 ]);
739 } 698 }
740 699
741 Future testSetterNotSubtype() { 700 Future testSetterNotSubtype() {
742 return Future.wait([ 701 return Future.wait([
743 check(""" 702 check("""
744 class A { 703 class A {
745 set setter(_) => null; // testSetterNotSubtype:1 704 set setter(_) => null; // testSetterNotSubtype:1
746 } 705 }
747 class Class extends A { 706 class Class extends A {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 755
797 check(""" 756 check("""
798 class A { 757 class A {
799 set setter(int _) => null; // testSetterNotSubtype:13 758 set setter(int _) => null; // testSetterNotSubtype:13
800 } 759 }
801 class Class extends A { 760 class Class extends A {
802 set setter(num _) => null; // testSetterNotSubtype:14 761 set setter(num _) => null; // testSetterNotSubtype:14
803 } 762 }
804 """), 763 """),
805 764
806 check( 765 check("""
807 """
808 class A { 766 class A {
809 set setter(int _) => null; // testSetterNotSubtype:15 767 set setter(int _) => null; // testSetterNotSubtype:15
810 } 768 }
811 class Class extends A { 769 class Class extends A {
812 set setter(double _) => null; // testSetterNotSubtype:16 770 set setter(double _) => null; // testSetterNotSubtype:16
813 } 771 }
814 """, 772 """,
815 warnings: MessageKind.INVALID_OVERRIDE_SETTER, 773 warnings: MessageKind.INVALID_OVERRIDE_SETTER,
816 infos: MessageKind.INVALID_OVERRIDDEN_SETTER), 774 infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
817 775
818 check(""" 776 check("""
819 class A { 777 class A {
820 set setter(int _) => null; // testSetterNotSubtype:17 778 set setter(int _) => null; // testSetterNotSubtype:17
821 } 779 }
822 class B extends A { 780 class B extends A {
823 set setter(num _) => null; // testSetterNotSubtype:18 781 set setter(num _) => null; // testSetterNotSubtype:18
824 } 782 }
825 class Class extends B { 783 class Class extends B {
826 set setter(double _) => null; // testSetterNotSubtype:19 784 set setter(double _) => null; // testSetterNotSubtype:19
827 } 785 }
828 """), 786 """),
829 787
830 check( 788 check("""
831 """
832 class A { 789 class A {
833 set setter(int _) => null; // testSetterNotSubtype:20 790 set setter(int _) => null; // testSetterNotSubtype:20
834 } 791 }
835 class B { 792 class B {
836 set setter(num _) => null; // testSetterNotSubtype:21 793 set setter(num _) => null; // testSetterNotSubtype:21
837 } 794 }
838 class Class extends A implements B { 795 class Class extends A implements B {
839 set setter(double _) => null; // testSetterNotSubtype:22 796 set setter(double _) => null; // testSetterNotSubtype:22
840 } 797 }
841 """, 798 """,
842 warnings: MessageKind.INVALID_OVERRIDE_SETTER, 799 warnings: MessageKind.INVALID_OVERRIDE_SETTER,
843 infos: MessageKind.INVALID_OVERRIDDEN_SETTER), 800 infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
844 801
845 check( 802 check("""
846 """
847 class A { 803 class A {
848 set setter(int _) => null; // testSetterNotSubtype:23 804 set setter(int _) => null; // testSetterNotSubtype:23
849 } 805 }
850 class B { 806 class B {
851 set setter(String _) => null; // testSetterNotSubtype:24 807 set setter(String _) => null; // testSetterNotSubtype:24
852 } 808 }
853 class Class extends A implements B { 809 class Class extends A implements B {
854 set setter(double _) => null; // testSetterNotSubtype:25 810 set setter(double _) => null; // testSetterNotSubtype:25
855 } 811 }
856 """, 812 """, warnings: [
857 warnings: [ 813 MessageKind.INVALID_OVERRIDE_SETTER,
858 MessageKind.INVALID_OVERRIDE_SETTER, 814 MessageKind.INVALID_OVERRIDE_SETTER
859 MessageKind.INVALID_OVERRIDE_SETTER 815 ], infos: [
860 ], 816 MessageKind.INVALID_OVERRIDDEN_SETTER,
861 infos: [ 817 MessageKind.INVALID_OVERRIDDEN_SETTER
862 MessageKind.INVALID_OVERRIDDEN_SETTER, 818 ]),
863 MessageKind.INVALID_OVERRIDDEN_SETTER
864 ]),
865 819
866 check( 820 check("""
867 """
868 class A { 821 class A {
869 set setter(int _) => null; // testSetterNotSubtype:26 822 set setter(int _) => null; // testSetterNotSubtype:26
870 } 823 }
871 class B { 824 class B {
872 set setter(String _) => null; // testSetterNotSubtype:27 825 set setter(String _) => null; // testSetterNotSubtype:27
873 } 826 }
874 class Class implements A, B { 827 class Class implements A, B {
875 set setter(double _) => null; // testSetterNotSubtype:28 828 set setter(double _) => null; // testSetterNotSubtype:28
876 } 829 }
877 """, 830 """, warnings: [
878 warnings: [ 831 MessageKind.INVALID_OVERRIDE_SETTER,
879 MessageKind.INVALID_OVERRIDE_SETTER, 832 MessageKind.INVALID_OVERRIDE_SETTER
880 MessageKind.INVALID_OVERRIDE_SETTER 833 ], infos: [
881 ], 834 MessageKind.INVALID_OVERRIDDEN_SETTER,
882 infos: [ 835 MessageKind.INVALID_OVERRIDDEN_SETTER
883 MessageKind.INVALID_OVERRIDDEN_SETTER, 836 ]),
884 MessageKind.INVALID_OVERRIDDEN_SETTER
885 ]),
886 837
887 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed. 838 // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
888 check( 839 check("""
889 """
890 class A { 840 class A {
891 set setter(int _) => null; // testSetterNotSubtype:29 841 set setter(int _) => null; // testSetterNotSubtype:29
892 } 842 }
893 class B { 843 class B {
894 set setter(num _) => null; // testSetterNotSubtype:30 844 set setter(num _) => null; // testSetterNotSubtype:30
895 } 845 }
896 abstract class C implements A, B { 846 abstract class C implements A, B {
897 } 847 }
898 class Class implements C { 848 class Class implements C {
899 set setter(double _) => null; // testSetterNotSubtype:31 849 set setter(double _) => null; // testSetterNotSubtype:31
900 } 850 }
901 """, 851 """,
902 warnings: MessageKind.INVALID_OVERRIDE_SETTER, 852 warnings: MessageKind.INVALID_OVERRIDE_SETTER,
903 infos: MessageKind.INVALID_OVERRIDDEN_SETTER), 853 infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
904 854
905 check( 855 check("""
906 """
907 class A { 856 class A {
908 set setter(int _) => null; // testSetterNotSubtype:32 857 set setter(int _) => null; // testSetterNotSubtype:32
909 } 858 }
910 class B { 859 class B {
911 set setter(num _) => null; // testSetterNotSubtype:33 860 set setter(num _) => null; // testSetterNotSubtype:33
912 } 861 }
913 abstract class C implements A, B { 862 abstract class C implements A, B {
914 } 863 }
915 class Class implements C { 864 class Class implements C {
916 set setter(String _) => null; // testSetterNotSubtype:34 865 set setter(String _) => null; // testSetterNotSubtype:34
917 } 866 }
918 """, 867 """, warnings: [
919 warnings: [ 868 MessageKind.INVALID_OVERRIDE_SETTER,
920 MessageKind.INVALID_OVERRIDE_SETTER, 869 MessageKind.INVALID_OVERRIDE_SETTER
921 MessageKind.INVALID_OVERRIDE_SETTER 870 ], infos: [
922 ], 871 MessageKind.INVALID_OVERRIDDEN_SETTER,
923 infos: [ 872 MessageKind.INVALID_OVERRIDDEN_SETTER
924 MessageKind.INVALID_OVERRIDDEN_SETTER, 873 ]),
925 MessageKind.INVALID_OVERRIDDEN_SETTER
926 ]),
927 ]); 874 ]);
928 } 875 }
929 876
930 Future testFieldNotSubtype() { 877 Future testFieldNotSubtype() {
931 return Future.wait([ 878 return Future.wait([
932 check(""" 879 check("""
933 class A { 880 class A {
934 int field; // testFieldNotSubtype:1 881 int field; // testFieldNotSubtype:1
935 } 882 }
936 class Class extends A { 883 class Class extends A {
937 int field; // testFieldNotSubtype:2 884 int field; // testFieldNotSubtype:2
938 } 885 }
939 """), 886 """),
940 check(""" 887 check("""
941 class A { 888 class A {
942 num field; // testFieldNotSubtype:3 889 num field; // testFieldNotSubtype:3
943 } 890 }
944 class Class extends A { 891 class Class extends A {
945 int field; // testFieldNotSubtype:4 892 int field; // testFieldNotSubtype:4
946 } 893 }
947 """), 894 """),
948 check(""" 895 check("""
949 class A { 896 class A {
950 int field; // testFieldNotSubtype:5 897 int field; // testFieldNotSubtype:5
951 } 898 }
952 class Class extends A { 899 class Class extends A {
953 num field; // testFieldNotSubtype:6 900 num field; // testFieldNotSubtype:6
954 } 901 }
955 """), 902 """),
956 check( 903 check("""
957 """
958 class A { 904 class A {
959 int field; // testFieldNotSubtype:7 905 int field; // testFieldNotSubtype:7
960 } 906 }
961 class Class extends A { 907 class Class extends A {
962 double field; // testFieldNotSubtype:8 908 double field; // testFieldNotSubtype:8
963 } 909 }
964 """, 910 """,
965 warnings: MessageKind.INVALID_OVERRIDE_FIELD, 911 warnings: MessageKind.INVALID_OVERRIDE_FIELD,
966 infos: MessageKind.INVALID_OVERRIDDEN_FIELD), 912 infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
967 check(""" 913 check("""
968 class A { 914 class A {
969 int field; // testFieldNotSubtype:9 915 int field; // testFieldNotSubtype:9
970 } 916 }
971 class B extends A { 917 class B extends A {
972 num field; // testFieldNotSubtype:10 918 num field; // testFieldNotSubtype:10
973 } 919 }
974 class Class extends B { 920 class Class extends B {
975 double field; // testFieldNotSubtype:11 921 double field; // testFieldNotSubtype:11
976 } 922 }
977 """), 923 """),
978 check(""" 924 check("""
979 class A { 925 class A {
980 num field; // testFieldNotSubtype:12 926 num field; // testFieldNotSubtype:12
981 } 927 }
982 class Class extends A { 928 class Class extends A {
983 int get field => null; // testFieldNotSubtype:13 929 int get field => null; // testFieldNotSubtype:13
984 } 930 }
985 """), 931 """),
986 check( 932 check("""
987 """
988 class A { 933 class A {
989 num field; // testFieldNotSubtype:14 934 num field; // testFieldNotSubtype:14
990 } 935 }
991 class Class extends A { 936 class Class extends A {
992 String get field => null; // testFieldNotSubtype:15 937 String get field => null; // testFieldNotSubtype:15
993 } 938 }
994 """, 939 """,
995 warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER, 940 warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
996 infos: MessageKind.INVALID_OVERRIDDEN_FIELD), 941 infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
997 check( 942 check("""
998 """
999 class A { 943 class A {
1000 num get field => null; // testFieldNotSubtype:16 944 num get field => null; // testFieldNotSubtype:16
1001 } 945 }
1002 class Class extends A { 946 class Class extends A {
1003 String field; // testFieldNotSubtype:17 947 String field; // testFieldNotSubtype:17
1004 } 948 }
1005 """, 949 """,
1006 warnings: MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD, 950 warnings: MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD,
1007 infos: MessageKind.INVALID_OVERRIDDEN_GETTER), 951 infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
1008 check(""" 952 check("""
(...skipping 21 matching lines...) Expand all
1030 } 974 }
1031 """), 975 """),
1032 check(""" 976 check("""
1033 class A { 977 class A {
1034 void set field(int _) {} // testFieldNotSubtype:23 978 void set field(int _) {} // testFieldNotSubtype:23
1035 } 979 }
1036 class Class extends A { 980 class Class extends A {
1037 num field; // testFieldNotSubtype:24 981 num field; // testFieldNotSubtype:24
1038 } 982 }
1039 """), 983 """),
1040 check( 984 check("""
1041 """
1042 class A { 985 class A {
1043 num field; // testFieldNotSubtype:25 986 num field; // testFieldNotSubtype:25
1044 } 987 }
1045 class Class extends A { 988 class Class extends A {
1046 set field(String _) {} // testFieldNotSubtype:26 989 set field(String _) {} // testFieldNotSubtype:26
1047 } 990 }
1048 """, 991 """,
1049 warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER, 992 warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER,
1050 infos: MessageKind.INVALID_OVERRIDDEN_FIELD), 993 infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
1051 check( 994 check("""
1052 """
1053 class A { 995 class A {
1054 set field(num _) {} // testFieldNotSubtype:27 996 set field(num _) {} // testFieldNotSubtype:27
1055 } 997 }
1056 class Class extends A { 998 class Class extends A {
1057 String field; // testFieldNotSubtype:28 999 String field; // testFieldNotSubtype:28
1058 } 1000 }
1059 """, 1001 """,
1060 warnings: MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD, 1002 warnings: MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD,
1061 infos: MessageKind.INVALID_OVERRIDDEN_SETTER), 1003 infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
1062 check( 1004 check("""
1063 """
1064 class A { 1005 class A {
1065 int field; // testFieldNotSubtype:29 1006 int field; // testFieldNotSubtype:29
1066 } 1007 }
1067 class Class implements A { 1008 class Class implements A {
1068 String get field => null; // testFieldNotSubtype:30 1009 String get field => null; // testFieldNotSubtype:30
1069 void set field(String s) {} // testFieldNotSubtype:31 1010 void set field(String s) {} // testFieldNotSubtype:31
1070 } 1011 }
1071 """, 1012 """, warnings: [
1072 warnings: [ 1013 MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
1073 MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER, 1014 MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER
1074 MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER 1015 ], infos: [
1075 ], 1016 MessageKind.INVALID_OVERRIDDEN_FIELD,
1076 infos: [ 1017 MessageKind.INVALID_OVERRIDDEN_FIELD
1077 MessageKind.INVALID_OVERRIDDEN_FIELD, 1018 ]),
1078 MessageKind.INVALID_OVERRIDDEN_FIELD 1019 check("""
1079 ]),
1080 check(
1081 """
1082 class A { 1020 class A {
1083 String get field => null; // testFieldNotSubtype:32 1021 String get field => null; // testFieldNotSubtype:32
1084 void set field(String s) {} // testFieldNotSubtype:33 1022 void set field(String s) {} // testFieldNotSubtype:33
1085 } 1023 }
1086 class Class implements A { 1024 class Class implements A {
1087 int field; // testFieldNotSubtype:34 1025 int field; // testFieldNotSubtype:34
1088 } 1026 }
1089 """, 1027 """, warnings: [
1090 warnings: [ 1028 MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD,
1091 MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD, 1029 MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD
1092 MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD 1030 ], infos: [
1093 ], 1031 MessageKind.INVALID_OVERRIDDEN_GETTER,
1094 infos: [ 1032 MessageKind.INVALID_OVERRIDDEN_SETTER
1095 MessageKind.INVALID_OVERRIDDEN_GETTER, 1033 ]),
1096 MessageKind.INVALID_OVERRIDDEN_SETTER
1097 ]),
1098 ]); 1034 ]);
1099 } 1035 }
1100 1036
1101 Future testMixedOverride() { 1037 Future testMixedOverride() {
1102 return Future.wait([ 1038 return Future.wait([
1103 check( 1039 check("""
1104 """
1105 class A { 1040 class A {
1106 var member; // testMixedOverride:1 1041 var member; // testMixedOverride:1
1107 } 1042 }
1108 class Class extends A { 1043 class Class extends A {
1109 member() {} // testMixedOverride:2 1044 member() {} // testMixedOverride:2
1110 } 1045 }
1111 """, 1046 """,
1112 errors: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD, 1047 errors: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD,
1113 infos: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT), 1048 infos: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT),
1114 check( 1049 check("""
1115 """
1116 class A { 1050 class A {
1117 member() {} // testMixedOverride:3 1051 member() {} // testMixedOverride:3
1118 } 1052 }
1119 class Class extends A { 1053 class Class extends A {
1120 var member; // testMixedOverride:4 1054 var member; // testMixedOverride:4
1121 } 1055 }
1122 """, 1056 """,
1123 errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD, 1057 errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD,
1124 infos: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT), 1058 infos: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT),
1125 check( 1059 check("""
1126 """
1127 class A { 1060 class A {
1128 get member => null; // testMixedOverride:5 1061 get member => null; // testMixedOverride:5
1129 } 1062 }
1130 class Class extends A { 1063 class Class extends A {
1131 member() {} // testMixedOverride:6 1064 member() {} // testMixedOverride:6
1132 } 1065 }
1133 """, 1066 """,
1134 errors: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD, 1067 errors: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD,
1135 infos: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT), 1068 infos: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT),
1136 check( 1069 check("""
1137 """
1138 class A { 1070 class A {
1139 member() {} // testMixedOverride:7 1071 member() {} // testMixedOverride:7
1140 } 1072 }
1141 class Class extends A { 1073 class Class extends A {
1142 get member => null; // testMixedOverride:8 1074 get member => null; // testMixedOverride:8
1143 } 1075 }
1144 """, 1076 """,
1145 errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER, 1077 errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER,
1146 infos: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT), 1078 infos: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT),
1147 check(""" 1079 check("""
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 } 1231 }
1300 """), 1232 """),
1301 check(""" 1233 check("""
1302 abstract class A { 1234 abstract class A {
1303 method(); // testAbstractMethod:7 1235 method(); // testAbstractMethod:7
1304 } 1236 }
1305 class Class extends A { 1237 class Class extends A {
1306 method([a]) {} // testAbstractMethod:8 1238 method([a]) {} // testAbstractMethod:8
1307 } 1239 }
1308 """), 1240 """),
1309 check( 1241 check("""
1310 """
1311 abstract class A { 1242 abstract class A {
1312 method(); // testAbstractMethod:9 1243 method(); // testAbstractMethod:9
1313 } 1244 }
1314 class Class extends A { 1245 class Class extends A {
1315 } 1246 }
1316 """, 1247 """,
1317 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE, 1248 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
1318 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT), 1249 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
1319 check( 1250 check("""
1320 """
1321 abstract class A { 1251 abstract class A {
1322 get getter; // testAbstractMethod:10 1252 get getter; // testAbstractMethod:10
1323 } 1253 }
1324 class Class extends A { 1254 class Class extends A {
1325 } 1255 }
1326 """, 1256 """,
1327 warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE, 1257 warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
1328 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER), 1258 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER),
1329 check( 1259 check("""
1330 """
1331 abstract class A { 1260 abstract class A {
1332 set setter(_); // testAbstractMethod:11 1261 set setter(_); // testAbstractMethod:11
1333 } 1262 }
1334 class Class extends A { 1263 class Class extends A {
1335 } 1264 }
1336 """, 1265 """,
1337 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE, 1266 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
1338 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER), 1267 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER),
1339 check( 1268 check(
1340 """ 1269 """
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 } 1363 }
1435 """), 1364 """),
1436 check(""" 1365 check("""
1437 class A { 1366 class A {
1438 method() {} // testAbstractMethod:26 1367 method() {} // testAbstractMethod:26
1439 } 1368 }
1440 class Class implements A { 1369 class Class implements A {
1441 method([a]) {} // testAbstractMethod:27 1370 method([a]) {} // testAbstractMethod:27
1442 } 1371 }
1443 """), 1372 """),
1444 check( 1373 check("""
1445 """
1446 class A { 1374 class A {
1447 method() {} // testAbstractMethod:28 1375 method() {} // testAbstractMethod:28
1448 } 1376 }
1449 class Class implements A { 1377 class Class implements A {
1450 } 1378 }
1451 """, 1379 """,
1452 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE, 1380 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
1453 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT), 1381 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
1454 check(""" 1382 check("""
1455 class A { 1383 class A {
1456 method() {} // testAbstractMethod:29 1384 method() {} // testAbstractMethod:29
1457 } 1385 }
1458 class B { 1386 class B {
1459 method() {} // testAbstractMethod:30 1387 method() {} // testAbstractMethod:30
1460 } 1388 }
1461 class Class extends A implements B { 1389 class Class extends A implements B {
1462 } 1390 }
1463 """), 1391 """),
1464 check( 1392 check("""
1465 """
1466 class A { 1393 class A {
1467 var member; // testAbstractMethod:31 1394 var member; // testAbstractMethod:31
1468 } 1395 }
1469 class Class implements A { 1396 class Class implements A {
1470 } 1397 }
1471 """, 1398 """, warnings: [
1472 warnings: [ 1399 MessageKind.UNIMPLEMENTED_GETTER_ONE,
1473 MessageKind.UNIMPLEMENTED_GETTER_ONE, 1400 MessageKind.UNIMPLEMENTED_SETTER_ONE
1474 MessageKind.UNIMPLEMENTED_SETTER_ONE 1401 ], infos: [
1475 ], 1402 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
1476 infos: [ 1403 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
1477 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER, 1404 ]),
1478 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER 1405 check("""
1479 ]),
1480 check(
1481 """
1482 class A { 1406 class A {
1483 var member; // testAbstractMethod:32 1407 var member; // testAbstractMethod:32
1484 } 1408 }
1485 class B { 1409 class B {
1486 get member => null; // testAbstractMethod:33 1410 get member => null; // testAbstractMethod:33
1487 set member(_) {} // testAbstractMethod:34 1411 set member(_) {} // testAbstractMethod:34
1488 } 1412 }
1489 class Class implements A, B { 1413 class Class implements A, B {
1490 } 1414 }
1491 """, 1415 """, warnings: [
1492 warnings: [ 1416 MessageKind.UNIMPLEMENTED_GETTER,
1493 MessageKind.UNIMPLEMENTED_GETTER, 1417 MessageKind.UNIMPLEMENTED_SETTER
1494 MessageKind.UNIMPLEMENTED_SETTER 1418 ], infos: [
1495 ], 1419 MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER,
1496 infos: [ 1420 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
1497 MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER, 1421 MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER,
1498 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER, 1422 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
1499 MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER, 1423 ]),
1500 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER 1424 check("""
1501 ]),
1502 check(
1503 """
1504 class A { 1425 class A {
1505 var member; // testAbstractMethod:35 1426 var member; // testAbstractMethod:35
1506 } 1427 }
1507 class B { 1428 class B {
1508 var member; // testAbstractMethod:36 1429 var member; // testAbstractMethod:36
1509 } 1430 }
1510 class Class implements A, B { 1431 class Class implements A, B {
1511 } 1432 }
1512 """, 1433 """, warnings: [
1513 warnings: [ 1434 MessageKind.UNIMPLEMENTED_GETTER,
1514 MessageKind.UNIMPLEMENTED_GETTER, 1435 MessageKind.UNIMPLEMENTED_SETTER
1515 MessageKind.UNIMPLEMENTED_SETTER 1436 ], infos: [
1516 ], 1437 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
1517 infos: [ 1438 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
1518 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER, 1439 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER,
1519 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER, 1440 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
1520 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER, 1441 ]),
1521 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER 1442 check("""
1522 ]),
1523 check(
1524 """
1525 class A { 1443 class A {
1526 get member => 0; // testAbstractMethod:37 1444 get member => 0; // testAbstractMethod:37
1527 } 1445 }
1528 class Class implements A { 1446 class Class implements A {
1529 } 1447 }
1530 """, 1448 """,
1531 warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE, 1449 warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
1532 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER), 1450 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER),
1533 check( 1451 check("""
1534 """
1535 class A { 1452 class A {
1536 set member(_) {} // testAbstractMethod:38 1453 set member(_) {} // testAbstractMethod:38
1537 } 1454 }
1538 class Class implements A { 1455 class Class implements A {
1539 } 1456 }
1540 """, 1457 """,
1541 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE, 1458 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
1542 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER), 1459 infos: MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER),
1543 check( 1460 check("""
1544 """
1545 class A { 1461 class A {
1546 var member; // testAbstractMethod:39 1462 var member; // testAbstractMethod:39
1547 } 1463 }
1548 class Class implements A { 1464 class Class implements A {
1549 get member => 0; 1465 get member => 0;
1550 } 1466 }
1551 """, 1467 """,
1552 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE, 1468 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
1553 infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER), 1469 infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER),
1554 check( 1470 check("""
1555 """
1556 class A { 1471 class A {
1557 var field; // testAbstractMethod:40 1472 var field; // testAbstractMethod:40
1558 } 1473 }
1559 class Class implements A { 1474 class Class implements A {
1560 final field = 0; // testAbstractMethod:41 1475 final field = 0; // testAbstractMethod:41
1561 } 1476 }
1562 """, 1477 """,
1563 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE, 1478 warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
1564 infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER), 1479 infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER),
1565 check( 1480 check("""
1566 """
1567 class A { 1481 class A {
1568 var member; // testAbstractMethod:42 1482 var member; // testAbstractMethod:42
1569 } 1483 }
1570 class Class implements A { 1484 class Class implements A {
1571 set member(_) {} 1485 set member(_) {}
1572 } 1486 }
1573 """, 1487 """,
1574 warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE, 1488 warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
1575 infos: MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER), 1489 infos: MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER),
1576 check(""" 1490 check("""
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 noSuchMethod(_, [__]) => null; 1528 noSuchMethod(_, [__]) => null;
1615 method(); // testNoSuchMethod:4 1529 method(); // testNoSuchMethod:4
1616 } 1530 }
1617 """), 1531 """),
1618 check(""" 1532 check("""
1619 class Class { 1533 class Class {
1620 noSuchMethod(_); 1534 noSuchMethod(_);
1621 method(); // testNoSuchMethod:5 1535 method(); // testNoSuchMethod:5
1622 } 1536 }
1623 """), 1537 """),
1624 check( 1538 check("""
1625 """
1626 abstract class A { 1539 abstract class A {
1627 method(); // testNoSuchMethod:6 1540 method(); // testNoSuchMethod:6
1628 } 1541 }
1629 class Class extends A { 1542 class Class extends A {
1630 } 1543 }
1631 """, 1544 """,
1632 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE, 1545 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
1633 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT), 1546 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
1634 check( 1547 check("""
1635 """
1636 abstract class A { 1548 abstract class A {
1637 method(); // testNoSuchMethod:7 1549 method(); // testNoSuchMethod:7
1638 } 1550 }
1639 @proxy 1551 @proxy
1640 class Class extends A { 1552 class Class extends A {
1641 } 1553 }
1642 """, 1554 """,
1643 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE, 1555 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
1644 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT), 1556 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
1645 check(""" 1557 check("""
1646 abstract class A { 1558 abstract class A {
1647 method(); // testNoSuchMethod:8 1559 method(); // testNoSuchMethod:8
1648 } 1560 }
1649 class Class extends A { 1561 class Class extends A {
1650 noSuchMethod(_) => null; 1562 noSuchMethod(_) => null;
1651 } 1563 }
1652 """), 1564 """),
1653 check( 1565 check("""
1654 """
1655 class A { 1566 class A {
1656 method() {} // testNoSuchMethod:9 1567 method() {} // testNoSuchMethod:9
1657 } 1568 }
1658 class Class implements A { 1569 class Class implements A {
1659 } 1570 }
1660 """, 1571 """,
1661 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE, 1572 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
1662 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT), 1573 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
1663 check( 1574 check("""
1664 """
1665 class A { 1575 class A {
1666 method() {} // testNoSuchMethod:10 1576 method() {} // testNoSuchMethod:10
1667 } 1577 }
1668 class Class implements A { 1578 class Class implements A {
1669 } 1579 }
1670 """, 1580 """,
1671 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE, 1581 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
1672 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT), 1582 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
1673 check( 1583 check("""
1674 """
1675 class A { 1584 class A {
1676 method() {} // testNoSuchMethod:11 1585 method() {} // testNoSuchMethod:11
1677 } 1586 }
1678 @proxy 1587 @proxy
1679 class Class implements A { 1588 class Class implements A {
1680 } 1589 }
1681 """, 1590 """,
1682 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE, 1591 warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
1683 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT), 1592 infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
1684 check(""" 1593 check("""
1685 class A { 1594 class A {
1686 method() {} // testNoSuchMethod:12 1595 method() {} // testNoSuchMethod:12
1687 } 1596 }
1688 class Class implements A { 1597 class Class implements A {
1689 noSuchMethod(_) => null; 1598 noSuchMethod(_) => null;
1690 } 1599 }
1691 """), 1600 """),
1692 check(""" 1601 check("""
1693 class A { 1602 class A {
1694 noSuchMethod(_) => null; 1603 noSuchMethod(_) => null;
1695 method(); // testNoSuchMethod:13 1604 method(); // testNoSuchMethod:13
1696 } 1605 }
1697 class Class extends A { 1606 class Class extends A {
1698 } 1607 }
1699 """), 1608 """),
1700 ]); 1609 ]);
1701 } 1610 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/no_such_method_enabled_test.dart ('k') | tests/compiler/dart2js/patch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698