| OLD | NEW |
| 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 // TODO(jmesserly): this file needs to be refactored, it's a port from | |
| 6 // package:dev_compiler's tests | |
| 7 /// General type checking tests | |
| 8 library analyzer.test.src.task.strong.checker_test; | 5 library analyzer.test.src.task.strong.checker_test; |
| 9 | 6 |
| 10 import '../../../reflective_tests.dart'; | 7 import '../../../reflective_tests.dart'; |
| 11 import 'strong_test_helper.dart'; | 8 import 'strong_test_helper.dart'; |
| 12 | 9 |
| 13 void main() { | 10 void main() { |
| 14 initStrongModeTests(); | 11 initStrongModeTests(); |
| 15 runReflectiveTests(CheckerTest); | 12 runReflectiveTests(CheckerTest); |
| 16 } | 13 } |
| 17 | 14 |
| 18 @reflectiveTest | 15 @reflectiveTest |
| 19 class CheckerTest { | 16 class CheckerTest { |
| 20 void test_awaitForInCastsStreamElementToVariable() { | 17 void test_awaitForInCastsStreamElementToVariable() { |
| 21 checkFile(''' | 18 checkFile(''' |
| 22 import 'dart:async'; | 19 import 'dart:async'; |
| 23 main() async { | 20 main() async { |
| 24 // Don't choke if sequence is not stream. | 21 // Don't choke if sequence is not stream. |
| 25 await for (var i in /*warning:FOR_IN_OF_INVALID_TYPE*/1234) {} | 22 await for (var i in /*severe:FOR_IN_OF_INVALID_TYPE*/1234) {} |
| 26 | 23 |
| 27 // Dynamic cast. | 24 // Dynamic cast. |
| 28 await for (String /*info:DYNAMIC_CAST*/s in new Stream<dynamic>()) {} | 25 await for (String /*info:DYNAMIC_CAST*/s in new Stream<dynamic>()) {} |
| 29 | 26 |
| 30 // Identity cast. | 27 // Identity cast. |
| 31 await for (String s in new Stream<String>()) {} | 28 await for (String s in new Stream<String>()) {} |
| 32 | 29 |
| 33 // Untyped. | 30 // Untyped. |
| 34 await for (var s in new Stream<String>()) {} | 31 await for (var s in new Stream<String>()) {} |
| 35 | 32 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 B b = new B(); | 76 B b = new B(); |
| 80 var c = foo(); | 77 var c = foo(); |
| 81 a = a * b; | 78 a = a * b; |
| 82 a = a * /*info:DYNAMIC_CAST*/c; | 79 a = a * /*info:DYNAMIC_CAST*/c; |
| 83 a = a / b; | 80 a = a / b; |
| 84 a = a ~/ b; | 81 a = a ~/ b; |
| 85 a = a % b; | 82 a = a % b; |
| 86 a = a + b; | 83 a = a + b; |
| 87 a = a + /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; | 84 a = a + /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; |
| 88 a = a - b; | 85 a = a - b; |
| 89 b = /*warning:INVALID_ASSIGNMENT*/b - b; | 86 b = /*severe:INVALID_ASSIGNMENT*/b - b; |
| 90 a = a << b; | 87 a = a << b; |
| 91 a = a >> b; | 88 a = a >> b; |
| 92 a = a & b; | 89 a = a & b; |
| 93 a = a ^ b; | 90 a = a ^ b; |
| 94 a = a | b; | 91 a = a | b; |
| 95 c = (/*info:DYNAMIC_INVOKE*/c + b); | 92 c = (/*info:DYNAMIC_INVOKE*/c + b); |
| 96 | 93 |
| 97 String x = 'hello'; | 94 String x = 'hello'; |
| 98 int y = 42; | 95 int y = 42; |
| 99 x = x + x; | 96 x = x + x; |
| 100 x = x + /*info:DYNAMIC_CAST*/c; | 97 x = x + /*info:DYNAMIC_CAST*/c; |
| 101 x = x + /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y; | 98 x = x + /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y; |
| 102 | 99 |
| 103 bool p = true; | 100 bool p = true; |
| 104 p = p && p; | 101 p = p && p; |
| 105 p = p && /*info:DYNAMIC_CAST*/c; | 102 p = p && /*info:DYNAMIC_CAST*/c; |
| 106 p = (/*info:DYNAMIC_CAST*/c) && p; | 103 p = (/*info:DYNAMIC_CAST*/c) && p; |
| 107 p = (/*info:DYNAMIC_CAST*/c) && /*info:DYNAMIC_CAST*/c; | 104 p = (/*info:DYNAMIC_CAST*/c) && /*info:DYNAMIC_CAST*/c; |
| 108 p = /*warning:NON_BOOL_OPERAND*/y && p; | 105 p = /*severe:NON_BOOL_OPERAND*/y && p; |
| 109 p = c == y; | 106 p = c == y; |
| 110 | 107 |
| 111 a = a[b]; | 108 a = a[b]; |
| 112 a = a[/*info:DYNAMIC_CAST*/c]; | 109 a = a[/*info:DYNAMIC_CAST*/c]; |
| 113 c = (/*info:DYNAMIC_INVOKE*/c[b]); | 110 c = (/*info:DYNAMIC_INVOKE*/c[b]); |
| 114 a[/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y]; | 111 a[/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/y]; |
| 115 } | 112 } |
| 116 '''); | 113 '''); |
| 117 } | 114 } |
| 118 | 115 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 var c = foo(); | 289 var c = foo(); |
| 293 a = a * b; | 290 a = a * b; |
| 294 a *= b; | 291 a *= b; |
| 295 a *= /*info:DYNAMIC_CAST*/c; | 292 a *= /*info:DYNAMIC_CAST*/c; |
| 296 a /= b; | 293 a /= b; |
| 297 a ~/= b; | 294 a ~/= b; |
| 298 a %= b; | 295 a %= b; |
| 299 a += b; | 296 a += b; |
| 300 a += /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; | 297 a += /*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; |
| 301 a -= b; | 298 a -= b; |
| 302 /*severe:STATIC_TYPE_ERROR*/b -= /*warning:INVALID_ASSIGNMENT*/b; | 299 /*severe:STATIC_TYPE_ERROR*/b -= /*severe:INVALID_ASSIGNMENT*/b; |
| 303 a <<= b; | 300 a <<= b; |
| 304 a >>= b; | 301 a >>= b; |
| 305 a &= b; | 302 a &= b; |
| 306 a ^= b; | 303 a ^= b; |
| 307 a |= b; | 304 a |= b; |
| 308 /*info:DYNAMIC_INVOKE*/c += b; | 305 /*info:DYNAMIC_INVOKE*/c += b; |
| 309 | 306 |
| 310 var d = new D(); | 307 var d = new D(); |
| 311 a[b] += d; | 308 a[b] += d; |
| 312 a[/*info:DYNAMIC_CAST*/c] += d; | 309 a[/*info:DYNAMIC_CAST*/c] += d; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 class B { | 437 class B { |
| 441 int call(int x) => x; | 438 int call(int x) => x; |
| 442 double col(double x) => x; | 439 double col(double x) => x; |
| 443 } | 440 } |
| 444 void main() { | 441 void main() { |
| 445 { | 442 { |
| 446 B f = new B(); | 443 B f = new B(); |
| 447 int x; | 444 int x; |
| 448 double y; | 445 double y; |
| 449 x = f(3); | 446 x = f(3); |
| 450 x = /*warning:INVALID_ASSIGNMENT*/f.col(3.0); | 447 x = /*severe:INVALID_ASSIGNMENT*/f.col(3.0); |
| 451 y = /*warning:INVALID_ASSIGNMENT*/f(3); | 448 y = /*severe:INVALID_ASSIGNMENT*/f(3); |
| 452 y = f.col(3.0); | 449 y = f.col(3.0); |
| 453 f(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3.0); | 450 f(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3.0); |
| 454 f.col(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); | 451 f.col(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); |
| 455 } | 452 } |
| 456 { | 453 { |
| 457 Function f = new B(); | 454 Function f = new B(); |
| 458 int x; | 455 int x; |
| 459 double y; | 456 double y; |
| 460 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); | 457 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); |
| 461 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE, info:INVALID_ASSIGNMENT*/f.col
(3.0); | 458 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE, info:INVALID_ASSIGNMENT*/f.col
(3.0); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 476 } | 473 } |
| 477 { | 474 { |
| 478 dynamic g = new B(); | 475 dynamic g = new B(); |
| 479 /*info:DYNAMIC_INVOKE*/g.call(/*info:ARGUMENT_TYPE_NOT_ASSIGNABLE*/32.0); | 476 /*info:DYNAMIC_INVOKE*/g.call(/*info:ARGUMENT_TYPE_NOT_ASSIGNABLE*/32.0); |
| 480 /*info:DYNAMIC_INVOKE*/g.col(42.0); | 477 /*info:DYNAMIC_INVOKE*/g.col(42.0); |
| 481 /*info:DYNAMIC_INVOKE*/g.foo(42.0); | 478 /*info:DYNAMIC_INVOKE*/g.foo(42.0); |
| 482 /*info:DYNAMIC_INVOKE*/g./*info:UNDEFINED_GETTER*/x; | 479 /*info:DYNAMIC_INVOKE*/g./*info:UNDEFINED_GETTER*/x; |
| 483 A f = new B(); | 480 A f = new B(); |
| 484 /*info:DYNAMIC_INVOKE*/f.col(42.0); | 481 /*info:DYNAMIC_INVOKE*/f.col(42.0); |
| 485 /*info:DYNAMIC_INVOKE*/f.foo(42.0); | 482 /*info:DYNAMIC_INVOKE*/f.foo(42.0); |
| 486 /*info:DYNAMIC_INVOKE*/f./*warning:UNDEFINED_GETTER*/x; | 483 /*info:DYNAMIC_INVOKE*/f./*severe:UNDEFINED_GETTER*/x; |
| 487 } | 484 } |
| 488 } | 485 } |
| 489 '''); | 486 '''); |
| 490 } | 487 } |
| 491 | 488 |
| 492 void test_factoryConstructorDowncast() { | 489 void test_factoryConstructorDowncast() { |
| 493 checkFile(r''' | 490 checkFile(r''' |
| 494 class Animal { | 491 class Animal { |
| 495 Animal(); | 492 Animal(); |
| 496 factory Animal.cat() => new Cat(); | 493 factory Animal.cat() => new Cat(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 /*severe:INVALID_METHOD_OVERRIDE*/void set f4(dynamic value) {} | 620 /*severe:INVALID_METHOD_OVERRIDE*/void set f4(dynamic value) {} |
| 624 set f5(B value) {} | 621 set f5(B value) {} |
| 625 } | 622 } |
| 626 '''); | 623 '''); |
| 627 } | 624 } |
| 628 | 625 |
| 629 void test_forInCastsIterateElementToVariable() { | 626 void test_forInCastsIterateElementToVariable() { |
| 630 checkFile(''' | 627 checkFile(''' |
| 631 main() { | 628 main() { |
| 632 // Don't choke if sequence is not iterable. | 629 // Don't choke if sequence is not iterable. |
| 633 for (var i in /*warning:FOR_IN_OF_INVALID_TYPE*/1234) {} | 630 for (var i in /*severe:FOR_IN_OF_INVALID_TYPE*/1234) {} |
| 634 | 631 |
| 635 // Dynamic cast. | 632 // Dynamic cast. |
| 636 for (String /*info:DYNAMIC_CAST*/s in <dynamic>[]) {} | 633 for (String /*info:DYNAMIC_CAST*/s in <dynamic>[]) {} |
| 637 | 634 |
| 638 // Identity cast. | 635 // Identity cast. |
| 639 for (String s in <String>[]) {} | 636 for (String s in <String>[]) {} |
| 640 | 637 |
| 641 // Untyped. | 638 // Untyped. |
| 642 for (var s in <String>[]) {} | 639 for (var s in <String>[]) {} |
| 643 | 640 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 656 Object o; | 653 Object o; |
| 657 for (var i in /*info:DOWN_CAST_IMPLICIT*/o) {} | 654 for (var i in /*info:DOWN_CAST_IMPLICIT*/o) {} |
| 658 } | 655 } |
| 659 '''); | 656 '''); |
| 660 } | 657 } |
| 661 | 658 |
| 662 void test_forLoopVariable() { | 659 void test_forLoopVariable() { |
| 663 checkFile(''' | 660 checkFile(''' |
| 664 foo() { | 661 foo() { |
| 665 for (int i = 0; i < 10; i++) { | 662 for (int i = 0; i < 10; i++) { |
| 666 i = /*warning:INVALID_ASSIGNMENT*/"hi"; | 663 i = /*severe:INVALID_ASSIGNMENT*/"hi"; |
| 667 } | 664 } |
| 668 } | 665 } |
| 669 bar() { | 666 bar() { |
| 670 for (var i = 0; i < 10; i++) { | 667 for (var i = 0; i < 10; i++) { |
| 671 int j = i + 1; | 668 int j = i + 1; |
| 672 } | 669 } |
| 673 } | 670 } |
| 674 '''); | 671 '''); |
| 675 } | 672 } |
| 676 | 673 |
| 677 void test_functionModifiers_async() { | 674 void test_functionModifiers_async() { |
| 678 checkFile(''' | 675 checkFile(''' |
| 679 import 'dart:async'; | 676 import 'dart:async'; |
| 680 import 'dart:math' show Random; | 677 import 'dart:math' show Random; |
| 681 | 678 |
| 682 dynamic x; | 679 dynamic x; |
| 683 | 680 |
| 684 foo1() async => x; | 681 foo1() async => x; |
| 685 Future foo2() async => x; | 682 Future foo2() async => x; |
| 686 Future<int> foo3() async => /*info:DYNAMIC_CAST*/x; | 683 Future<int> foo3() async => /*info:DYNAMIC_CAST*/x; |
| 687 Future<int> foo4() async => new Future<int>.value(/*info:DYNAMIC_CAST*/x); | 684 Future<int> foo4() async => new Future<int>.value(/*info:DYNAMIC_CAST*/x); |
| 688 Future<int> foo5() async => | 685 Future<int> foo5() async => |
| 689 /*warning:RETURN_OF_INVALID_TYPE*/new Future<String>.value(/*info:DYNAMIC_CA
ST*/x); | 686 /*severe:RETURN_OF_INVALID_TYPE*/new Future<String>.value(/*info:DYNAMIC_CAS
T*/x); |
| 690 | 687 |
| 691 bar1() async { return x; } | 688 bar1() async { return x; } |
| 692 Future bar2() async { return x; } | 689 Future bar2() async { return x; } |
| 693 Future<int> bar3() async { return /*info:DYNAMIC_CAST*/x; } | 690 Future<int> bar3() async { return /*info:DYNAMIC_CAST*/x; } |
| 694 Future<int> bar4() async { return new Future<int>.value(/*info:DYNAMIC_CAST*/x);
} | 691 Future<int> bar4() async { return new Future<int>.value(/*info:DYNAMIC_CAST*/x);
} |
| 695 Future<int> bar5() async { | 692 Future<int> bar5() async { |
| 696 return /*warning:RETURN_OF_INVALID_TYPE*/new Future<String>.value(/*info:DYNAM
IC_CAST*/x); | 693 return /*severe:RETURN_OF_INVALID_TYPE*/new Future<String>.value(/*info:DYNAMI
C_CAST*/x); |
| 697 } | 694 } |
| 698 | 695 |
| 699 int y; | 696 int y; |
| 700 Future<int> z; | 697 Future<int> z; |
| 701 | 698 |
| 702 baz() async { | 699 baz() async { |
| 703 int a = /*info:DYNAMIC_CAST*/await x; | 700 int a = /*info:DYNAMIC_CAST*/await x; |
| 704 int b = await y; | 701 int b = await y; |
| 705 int c = await z; | 702 int c = await z; |
| 706 String d = /*warning:INVALID_ASSIGNMENT*/await z; | 703 String d = /*severe:INVALID_ASSIGNMENT*/await z; |
| 707 } | 704 } |
| 708 | 705 |
| 709 Future<bool> get issue_264 async { | 706 Future<bool> get issue_264 async { |
| 710 await 42; | 707 await 42; |
| 711 if (new Random().nextBool()) { | 708 if (new Random().nextBool()) { |
| 712 return true; | 709 return true; |
| 713 } else { | 710 } else { |
| 714 return new Future<bool>.value(false); | 711 return new Future<bool>.value(false); |
| 715 } | 712 } |
| 716 } | 713 } |
| 717 '''); | 714 '''); |
| 718 } | 715 } |
| 719 | 716 |
| 720 void test_functionModifiers_asyncStar() { | 717 void test_functionModifiers_asyncStar() { |
| 721 checkFile(''' | 718 checkFile(''' |
| 722 import 'dart:async'; | 719 import 'dart:async'; |
| 723 | 720 |
| 724 dynamic x; | 721 dynamic x; |
| 725 | 722 |
| 726 bar1() async* { yield x; } | 723 bar1() async* { yield x; } |
| 727 Stream bar2() async* { yield x; } | 724 Stream bar2() async* { yield x; } |
| 728 Stream<int> bar3() async* { yield /*info:DYNAMIC_CAST*/x; } | 725 Stream<int> bar3() async* { yield /*info:DYNAMIC_CAST*/x; } |
| 729 Stream<int> bar4() async* { yield /*warning:YIELD_OF_INVALID_TYPE*/new Stream<in
t>(); } | 726 Stream<int> bar4() async* { yield /*severe:YIELD_OF_INVALID_TYPE*/new Stream<int
>(); } |
| 730 | 727 |
| 731 baz1() async* { yield* /*info:DYNAMIC_CAST*/x; } | 728 baz1() async* { yield* /*info:DYNAMIC_CAST*/x; } |
| 732 Stream baz2() async* { yield* /*info:DYNAMIC_CAST*/x; } | 729 Stream baz2() async* { yield* /*info:DYNAMIC_CAST*/x; } |
| 733 Stream<int> baz3() async* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } | 730 Stream<int> baz3() async* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } |
| 734 Stream<int> baz4() async* { yield* new Stream<int>(); } | 731 Stream<int> baz4() async* { yield* new Stream<int>(); } |
| 735 Stream<int> baz5() async* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new Stream()
; } | 732 Stream<int> baz5() async* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new Stream()
; } |
| 736 '''); | 733 '''); |
| 737 } | 734 } |
| 738 | 735 |
| 739 void test_functionModifiers_syncStar() { | 736 void test_functionModifiers_syncStar() { |
| 740 checkFile(''' | 737 checkFile(''' |
| 741 dynamic x; | 738 dynamic x; |
| 742 | 739 |
| 743 bar1() sync* { yield x; } | 740 bar1() sync* { yield x; } |
| 744 Iterable bar2() sync* { yield x; } | 741 Iterable bar2() sync* { yield x; } |
| 745 Iterable<int> bar3() sync* { yield /*info:DYNAMIC_CAST*/x; } | 742 Iterable<int> bar3() sync* { yield /*info:DYNAMIC_CAST*/x; } |
| 746 Iterable<int> bar4() sync* { yield /*warning:YIELD_OF_INVALID_TYPE*/bar3(); } | 743 Iterable<int> bar4() sync* { yield /*severe:YIELD_OF_INVALID_TYPE*/bar3(); } |
| 747 | 744 |
| 748 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } | 745 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } |
| 749 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } | 746 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } |
| 750 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } | 747 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } |
| 751 Iterable<int> baz4() sync* { yield* bar3(); } | 748 Iterable<int> baz4() sync* { yield* bar3(); } |
| 752 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List();
} | 749 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List();
} |
| 753 '''); | 750 '''); |
| 754 } | 751 } |
| 755 | 752 |
| 756 void test_functionTypingAndSubtyping_classes() { | 753 void test_functionTypingAndSubtyping_classes() { |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 FN n; | 1492 FN n; |
| 1496 FRR rr; | 1493 FRR rr; |
| 1497 FRO ro; | 1494 FRO ro; |
| 1498 FRN rn; | 1495 FRN rn; |
| 1499 FOO oo; | 1496 FOO oo; |
| 1500 FNN nn; | 1497 FNN nn; |
| 1501 FNNN nnn; | 1498 FNNN nnn; |
| 1502 | 1499 |
| 1503 r = r; | 1500 r = r; |
| 1504 r = o; | 1501 r = o; |
| 1505 r = /*warning:INVALID_ASSIGNMENT*/n; | 1502 r = /*severe:INVALID_ASSIGNMENT*/n; |
| 1506 r = /*warning:INVALID_ASSIGNMENT*/rr; | 1503 r = /*severe:INVALID_ASSIGNMENT*/rr; |
| 1507 r = ro; | 1504 r = ro; |
| 1508 r = rn; | 1505 r = rn; |
| 1509 r = oo; | 1506 r = oo; |
| 1510 r = /*warning:INVALID_ASSIGNMENT*/nn; | 1507 r = /*severe:INVALID_ASSIGNMENT*/nn; |
| 1511 r = /*warning:INVALID_ASSIGNMENT*/nnn; | 1508 r = /*severe:INVALID_ASSIGNMENT*/nnn; |
| 1512 | 1509 |
| 1513 o = /*warning:DOWN_CAST_COMPOSITE*/r; | 1510 o = /*warning:DOWN_CAST_COMPOSITE*/r; |
| 1514 o = o; | 1511 o = o; |
| 1515 o = /*warning:INVALID_ASSIGNMENT*/n; | 1512 o = /*severe:INVALID_ASSIGNMENT*/n; |
| 1516 o = /*warning:INVALID_ASSIGNMENT*/rr; | 1513 o = /*severe:INVALID_ASSIGNMENT*/rr; |
| 1517 o = /*warning:INVALID_ASSIGNMENT*/ro; | 1514 o = /*severe:INVALID_ASSIGNMENT*/ro; |
| 1518 o = /*warning:INVALID_ASSIGNMENT*/rn; | 1515 o = /*severe:INVALID_ASSIGNMENT*/rn; |
| 1519 o = oo; | 1516 o = oo; |
| 1520 o = /*warning:INVALID_ASSIGNMENT*/nn; | 1517 o = /*severe:INVALID_ASSIGNMENT*/nn; |
| 1521 o = /*warning:INVALID_ASSIGNMENT*/nnn; | 1518 o = /*severe:INVALID_ASSIGNMENT*/nnn; |
| 1522 | 1519 |
| 1523 n = /*warning:INVALID_ASSIGNMENT*/r; | 1520 n = /*severe:INVALID_ASSIGNMENT*/r; |
| 1524 n = /*warning:INVALID_ASSIGNMENT*/o; | 1521 n = /*severe:INVALID_ASSIGNMENT*/o; |
| 1525 n = n; | 1522 n = n; |
| 1526 n = /*warning:INVALID_ASSIGNMENT*/rr; | 1523 n = /*severe:INVALID_ASSIGNMENT*/rr; |
| 1527 n = /*warning:INVALID_ASSIGNMENT*/ro; | 1524 n = /*severe:INVALID_ASSIGNMENT*/ro; |
| 1528 n = /*warning:INVALID_ASSIGNMENT*/rn; | 1525 n = /*severe:INVALID_ASSIGNMENT*/rn; |
| 1529 n = /*warning:INVALID_ASSIGNMENT*/oo; | 1526 n = /*severe:INVALID_ASSIGNMENT*/oo; |
| 1530 n = nn; | 1527 n = nn; |
| 1531 n = nnn; | 1528 n = nnn; |
| 1532 | 1529 |
| 1533 rr = /*warning:INVALID_ASSIGNMENT*/r; | 1530 rr = /*severe:INVALID_ASSIGNMENT*/r; |
| 1534 rr = /*warning:INVALID_ASSIGNMENT*/o; | 1531 rr = /*severe:INVALID_ASSIGNMENT*/o; |
| 1535 rr = /*warning:INVALID_ASSIGNMENT*/n; | 1532 rr = /*severe:INVALID_ASSIGNMENT*/n; |
| 1536 rr = rr; | 1533 rr = rr; |
| 1537 rr = ro; | 1534 rr = ro; |
| 1538 rr = /*warning:INVALID_ASSIGNMENT*/rn; | 1535 rr = /*severe:INVALID_ASSIGNMENT*/rn; |
| 1539 rr = oo; | 1536 rr = oo; |
| 1540 rr = /*warning:INVALID_ASSIGNMENT*/nn; | 1537 rr = /*severe:INVALID_ASSIGNMENT*/nn; |
| 1541 rr = /*warning:INVALID_ASSIGNMENT*/nnn; | 1538 rr = /*severe:INVALID_ASSIGNMENT*/nnn; |
| 1542 | 1539 |
| 1543 ro = /*warning:DOWN_CAST_COMPOSITE*/r; | 1540 ro = /*warning:DOWN_CAST_COMPOSITE*/r; |
| 1544 ro = /*warning:INVALID_ASSIGNMENT*/o; | 1541 ro = /*severe:INVALID_ASSIGNMENT*/o; |
| 1545 ro = /*warning:INVALID_ASSIGNMENT*/n; | 1542 ro = /*severe:INVALID_ASSIGNMENT*/n; |
| 1546 ro = /*warning:DOWN_CAST_COMPOSITE*/rr; | 1543 ro = /*warning:DOWN_CAST_COMPOSITE*/rr; |
| 1547 ro = ro; | 1544 ro = ro; |
| 1548 ro = /*warning:INVALID_ASSIGNMENT*/rn; | 1545 ro = /*severe:INVALID_ASSIGNMENT*/rn; |
| 1549 ro = oo; | 1546 ro = oo; |
| 1550 ro = /*warning:INVALID_ASSIGNMENT*/nn; | 1547 ro = /*severe:INVALID_ASSIGNMENT*/nn; |
| 1551 ro = /*warning:INVALID_ASSIGNMENT*/nnn; | 1548 ro = /*severe:INVALID_ASSIGNMENT*/nnn; |
| 1552 | 1549 |
| 1553 rn = /*warning:DOWN_CAST_COMPOSITE*/r; | 1550 rn = /*warning:DOWN_CAST_COMPOSITE*/r; |
| 1554 rn = /*warning:INVALID_ASSIGNMENT*/o; | 1551 rn = /*severe:INVALID_ASSIGNMENT*/o; |
| 1555 rn = /*warning:INVALID_ASSIGNMENT*/n; | 1552 rn = /*severe:INVALID_ASSIGNMENT*/n; |
| 1556 rn = /*warning:INVALID_ASSIGNMENT*/rr; | 1553 rn = /*severe:INVALID_ASSIGNMENT*/rr; |
| 1557 rn = /*warning:INVALID_ASSIGNMENT*/ro; | 1554 rn = /*severe:INVALID_ASSIGNMENT*/ro; |
| 1558 rn = rn; | 1555 rn = rn; |
| 1559 rn = /*warning:INVALID_ASSIGNMENT*/oo; | 1556 rn = /*severe:INVALID_ASSIGNMENT*/oo; |
| 1560 rn = /*warning:INVALID_ASSIGNMENT*/nn; | 1557 rn = /*severe:INVALID_ASSIGNMENT*/nn; |
| 1561 rn = /*warning:INVALID_ASSIGNMENT*/nnn; | 1558 rn = /*severe:INVALID_ASSIGNMENT*/nnn; |
| 1562 | 1559 |
| 1563 oo = /*warning:DOWN_CAST_COMPOSITE*/r; | 1560 oo = /*warning:DOWN_CAST_COMPOSITE*/r; |
| 1564 oo = /*warning:DOWN_CAST_COMPOSITE*/o; | 1561 oo = /*warning:DOWN_CAST_COMPOSITE*/o; |
| 1565 oo = /*warning:INVALID_ASSIGNMENT*/n; | 1562 oo = /*severe:INVALID_ASSIGNMENT*/n; |
| 1566 oo = /*warning:DOWN_CAST_COMPOSITE*/rr; | 1563 oo = /*warning:DOWN_CAST_COMPOSITE*/rr; |
| 1567 oo = /*warning:DOWN_CAST_COMPOSITE*/ro; | 1564 oo = /*warning:DOWN_CAST_COMPOSITE*/ro; |
| 1568 oo = /*warning:INVALID_ASSIGNMENT*/rn; | 1565 oo = /*severe:INVALID_ASSIGNMENT*/rn; |
| 1569 oo = oo; | 1566 oo = oo; |
| 1570 oo = /*warning:INVALID_ASSIGNMENT*/nn; | 1567 oo = /*severe:INVALID_ASSIGNMENT*/nn; |
| 1571 oo = /*warning:INVALID_ASSIGNMENT*/nnn; | 1568 oo = /*severe:INVALID_ASSIGNMENT*/nnn; |
| 1572 | 1569 |
| 1573 nn = /*warning:INVALID_ASSIGNMENT*/r; | 1570 nn = /*severe:INVALID_ASSIGNMENT*/r; |
| 1574 nn = /*warning:INVALID_ASSIGNMENT*/o; | 1571 nn = /*severe:INVALID_ASSIGNMENT*/o; |
| 1575 nn = /*warning:DOWN_CAST_COMPOSITE*/n; | 1572 nn = /*warning:DOWN_CAST_COMPOSITE*/n; |
| 1576 nn = /*warning:INVALID_ASSIGNMENT*/rr; | 1573 nn = /*severe:INVALID_ASSIGNMENT*/rr; |
| 1577 nn = /*warning:INVALID_ASSIGNMENT*/ro; | 1574 nn = /*severe:INVALID_ASSIGNMENT*/ro; |
| 1578 nn = /*warning:INVALID_ASSIGNMENT*/rn; | 1575 nn = /*severe:INVALID_ASSIGNMENT*/rn; |
| 1579 nn = /*warning:INVALID_ASSIGNMENT*/oo; | 1576 nn = /*severe:INVALID_ASSIGNMENT*/oo; |
| 1580 nn = nn; | 1577 nn = nn; |
| 1581 nn = nnn; | 1578 nn = nnn; |
| 1582 | 1579 |
| 1583 nnn = /*warning:INVALID_ASSIGNMENT*/r; | 1580 nnn = /*severe:INVALID_ASSIGNMENT*/r; |
| 1584 nnn = /*warning:INVALID_ASSIGNMENT*/o; | 1581 nnn = /*severe:INVALID_ASSIGNMENT*/o; |
| 1585 nnn = /*warning:DOWN_CAST_COMPOSITE*/n; | 1582 nnn = /*warning:DOWN_CAST_COMPOSITE*/n; |
| 1586 nnn = /*warning:INVALID_ASSIGNMENT*/rr; | 1583 nnn = /*severe:INVALID_ASSIGNMENT*/rr; |
| 1587 nnn = /*warning:INVALID_ASSIGNMENT*/ro; | 1584 nnn = /*severe:INVALID_ASSIGNMENT*/ro; |
| 1588 nnn = /*warning:INVALID_ASSIGNMENT*/rn; | 1585 nnn = /*severe:INVALID_ASSIGNMENT*/rn; |
| 1589 nnn = /*warning:INVALID_ASSIGNMENT*/oo; | 1586 nnn = /*severe:INVALID_ASSIGNMENT*/oo; |
| 1590 nnn = /*warning:DOWN_CAST_COMPOSITE*/nn; | 1587 nnn = /*warning:DOWN_CAST_COMPOSITE*/nn; |
| 1591 nnn = nnn; | 1588 nnn = nnn; |
| 1592 } | 1589 } |
| 1593 '''); | 1590 '''); |
| 1594 } | 1591 } |
| 1595 | 1592 |
| 1596 void test_functionTypingAndSubtyping_objectsWithCallMethods() { | 1593 void test_functionTypingAndSubtyping_objectsWithCallMethods() { |
| 1597 checkFile(''' | 1594 checkFile(''' |
| 1598 typedef int I2I(int x); | 1595 typedef int I2I(int x); |
| 1599 typedef num N2N(num x); | 1596 typedef num N2N(num x); |
| 1600 class A { | 1597 class A { |
| 1601 int call(int x) => x; | 1598 int call(int x) => x; |
| 1602 } | 1599 } |
| 1603 class B { | 1600 class B { |
| 1604 num call(num x) => x; | 1601 num call(num x) => x; |
| 1605 } | 1602 } |
| 1606 int i2i(int x) => x; | 1603 int i2i(int x) => x; |
| 1607 num n2n(num x) => x; | 1604 num n2n(num x) => x; |
| 1608 void main() { | 1605 void main() { |
| 1609 { | 1606 { |
| 1610 I2I f; | 1607 I2I f; |
| 1611 f = new A(); | 1608 f = new A(); |
| 1612 f = /*warning:INVALID_ASSIGNMENT*/new B(); | 1609 f = /*severe:INVALID_ASSIGNMENT*/new B(); |
| 1613 f = i2i; | 1610 f = i2i; |
| 1614 f = /*severe:STATIC_TYPE_ERROR*/n2n; | 1611 f = /*severe:STATIC_TYPE_ERROR*/n2n; |
| 1615 f = /*warning:DOWN_CAST_COMPOSITE*/i2i as Object; | 1612 f = /*warning:DOWN_CAST_COMPOSITE*/i2i as Object; |
| 1616 f = /*warning:DOWN_CAST_COMPOSITE*/n2n as Function; | 1613 f = /*warning:DOWN_CAST_COMPOSITE*/n2n as Function; |
| 1617 } | 1614 } |
| 1618 { | 1615 { |
| 1619 N2N f; | 1616 N2N f; |
| 1620 f = /*warning:INVALID_ASSIGNMENT*/new A(); | 1617 f = /*severe:INVALID_ASSIGNMENT*/new A(); |
| 1621 f = new B(); | 1618 f = new B(); |
| 1622 f = /*severe:STATIC_TYPE_ERROR*/i2i; | 1619 f = /*severe:STATIC_TYPE_ERROR*/i2i; |
| 1623 f = n2n; | 1620 f = n2n; |
| 1624 f = /*warning:DOWN_CAST_COMPOSITE*/i2i as Object; | 1621 f = /*warning:DOWN_CAST_COMPOSITE*/i2i as Object; |
| 1625 f = /*warning:DOWN_CAST_COMPOSITE*/n2n as Function; | 1622 f = /*warning:DOWN_CAST_COMPOSITE*/n2n as Function; |
| 1626 } | 1623 } |
| 1627 { | 1624 { |
| 1628 A f; | 1625 A f; |
| 1629 f = new A(); | 1626 f = new A(); |
| 1630 f = /*warning:INVALID_ASSIGNMENT*/new B(); | 1627 f = /*severe:INVALID_ASSIGNMENT*/new B(); |
| 1631 f = /*warning:INVALID_ASSIGNMENT*/i2i; | 1628 f = /*severe:INVALID_ASSIGNMENT*/i2i; |
| 1632 f = /*warning:INVALID_ASSIGNMENT*/n2n; | 1629 f = /*severe:INVALID_ASSIGNMENT*/n2n; |
| 1633 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; | 1630 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; |
| 1634 f = /*info:DOWN_CAST_IMPLICIT*/n2n as Function; | 1631 f = /*info:DOWN_CAST_IMPLICIT*/n2n as Function; |
| 1635 } | 1632 } |
| 1636 { | 1633 { |
| 1637 B f; | 1634 B f; |
| 1638 f = /*warning:INVALID_ASSIGNMENT*/new A(); | 1635 f = /*severe:INVALID_ASSIGNMENT*/new A(); |
| 1639 f = new B(); | 1636 f = new B(); |
| 1640 f = /*warning:INVALID_ASSIGNMENT*/i2i; | 1637 f = /*severe:INVALID_ASSIGNMENT*/i2i; |
| 1641 f = /*warning:INVALID_ASSIGNMENT*/n2n; | 1638 f = /*severe:INVALID_ASSIGNMENT*/n2n; |
| 1642 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; | 1639 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; |
| 1643 f = /*info:DOWN_CAST_IMPLICIT*/n2n as Function; | 1640 f = /*info:DOWN_CAST_IMPLICIT*/n2n as Function; |
| 1644 } | 1641 } |
| 1645 { | 1642 { |
| 1646 Function f; | 1643 Function f; |
| 1647 f = new A(); | 1644 f = new A(); |
| 1648 f = new B(); | 1645 f = new B(); |
| 1649 f = i2i; | 1646 f = i2i; |
| 1650 f = n2n; | 1647 f = n2n; |
| 1651 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; | 1648 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 void main() { | 1704 void main() { |
| 1708 nonGenericFn(x) => null; | 1705 nonGenericFn(x) => null; |
| 1709 { | 1706 { |
| 1710 /*=R*/ f/*<P, R>*/(/*=P*/ p) => null; | 1707 /*=R*/ f/*<P, R>*/(/*=P*/ p) => null; |
| 1711 /*=T*/ g/*<S, T>*/(/*=S*/ s) => null; | 1708 /*=T*/ g/*<S, T>*/(/*=S*/ s) => null; |
| 1712 | 1709 |
| 1713 var local = f; | 1710 var local = f; |
| 1714 local = g; // valid | 1711 local = g; // valid |
| 1715 | 1712 |
| 1716 // Non-generic function cannot subtype a generic one. | 1713 // Non-generic function cannot subtype a generic one. |
| 1717 local = /*warning:INVALID_ASSIGNMENT*/(x) => null; | 1714 local = /*severe:INVALID_ASSIGNMENT*/(x) => null; |
| 1718 local = /*warning:INVALID_ASSIGNMENT*/nonGenericFn; | 1715 local = /*severe:INVALID_ASSIGNMENT*/nonGenericFn; |
| 1719 } | 1716 } |
| 1720 { | 1717 { |
| 1721 Iterable/*<R>*/ f/*<P, R>*/(List/*<P>*/ p) => null; | 1718 Iterable/*<R>*/ f/*<P, R>*/(List/*<P>*/ p) => null; |
| 1722 List/*<T>*/ g/*<S, T>*/(Iterable/*<S>*/ s) => null; | 1719 List/*<T>*/ g/*<S, T>*/(Iterable/*<S>*/ s) => null; |
| 1723 | 1720 |
| 1724 var local = f; | 1721 var local = f; |
| 1725 local = g; // valid | 1722 local = g; // valid |
| 1726 | 1723 |
| 1727 var local2 = g; | 1724 var local2 = g; |
| 1728 local = local2; | 1725 local = local2; |
| 1729 local2 = /*severe:STATIC_TYPE_ERROR*/f; | 1726 local2 = /*severe:STATIC_TYPE_ERROR*/f; |
| 1730 local2 = /*warning:DOWN_CAST_COMPOSITE*/local; | 1727 local2 = /*warning:DOWN_CAST_COMPOSITE*/local; |
| 1731 | 1728 |
| 1732 // Non-generic function cannot subtype a generic one. | 1729 // Non-generic function cannot subtype a generic one. |
| 1733 local = /*warning:INVALID_ASSIGNMENT*/(x) => null; | 1730 local = /*severe:INVALID_ASSIGNMENT*/(x) => null; |
| 1734 local = /*warning:INVALID_ASSIGNMENT*/nonGenericFn; | 1731 local = /*severe:INVALID_ASSIGNMENT*/nonGenericFn; |
| 1735 } | 1732 } |
| 1736 } | 1733 } |
| 1737 '''); | 1734 '''); |
| 1738 } | 1735 } |
| 1739 | 1736 |
| 1740 void test_functionTypingAndSubtyping_uninferredClosure() { | 1737 void test_functionTypingAndSubtyping_uninferredClosure() { |
| 1741 checkFile(''' | 1738 checkFile(''' |
| 1742 typedef num Num2Num(num x); | 1739 typedef num Num2Num(num x); |
| 1743 void main() { | 1740 void main() { |
| 1744 Num2Num g = /*info:INFERRED_TYPE_CLOSURE,severe:STATIC_TYPE_ERROR*/(int x) { r
eturn x; }; | 1741 Num2Num g = /*info:INFERRED_TYPE_CLOSURE,severe:STATIC_TYPE_ERROR*/(int x) { r
eturn x; }; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 checkFile(''' | 1870 checkFile(''' |
| 1874 main() { | 1871 main() { |
| 1875 dynamic dyn = 42; | 1872 dynamic dyn = 42; |
| 1876 Object obj = 42; | 1873 Object obj = 42; |
| 1877 int i = 42; | 1874 int i = 42; |
| 1878 bool b = false; | 1875 bool b = false; |
| 1879 | 1876 |
| 1880 if (b) {} | 1877 if (b) {} |
| 1881 if (/*info:DYNAMIC_CAST*/dyn) {} | 1878 if (/*info:DYNAMIC_CAST*/dyn) {} |
| 1882 if (/*info:DOWN_CAST_IMPLICIT*/obj) {} | 1879 if (/*info:DOWN_CAST_IMPLICIT*/obj) {} |
| 1883 if (/*warning:NON_BOOL_CONDITION*/i) {} | 1880 if (/*severe:NON_BOOL_CONDITION*/i) {} |
| 1884 | 1881 |
| 1885 while (b) {} | 1882 while (b) {} |
| 1886 while (/*info:DYNAMIC_CAST*/dyn) {} | 1883 while (/*info:DYNAMIC_CAST*/dyn) {} |
| 1887 while (/*info:DOWN_CAST_IMPLICIT*/obj) {} | 1884 while (/*info:DOWN_CAST_IMPLICIT*/obj) {} |
| 1888 while (/*warning:NON_BOOL_CONDITION*/i) {} | 1885 while (/*severe:NON_BOOL_CONDITION*/i) {} |
| 1889 | 1886 |
| 1890 do {} while (b); | 1887 do {} while (b); |
| 1891 do {} while (/*info:DYNAMIC_CAST*/dyn); | 1888 do {} while (/*info:DYNAMIC_CAST*/dyn); |
| 1892 do {} while (/*info:DOWN_CAST_IMPLICIT*/obj); | 1889 do {} while (/*info:DOWN_CAST_IMPLICIT*/obj); |
| 1893 do {} while (/*warning:NON_BOOL_CONDITION*/i); | 1890 do {} while (/*severe:NON_BOOL_CONDITION*/i); |
| 1894 | 1891 |
| 1895 for (;b;) {} | 1892 for (;b;) {} |
| 1896 for (;/*info:DYNAMIC_CAST*/dyn;) {} | 1893 for (;/*info:DYNAMIC_CAST*/dyn;) {} |
| 1897 for (;/*info:DOWN_CAST_IMPLICIT*/obj;) {} | 1894 for (;/*info:DOWN_CAST_IMPLICIT*/obj;) {} |
| 1898 for (;/*warning:NON_BOOL_CONDITION*/i;) {} | 1895 for (;/*severe:NON_BOOL_CONDITION*/i;) {} |
| 1899 } | 1896 } |
| 1900 '''); | 1897 '''); |
| 1901 } | 1898 } |
| 1902 | 1899 |
| 1903 void test_implicitCasts() { | 1900 void test_implicitCasts() { |
| 1904 addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;'); | 1901 addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;'); |
| 1905 check(); | 1902 check(); |
| 1906 addFile('num n; int i = /*severe:ASSIGNMENT_CAST*/n;'); | 1903 // TODO(jmesserly): should not be emitting the hint as well as the error. |
| 1904 addFile( |
| 1905 'num n; int i = /*info:ASSIGNMENT_CAST,severe:INVALID_ASSIGNMENT*/n;'); |
| 1907 check(implicitCasts: false); | 1906 check(implicitCasts: false); |
| 1908 } | 1907 } |
| 1909 | 1908 |
| 1910 void test_invalidOverrides_baseClassOverrideToChildInterface() { | 1909 void test_invalidOverrides_baseClassOverrideToChildInterface() { |
| 1911 checkFile(''' | 1910 checkFile(''' |
| 1912 class A {} | 1911 class A {} |
| 1913 class B {} | 1912 class B {} |
| 1914 | 1913 |
| 1915 abstract class I { | 1914 abstract class I { |
| 1916 m(A a); | 1915 m(A a); |
| 1917 } | 1916 } |
| 1918 | 1917 |
| 1919 class Base { | 1918 class Base { |
| 1920 m(B a) {} | 1919 m(B a) {} |
| 1921 } | 1920 } |
| 1922 | 1921 |
| 1923 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 1922 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 1924 /*severe:INVALID_METHOD_OVERRIDE*/extends Base implements I {} | 1923 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base implements I {} |
| 1925 '''); | 1924 '''); |
| 1926 } | 1925 } |
| 1927 | 1926 |
| 1928 void test_invalidOverrides_childOverride() { | 1927 void test_invalidOverrides_childOverride() { |
| 1929 checkFile(''' | 1928 checkFile(''' |
| 1930 class A {} | 1929 class A {} |
| 1931 class B {} | 1930 class B {} |
| 1932 | 1931 |
| 1933 class Base { | 1932 class Base { |
| 1934 A f; | 1933 A f; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 class B {} | 2072 class B {} |
| 2074 | 2073 |
| 2075 abstract class I { | 2074 abstract class I { |
| 2076 m(A a); | 2075 m(A a); |
| 2077 } | 2076 } |
| 2078 | 2077 |
| 2079 class M { | 2078 class M { |
| 2080 m(B a) {} | 2079 m(B a) {} |
| 2081 } | 2080 } |
| 2082 | 2081 |
| 2083 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2082 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2084 extends Object with /*severe:INVALID_METHOD_OVERRIDE*/M | 2083 extends Object with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M |
| 2085 implements I {} | 2084 implements I {} |
| 2086 '''); | 2085 '''); |
| 2087 } | 2086 } |
| 2088 | 2087 |
| 2089 void test_invalidOverrides_mixinOverrideToBase() { | 2088 void test_invalidOverrides_mixinOverrideToBase() { |
| 2090 checkFile(''' | 2089 checkFile(''' |
| 2091 class A {} | 2090 class A {} |
| 2092 class B {} | 2091 class B {} |
| 2093 | 2092 |
| 2094 class Base { | 2093 class Base { |
| 2095 m(A a) {} | 2094 m(A a) {} |
| 2096 int x; | 2095 int x; |
| 2097 } | 2096 } |
| 2098 | 2097 |
| 2099 class M1 { | 2098 class M1 { |
| 2100 m(B a) {} | 2099 m(B a) {} |
| 2101 } | 2100 } |
| 2102 | 2101 |
| 2103 class M2 { | 2102 class M2 { |
| 2104 int x; | 2103 int x; |
| 2105 } | 2104 } |
| 2106 | 2105 |
| 2107 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base | 2106 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base |
| 2108 with /*severe:INVALID_METHOD_OVERRIDE*/M1 {} | 2107 with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M1 {} |
| 2109 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T2 extends Base | 2108 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T2 extends Base |
| 2110 with /*severe:INVALID_METHOD_OVERRIDE*/M1, /*severe:INVALID_FIELD_OVERRIDE*/
M2 {} | 2109 with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M1, /*severe:INVALID_FIELD
_OVERRIDE*/M2 {} |
| 2111 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T3 extends Base | 2110 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T3 extends Base |
| 2112 with /*severe:INVALID_FIELD_OVERRIDE*/M2, /*severe:INVALID_METHOD_OVERRIDE*/
M1 {} | 2111 with /*severe:INVALID_FIELD_OVERRIDE*/M2, /*severe:INVALID_METHOD_OVERRIDE_F
ROM_MIXIN*/M1 {} |
| 2113 '''); | 2112 '''); |
| 2114 } | 2113 } |
| 2115 | 2114 |
| 2116 void test_invalidOverrides_mixinOverrideToMixin() { | 2115 void test_invalidOverrides_mixinOverrideToMixin() { |
| 2117 checkFile(''' | 2116 checkFile(''' |
| 2118 class A {} | 2117 class A {} |
| 2119 class B {} | 2118 class B {} |
| 2120 | 2119 |
| 2121 class Base { | 2120 class Base { |
| 2122 } | 2121 } |
| 2123 | 2122 |
| 2124 class M1 { | 2123 class M1 { |
| 2125 m(B a) {} | 2124 m(B a) {} |
| 2126 int x; | 2125 int x; |
| 2127 } | 2126 } |
| 2128 | 2127 |
| 2129 class M2 { | 2128 class M2 { |
| 2130 m(A a) {} | 2129 m(A a) {} |
| 2131 int x; | 2130 int x; |
| 2132 } | 2131 } |
| 2133 | 2132 |
| 2134 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base | 2133 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base |
| 2135 with M1, | 2134 with M1, |
| 2136 /*severe:INVALID_METHOD_OVERRIDE,severe:INVALID_FIELD_OVERRIDE*/M2 {} | 2135 /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN,severe:INVALID_FIELD_OVERRIDE*/M
2 {} |
| 2137 '''); | 2136 '''); |
| 2138 } | 2137 } |
| 2139 | 2138 |
| 2140 void test_invalidOverrides_noDuplicateMixinOverride() { | 2139 void test_invalidOverrides_noDuplicateMixinOverride() { |
| 2141 // This is a regression test for a bug in an earlier implementation were | 2140 // This is a regression test for a bug in an earlier implementation were |
| 2142 // names were hiding errors if the first mixin override looked correct, | 2141 // names were hiding errors if the first mixin override looked correct, |
| 2143 // but subsequent ones did not. | 2142 // but subsequent ones did not. |
| 2144 checkFile(''' | 2143 checkFile(''' |
| 2145 class A {} | 2144 class A {} |
| 2146 class B {} | 2145 class B {} |
| 2147 | 2146 |
| 2148 class Base { | 2147 class Base { |
| 2149 m(A a) {} | 2148 m(A a) {} |
| 2150 } | 2149 } |
| 2151 | 2150 |
| 2152 class M1 { | 2151 class M1 { |
| 2153 m(A a) {} | 2152 m(A a) {} |
| 2154 } | 2153 } |
| 2155 | 2154 |
| 2156 class M2 { | 2155 class M2 { |
| 2157 m(B a) {} | 2156 m(B a) {} |
| 2158 } | 2157 } |
| 2159 | 2158 |
| 2160 class M3 { | 2159 class M3 { |
| 2161 m(B a) {} | 2160 m(B a) {} |
| 2162 } | 2161 } |
| 2163 | 2162 |
| 2164 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base | 2163 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base |
| 2165 with M1, /*severe:INVALID_METHOD_OVERRIDE*/M2, M3 {} | 2164 with M1, /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M2, M3 {} |
| 2166 '''); | 2165 '''); |
| 2167 } | 2166 } |
| 2168 | 2167 |
| 2169 void | 2168 void |
| 2170 test_invalidOverrides_noErrorsIfSubclassCorrectlyOverrideBaseAndInterface(
) { | 2169 test_invalidOverrides_noErrorsIfSubclassCorrectlyOverrideBaseAndInterface(
) { |
| 2171 // This is a case were it is incorrect to say that the base class | 2170 // This is a case were it is incorrect to say that the base class |
| 2172 // incorrectly overrides the interface. | 2171 // incorrectly overrides the interface. |
| 2173 checkFile(''' | 2172 checkFile(''' |
| 2174 class A {} | 2173 class A {} |
| 2175 class B {} | 2174 class B {} |
| 2176 | 2175 |
| 2177 class Base { | 2176 class Base { |
| 2178 m(A a) {} | 2177 m(A a) {} |
| 2179 } | 2178 } |
| 2180 | 2179 |
| 2181 class I1 { | 2180 class I1 { |
| 2182 m(B a) {} | 2181 m(B a) {} |
| 2183 } | 2182 } |
| 2184 | 2183 |
| 2185 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2184 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2186 /*severe:INVALID_METHOD_OVERRIDE*/extends Base | 2185 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base |
| 2187 implements I1 {} | 2186 implements I1 {} |
| 2188 | 2187 |
| 2189 class T2 extends Base implements I1 { | 2188 class T2 extends Base implements I1 { |
| 2190 m(a) {} | 2189 m(a) {} |
| 2191 } | 2190 } |
| 2192 | 2191 |
| 2193 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T3 | 2192 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T3 |
| 2194 extends Object with /*severe:INVALID_METHOD_OVERRIDE*/Base | 2193 extends Object with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/Base |
| 2195 implements I1 {} | 2194 implements I1 {} |
| 2196 | 2195 |
| 2197 class T4 extends Object with Base implements I1 { | 2196 class T4 extends Object with Base implements I1 { |
| 2198 m(a) {} | 2197 m(a) {} |
| 2199 } | 2198 } |
| 2200 '''); | 2199 '''); |
| 2201 } | 2200 } |
| 2202 | 2201 |
| 2203 void test_invalidRuntimeChecks() { | 2202 void test_invalidRuntimeChecks() { |
| 2204 checkFile(''' | 2203 checkFile(''' |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2257 void test_leastUpperBounds() { | 2256 void test_leastUpperBounds() { |
| 2258 checkFile(''' | 2257 checkFile(''' |
| 2259 typedef T Returns<T>(); | 2258 typedef T Returns<T>(); |
| 2260 | 2259 |
| 2261 // regression test for https://github.com/dart-lang/sdk/issues/26094 | 2260 // regression test for https://github.com/dart-lang/sdk/issues/26094 |
| 2262 class A <S extends Returns<S>, T extends Returns<T>> { | 2261 class A <S extends Returns<S>, T extends Returns<T>> { |
| 2263 int test(bool b) { | 2262 int test(bool b) { |
| 2264 S s; | 2263 S s; |
| 2265 T t; | 2264 T t; |
| 2266 if (b) { | 2265 if (b) { |
| 2267 return /*warning:RETURN_OF_INVALID_TYPE*/b ? s : t; | 2266 return /*severe:RETURN_OF_INVALID_TYPE*/b ? s : t; |
| 2268 } else { | 2267 } else { |
| 2269 return /*warning:RETURN_OF_INVALID_TYPE*/s ?? t; | 2268 return /*severe:RETURN_OF_INVALID_TYPE*/s ?? t; |
| 2270 } | 2269 } |
| 2271 } | 2270 } |
| 2272 } | 2271 } |
| 2273 | 2272 |
| 2274 class B<S, T extends S> { | 2273 class B<S, T extends S> { |
| 2275 T t; | 2274 T t; |
| 2276 S s; | 2275 S s; |
| 2277 int test(bool b) { | 2276 int test(bool b) { |
| 2278 return /*warning:RETURN_OF_INVALID_TYPE*/b ? t : s; | 2277 return /*severe:RETURN_OF_INVALID_TYPE*/b ? t : s; |
| 2279 } | 2278 } |
| 2280 } | 2279 } |
| 2281 | 2280 |
| 2282 class C { | 2281 class C { |
| 2283 // Check that the least upper bound of two types with the same | 2282 // Check that the least upper bound of two types with the same |
| 2284 // class but different type arguments produces the pointwise | 2283 // class but different type arguments produces the pointwise |
| 2285 // least upper bound of the type arguments | 2284 // least upper bound of the type arguments |
| 2286 int test1(bool b) { | 2285 int test1(bool b) { |
| 2287 List<int> li; | 2286 List<int> li; |
| 2288 List<double> ld; | 2287 List<double> ld; |
| 2289 return /*warning:RETURN_OF_INVALID_TYPE*/b ? li : ld; | 2288 return /*severe:RETURN_OF_INVALID_TYPE*/b ? li : ld; |
| 2290 } | 2289 } |
| 2291 // TODO(leafp): This case isn't handled yet. This test checks | 2290 // TODO(leafp): This case isn't handled yet. This test checks |
| 2292 // the case where two related classes are instantiated with related | 2291 // the case where two related classes are instantiated with related |
| 2293 // but different types. | 2292 // but different types. |
| 2294 Iterable<num> test2(bool b) { | 2293 Iterable<num> test2(bool b) { |
| 2295 List<int> li; | 2294 List<int> li; |
| 2296 Iterable<double> id; | 2295 Iterable<double> id; |
| 2297 int x = | 2296 int x = |
| 2298 /*info:ASSIGNMENT_CAST should be warning:INVALID_ASSIGNMENT*/ | 2297 /*info:ASSIGNMENT_CAST should be severe:INVALID_ASSIGNMENT*/ |
| 2299 b ? li : id; | 2298 b ? li : id; |
| 2300 return /*warning:DOWN_CAST_COMPOSITE should be pass*/b ? li : id; | 2299 return /*warning:DOWN_CAST_COMPOSITE should be pass*/b ? li : id; |
| 2301 } | 2300 } |
| 2302 } | 2301 } |
| 2303 '''); | 2302 '''); |
| 2304 } | 2303 } |
| 2305 | 2304 |
| 2306 void test_loadLibrary() { | 2305 void test_loadLibrary() { |
| 2307 addFile('''library lib1;''', name: '/lib1.dart'); | 2306 addFile('''library lib1;''', name: '/lib1.dart'); |
| 2308 checkFile(r''' | 2307 checkFile(r''' |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 | 2370 |
| 2372 abstract class I1 { | 2371 abstract class I1 { |
| 2373 m(A a); | 2372 m(A a); |
| 2374 } | 2373 } |
| 2375 abstract class Base implements I1 {} | 2374 abstract class Base implements I1 {} |
| 2376 | 2375 |
| 2377 class M { | 2376 class M { |
| 2378 m(B a) {} | 2377 m(B a) {} |
| 2379 } | 2378 } |
| 2380 | 2379 |
| 2381 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base | 2380 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base |
| 2382 with /*severe:INVALID_METHOD_OVERRIDE*/M {} | 2381 with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M {} |
| 2383 '''); | 2382 '''); |
| 2384 } | 2383 } |
| 2385 | 2384 |
| 2386 void test_mixinOverrideOfGrandInterface_interfaceOfConcreteSuperclass() { | 2385 void test_mixinOverrideOfGrandInterface_interfaceOfConcreteSuperclass() { |
| 2387 checkFile(''' | 2386 checkFile(''' |
| 2388 class A {} | 2387 class A {} |
| 2389 class B {} | 2388 class B {} |
| 2390 | 2389 |
| 2391 abstract class I1 { | 2390 abstract class I1 { |
| 2392 m(A a); | 2391 m(A a); |
| 2393 } | 2392 } |
| 2394 | 2393 |
| 2395 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/Base | 2394 class /*warning:NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE*/Base |
| 2396 implements I1 {} | 2395 implements I1 {} |
| 2397 | 2396 |
| 2398 class M { | 2397 class M { |
| 2399 m(B a) {} | 2398 m(B a) {} |
| 2400 } | 2399 } |
| 2401 | 2400 |
| 2402 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base | 2401 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Base |
| 2403 with M {} | 2402 with M {} |
| 2404 '''); | 2403 '''); |
| 2405 } | 2404 } |
| 2406 | 2405 |
| 2407 void test_mixinOverrideOfGrandInterface_interfaceOfInterfaceOfChild() { | 2406 void test_mixinOverrideOfGrandInterface_interfaceOfInterfaceOfChild() { |
| 2408 checkFile(''' | 2407 checkFile(''' |
| 2409 class A {} | 2408 class A {} |
| 2410 class B {} | 2409 class B {} |
| 2411 | 2410 |
| 2412 abstract class I1 { | 2411 abstract class I1 { |
| 2413 m(A a); | 2412 m(A a); |
| 2414 } | 2413 } |
| 2415 abstract class I2 implements I1 {} | 2414 abstract class I2 implements I1 {} |
| 2416 | 2415 |
| 2417 class M { | 2416 class M { |
| 2418 m(B a) {} | 2417 m(B a) {} |
| 2419 } | 2418 } |
| 2420 | 2419 |
| 2421 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2420 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2422 extends Object with /*severe:INVALID_METHOD_OVERRIDE*/M | 2421 extends Object with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M |
| 2423 implements I2 {} | 2422 implements I2 {} |
| 2424 '''); | 2423 '''); |
| 2425 } | 2424 } |
| 2426 | 2425 |
| 2427 void test_mixinOverrideOfGrandInterface_mixinOfInterfaceOfChild() { | 2426 void test_mixinOverrideOfGrandInterface_mixinOfInterfaceOfChild() { |
| 2428 checkFile(''' | 2427 checkFile(''' |
| 2429 class A {} | 2428 class A {} |
| 2430 class B {} | 2429 class B {} |
| 2431 | 2430 |
| 2432 abstract class M1 { | 2431 abstract class M1 { |
| 2433 m(A a); | 2432 m(A a); |
| 2434 } | 2433 } |
| 2435 abstract class I2 extends Object with M1 {} | 2434 abstract class I2 extends Object with M1 {} |
| 2436 | 2435 |
| 2437 class M { | 2436 class M { |
| 2438 m(B a) {} | 2437 m(B a) {} |
| 2439 } | 2438 } |
| 2440 | 2439 |
| 2441 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2440 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2442 extends Object with /*severe:INVALID_METHOD_OVERRIDE*/M | 2441 extends Object with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M |
| 2443 implements I2 {} | 2442 implements I2 {} |
| 2444 '''); | 2443 '''); |
| 2445 } | 2444 } |
| 2446 | 2445 |
| 2447 void test_mixinOverrideOfGrandInterface_superclassOfInterfaceOfChild() { | 2446 void test_mixinOverrideOfGrandInterface_superclassOfInterfaceOfChild() { |
| 2448 checkFile(''' | 2447 checkFile(''' |
| 2449 class A {} | 2448 class A {} |
| 2450 class B {} | 2449 class B {} |
| 2451 | 2450 |
| 2452 abstract class I1 { | 2451 abstract class I1 { |
| 2453 m(A a); | 2452 m(A a); |
| 2454 } | 2453 } |
| 2455 abstract class I2 extends I1 {} | 2454 abstract class I2 extends I1 {} |
| 2456 | 2455 |
| 2457 class M { | 2456 class M { |
| 2458 m(B a) {} | 2457 m(B a) {} |
| 2459 } | 2458 } |
| 2460 | 2459 |
| 2461 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2460 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2462 extends Object with /*severe:INVALID_METHOD_OVERRIDE*/M | 2461 extends Object with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M |
| 2463 implements I2 {} | 2462 implements I2 {} |
| 2464 '''); | 2463 '''); |
| 2465 } | 2464 } |
| 2466 | 2465 |
| 2467 void | 2466 void |
| 2468 test_noDuplicateReportsFromOverridingInterfaces_baseTypeAndMixinOverrideSa
meMethodInInterface() { | 2467 test_noDuplicateReportsFromOverridingInterfaces_baseTypeAndMixinOverrideSa
meMethodInInterface() { |
| 2469 checkFile(''' | 2468 checkFile(''' |
| 2470 class A {} | 2469 class A {} |
| 2471 class B {} | 2470 class B {} |
| 2472 | 2471 |
| 2473 abstract class I1 { | 2472 abstract class I1 { |
| 2474 m(A a); | 2473 m(A a); |
| 2475 } | 2474 } |
| 2476 | 2475 |
| 2477 class Base { | 2476 class Base { |
| 2478 m(B a) {} | 2477 m(B a) {} |
| 2479 } | 2478 } |
| 2480 | 2479 |
| 2481 class M { | 2480 class M { |
| 2482 m(B a) {} | 2481 m(B a) {} |
| 2483 } | 2482 } |
| 2484 | 2483 |
| 2485 // Here we want to report both, because the error location is | 2484 // Here we want to report both, because the error location is |
| 2486 // different. | 2485 // different. |
| 2487 // TODO(sigmund): should we merge these as well? | 2486 // TODO(sigmund): should we merge these as well? |
| 2488 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2487 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2489 /*severe:INVALID_METHOD_OVERRIDE*/extends Base | 2488 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base |
| 2490 with /*severe:INVALID_METHOD_OVERRIDE*/M | 2489 with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M |
| 2491 implements I1 {} | 2490 implements I1 {} |
| 2492 '''); | 2491 '''); |
| 2493 } | 2492 } |
| 2494 | 2493 |
| 2495 void | 2494 void |
| 2496 test_noDuplicateReportsFromOverridingInterfaces_twoGrandTypesOverrideSameM
ethodInInterface() { | 2495 test_noDuplicateReportsFromOverridingInterfaces_twoGrandTypesOverrideSameM
ethodInInterface() { |
| 2497 checkFile(''' | 2496 checkFile(''' |
| 2498 class A {} | 2497 class A {} |
| 2499 class B {} | 2498 class B {} |
| 2500 | 2499 |
| 2501 abstract class I1 { | 2500 abstract class I1 { |
| 2502 m(A a); | 2501 m(A a); |
| 2503 } | 2502 } |
| 2504 | 2503 |
| 2505 class Grandparent { | 2504 class Grandparent { |
| 2506 m(B a) {} | 2505 m(B a) {} |
| 2507 } | 2506 } |
| 2508 | 2507 |
| 2509 class Parent1 extends Grandparent { | 2508 class Parent1 extends Grandparent { |
| 2510 m(B a) {} | 2509 m(B a) {} |
| 2511 } | 2510 } |
| 2512 class Parent2 extends Grandparent {} | 2511 class Parent2 extends Grandparent {} |
| 2513 | 2512 |
| 2514 // Note: otherwise both errors would be reported on this line | 2513 // Note: otherwise both errors would be reported on this line |
| 2515 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2514 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2516 /*severe:INVALID_METHOD_OVERRIDE*/extends Parent1 | 2515 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Parent1 |
| 2517 implements I1 {} | 2516 implements I1 {} |
| 2518 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T2 | 2517 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T2 |
| 2519 /*severe:INVALID_METHOD_OVERRIDE*/extends Parent2 | 2518 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Parent2 |
| 2520 implements I1 {} | 2519 implements I1 {} |
| 2521 '''); | 2520 '''); |
| 2522 } | 2521 } |
| 2523 | 2522 |
| 2524 void | 2523 void |
| 2525 test_noDuplicateReportsFromOverridingInterfaces_twoMixinsOverrideSameMetho
dInInterface() { | 2524 test_noDuplicateReportsFromOverridingInterfaces_twoMixinsOverrideSameMetho
dInInterface() { |
| 2526 checkFile(''' | 2525 checkFile(''' |
| 2527 class A {} | 2526 class A {} |
| 2528 class B {} | 2527 class B {} |
| 2529 | 2528 |
| 2530 abstract class I1 { | 2529 abstract class I1 { |
| 2531 m(A a); | 2530 m(A a); |
| 2532 } | 2531 } |
| 2533 | 2532 |
| 2534 class M1 { | 2533 class M1 { |
| 2535 m(B a) {} | 2534 m(B a) {} |
| 2536 } | 2535 } |
| 2537 | 2536 |
| 2538 class M2 { | 2537 class M2 { |
| 2539 m(B a) {} | 2538 m(B a) {} |
| 2540 } | 2539 } |
| 2541 | 2540 |
| 2542 // Here we want to report both, because the error location is | 2541 // Here we want to report both, because the error location is |
| 2543 // different. | 2542 // different. |
| 2544 // TODO(sigmund): should we merge these as well? | 2543 // TODO(sigmund): should we merge these as well? |
| 2545 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Object | 2544 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 extends Object |
| 2546 with /*severe:INVALID_METHOD_OVERRIDE*/M1, | 2545 with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M1, |
| 2547 /*severe:INVALID_METHOD_OVERRIDE*/M2 | 2546 /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M2 |
| 2548 implements I1 {} | 2547 implements I1 {} |
| 2549 '''); | 2548 '''); |
| 2550 } | 2549 } |
| 2551 | 2550 |
| 2552 void | 2551 void |
| 2553 test_noDuplicateReportsFromOverridingInterfaces_typeAndBaseTypeOverrideSam
eMethodInInterface() { | 2552 test_noDuplicateReportsFromOverridingInterfaces_typeAndBaseTypeOverrideSam
eMethodInInterface() { |
| 2554 checkFile(''' | 2553 checkFile(''' |
| 2555 class A {} | 2554 class A {} |
| 2556 class B {} | 2555 class B {} |
| 2557 | 2556 |
| 2558 abstract class I1 { | 2557 abstract class I1 { |
| 2559 m(A a); | 2558 m(A a); |
| 2560 } | 2559 } |
| 2561 | 2560 |
| 2562 class Base { | 2561 class Base { |
| 2563 m(B a) {} | 2562 m(B a) {} |
| 2564 } | 2563 } |
| 2565 | 2564 |
| 2566 // Note: no error reported in `extends Base` to avoid duplicating | 2565 // Note: no error reported in `extends Base` to avoid duplicating |
| 2567 // the error in T1. | 2566 // the error in T1. |
| 2568 class T1 extends Base implements I1 { | 2567 class T1 extends Base implements I1 { |
| 2569 /*severe:INVALID_METHOD_OVERRIDE*/m( | 2568 /*severe:INVALID_METHOD_OVERRIDE*/m( |
| 2570 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} | 2569 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} |
| 2571 } | 2570 } |
| 2572 | 2571 |
| 2573 // If there is no error in the class, we do report the error at | 2572 // If there is no error in the class, we do report the error at |
| 2574 // the base class: | 2573 // the base class: |
| 2575 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T2 | 2574 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T2 |
| 2576 /*severe:INVALID_METHOD_OVERRIDE*/extends Base | 2575 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base |
| 2577 implements I1 {} | 2576 implements I1 {} |
| 2578 '''); | 2577 '''); |
| 2579 } | 2578 } |
| 2580 | 2579 |
| 2581 void | 2580 void |
| 2582 test_noDuplicateReportsFromOverridingInterfaces_typeAndMixinOverrideSameMe
thodInInterface() { | 2581 test_noDuplicateReportsFromOverridingInterfaces_typeAndMixinOverrideSameMe
thodInInterface() { |
| 2583 checkFile(''' | 2582 checkFile(''' |
| 2584 class A {} | 2583 class A {} |
| 2585 class B {} | 2584 class B {} |
| 2586 | 2585 |
| 2587 abstract class I1 { | 2586 abstract class I1 { |
| 2588 m(A a); | 2587 m(A a); |
| 2589 } | 2588 } |
| 2590 | 2589 |
| 2591 class M { | 2590 class M { |
| 2592 m(B a) {} | 2591 m(B a) {} |
| 2593 } | 2592 } |
| 2594 | 2593 |
| 2595 class T1 extends Object with M implements I1 { | 2594 class T1 extends Object with M implements I1 { |
| 2596 /*severe:INVALID_METHOD_OVERRIDE*/m( | 2595 /*severe:INVALID_METHOD_OVERRIDE*/m( |
| 2597 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} | 2596 /*warning:INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE*/B a) {} |
| 2598 } | 2597 } |
| 2599 | 2598 |
| 2600 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T2 | 2599 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T2 |
| 2601 extends Object with /*severe:INVALID_METHOD_OVERRIDE*/M | 2600 extends Object with /*severe:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/M |
| 2602 implements I1 {} | 2601 implements I1 {} |
| 2603 '''); | 2602 '''); |
| 2604 } | 2603 } |
| 2605 | 2604 |
| 2606 void | 2605 void |
| 2607 test_noDuplicateReportsFromOverridingInterfaces_typeOverridesSomeMethodInM
ultipleInterfaces() { | 2606 test_noDuplicateReportsFromOverridingInterfaces_typeOverridesSomeMethodInM
ultipleInterfaces() { |
| 2608 checkFile(''' | 2607 checkFile(''' |
| 2609 class A {} | 2608 class A {} |
| 2610 class B {} | 2609 class B {} |
| 2611 | 2610 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2725 lOfOs = mOfDs; | 2724 lOfOs = mOfDs; |
| 2726 lOfOs = mOfOs; | 2725 lOfOs = mOfOs; |
| 2727 lOfOs = mOfAs; | 2726 lOfOs = mOfAs; |
| 2728 lOfOs = lOfDs; | 2727 lOfOs = lOfDs; |
| 2729 lOfOs = lOfOs; | 2728 lOfOs = lOfOs; |
| 2730 lOfOs = lOfAs; | 2729 lOfOs = lOfAs; |
| 2731 lOfOs = new L<Object>(); // Reset type propagation. | 2730 lOfOs = new L<Object>(); // Reset type propagation. |
| 2732 } | 2731 } |
| 2733 { | 2732 { |
| 2734 lOfAs = /*warning:DOWN_CAST_COMPOSITE*/mOfDs; | 2733 lOfAs = /*warning:DOWN_CAST_COMPOSITE*/mOfDs; |
| 2735 lOfAs = /*warning:INVALID_ASSIGNMENT*/mOfOs; | 2734 lOfAs = /*severe:INVALID_ASSIGNMENT*/mOfOs; |
| 2736 lOfAs = mOfAs; | 2735 lOfAs = mOfAs; |
| 2737 lOfAs = /*warning:DOWN_CAST_COMPOSITE*/lOfDs; | 2736 lOfAs = /*warning:DOWN_CAST_COMPOSITE*/lOfDs; |
| 2738 lOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; | 2737 lOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; |
| 2739 lOfAs = lOfAs; | 2738 lOfAs = lOfAs; |
| 2740 lOfAs = new L<A>(); // Reset type propagation. | 2739 lOfAs = new L<A>(); // Reset type propagation. |
| 2741 } | 2740 } |
| 2742 { | 2741 { |
| 2743 mOfDs = mOfDs; | 2742 mOfDs = mOfDs; |
| 2744 mOfDs = mOfOs; | 2743 mOfDs = mOfOs; |
| 2745 mOfDs = mOfAs; | 2744 mOfDs = mOfAs; |
| 2746 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfDs; | 2745 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfDs; |
| 2747 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; | 2746 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; |
| 2748 mOfDs = /*warning:DOWN_CAST_COMPOSITE*/lOfAs; | 2747 mOfDs = /*warning:DOWN_CAST_COMPOSITE*/lOfAs; |
| 2749 mOfDs = new M(); // Reset type propagation. | 2748 mOfDs = new M(); // Reset type propagation. |
| 2750 } | 2749 } |
| 2751 { | 2750 { |
| 2752 mOfOs = mOfDs; | 2751 mOfOs = mOfDs; |
| 2753 mOfOs = mOfOs; | 2752 mOfOs = mOfOs; |
| 2754 mOfOs = mOfAs; | 2753 mOfOs = mOfAs; |
| 2755 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfDs; | 2754 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfDs; |
| 2756 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; | 2755 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; |
| 2757 mOfOs = /*warning:INVALID_ASSIGNMENT*/lOfAs; | 2756 mOfOs = /*severe:INVALID_ASSIGNMENT*/lOfAs; |
| 2758 mOfOs = new M<Object>(); // Reset type propagation. | 2757 mOfOs = new M<Object>(); // Reset type propagation. |
| 2759 } | 2758 } |
| 2760 { | 2759 { |
| 2761 mOfAs = /*warning:DOWN_CAST_COMPOSITE*/mOfDs; | 2760 mOfAs = /*warning:DOWN_CAST_COMPOSITE*/mOfDs; |
| 2762 mOfAs = /*info:DOWN_CAST_IMPLICIT*/mOfOs; | 2761 mOfAs = /*info:DOWN_CAST_IMPLICIT*/mOfOs; |
| 2763 mOfAs = mOfAs; | 2762 mOfAs = mOfAs; |
| 2764 mOfAs = /*warning:DOWN_CAST_COMPOSITE*/lOfDs; | 2763 mOfAs = /*warning:DOWN_CAST_COMPOSITE*/lOfDs; |
| 2765 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; | 2764 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; |
| 2766 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfAs; | 2765 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfAs; |
| 2767 } | 2766 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2794 } | 2793 } |
| 2795 '''); | 2794 '''); |
| 2796 } | 2795 } |
| 2797 | 2796 |
| 2798 void test_setterReturnTypes() { | 2797 void test_setterReturnTypes() { |
| 2799 checkFile(''' | 2798 checkFile(''' |
| 2800 void voidFn() => null; | 2799 void voidFn() => null; |
| 2801 class A { | 2800 class A { |
| 2802 set a(y) => 4; | 2801 set a(y) => 4; |
| 2803 set b(y) => voidFn(); | 2802 set b(y) => voidFn(); |
| 2804 void set c(y) => /*warning:RETURN_OF_INVALID_TYPE*/4; | 2803 void set c(y) => /*severe:RETURN_OF_INVALID_TYPE*/4; |
| 2805 void set d(y) => voidFn(); | 2804 void set d(y) => voidFn(); |
| 2806 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set e(y) => 4; | 2805 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set e(y) => 4; |
| 2807 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set f(y) => | 2806 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set f(y) => |
| 2808 /*warning:RETURN_OF_INVALID_TYPE*/voidFn(); | 2807 /*severe:RETURN_OF_INVALID_TYPE*/voidFn(); |
| 2809 set g(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;} | 2808 set g(y) {return /*severe:RETURN_OF_INVALID_TYPE*/4;} |
| 2810 void set h(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;} | 2809 void set h(y) {return /*severe:RETURN_OF_INVALID_TYPE*/4;} |
| 2811 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set i(y) {return 4;} | 2810 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set i(y) {return 4;} |
| 2812 } | 2811 } |
| 2813 '''); | 2812 '''); |
| 2814 } | 2813 } |
| 2815 | 2814 |
| 2816 void test_setterSetterOverride() { | 2815 void test_setterSetterOverride() { |
| 2817 checkFile(''' | 2816 checkFile(''' |
| 2818 class A {} | 2817 class A {} |
| 2819 class B extends A {} | 2818 class B extends A {} |
| 2820 class C extends B {} | 2819 class C extends B {} |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2924 | 2923 |
| 2925 abstract class I1 { | 2924 abstract class I1 { |
| 2926 m(A a); | 2925 m(A a); |
| 2927 } | 2926 } |
| 2928 abstract class I2 implements I1 {} | 2927 abstract class I2 implements I1 {} |
| 2929 | 2928 |
| 2930 class Base { | 2929 class Base { |
| 2931 m(B a) {} | 2930 m(B a) {} |
| 2932 } | 2931 } |
| 2933 | 2932 |
| 2934 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2933 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2935 /*severe:INVALID_METHOD_OVERRIDE*/extends Base implements I2 {} | 2934 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base implements I2 {} |
| 2936 '''); | 2935 '''); |
| 2937 } | 2936 } |
| 2938 | 2937 |
| 2939 void test_superclassOverrideOfGrandInterface_mixinOfInterfaceOfChild() { | 2938 void test_superclassOverrideOfGrandInterface_mixinOfInterfaceOfChild() { |
| 2940 checkFile(''' | 2939 checkFile(''' |
| 2941 class A {} | 2940 class A {} |
| 2942 class B {} | 2941 class B {} |
| 2943 | 2942 |
| 2944 abstract class M1 { | 2943 abstract class M1 { |
| 2945 m(A a); | 2944 m(A a); |
| 2946 } | 2945 } |
| 2947 abstract class I2 extends Object with M1 {} | 2946 abstract class I2 extends Object with M1 {} |
| 2948 | 2947 |
| 2949 class Base { | 2948 class Base { |
| 2950 m(B a) {} | 2949 m(B a) {} |
| 2951 } | 2950 } |
| 2952 | 2951 |
| 2953 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2952 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2954 /*severe:INVALID_METHOD_OVERRIDE*/extends Base | 2953 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base |
| 2955 implements I2 {} | 2954 implements I2 {} |
| 2956 '''); | 2955 '''); |
| 2957 } | 2956 } |
| 2958 | 2957 |
| 2959 void test_superclassOverrideOfGrandInterface_superclassOfInterfaceOfChild() { | 2958 void test_superclassOverrideOfGrandInterface_superclassOfInterfaceOfChild() { |
| 2960 checkFile(''' | 2959 checkFile(''' |
| 2961 class A {} | 2960 class A {} |
| 2962 class B {} | 2961 class B {} |
| 2963 | 2962 |
| 2964 abstract class I1 { | 2963 abstract class I1 { |
| 2965 m(A a); | 2964 m(A a); |
| 2966 } | 2965 } |
| 2967 abstract class I2 extends I1 {} | 2966 abstract class I2 extends I1 {} |
| 2968 | 2967 |
| 2969 class Base { | 2968 class Base { |
| 2970 m(B a) {} | 2969 m(B a) {} |
| 2971 } | 2970 } |
| 2972 | 2971 |
| 2973 class /*warning:INCONSISTENT_METHOD_INHERITANCE*/T1 | 2972 class /*severe:INCONSISTENT_METHOD_INHERITANCE*/T1 |
| 2974 /*severe:INVALID_METHOD_OVERRIDE*/extends Base | 2973 /*severe:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends Base |
| 2975 implements I2 {} | 2974 implements I2 {} |
| 2976 '''); | 2975 '''); |
| 2977 } | 2976 } |
| 2978 | 2977 |
| 2979 void test_superConstructor() { | 2978 void test_superConstructor() { |
| 2980 checkFile(''' | 2979 checkFile(''' |
| 2981 class A { A(A x) {} } | 2980 class A { A(A x) {} } |
| 2982 class B extends A { | 2981 class B extends A { |
| 2983 B() : super(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); | 2982 B() : super(/*warning:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); |
| 2984 } | 2983 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3019 v = (isValidKey != null) | 3018 v = (isValidKey != null) |
| 3020 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true); | 3019 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true); |
| 3021 } | 3020 } |
| 3022 } | 3021 } |
| 3023 void main() { | 3022 void main() { |
| 3024 Object obj = 42; | 3023 Object obj = 42; |
| 3025 dynamic dyn = 42; | 3024 dynamic dyn = 42; |
| 3026 int i = 42; | 3025 int i = 42; |
| 3027 | 3026 |
| 3028 // Check the boolean conversion of the condition. | 3027 // Check the boolean conversion of the condition. |
| 3029 print(/*warning:NON_BOOL_CONDITION*/i ? false : true); | 3028 print(/*severe:NON_BOOL_CONDITION*/i ? false : true); |
| 3030 print((/*info:DOWN_CAST_IMPLICIT*/obj) ? false : true); | 3029 print((/*info:DOWN_CAST_IMPLICIT*/obj) ? false : true); |
| 3031 print((/*info:DYNAMIC_CAST*/dyn) ? false : true); | 3030 print((/*info:DYNAMIC_CAST*/dyn) ? false : true); |
| 3032 } | 3031 } |
| 3033 '''); | 3032 '''); |
| 3034 } | 3033 } |
| 3035 | 3034 |
| 3036 void test_typeCheckingLiterals() { | 3035 void test_typeCheckingLiterals() { |
| 3037 checkFile(''' | 3036 checkFile(''' |
| 3038 test() { | 3037 test() { |
| 3039 num n = 3; | 3038 num n = 3; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3077 } | 3076 } |
| 3078 '''); | 3077 '''); |
| 3079 } | 3078 } |
| 3080 | 3079 |
| 3081 void test_typePromotionFromDynamic() { | 3080 void test_typePromotionFromDynamic() { |
| 3082 checkFile(r''' | 3081 checkFile(r''' |
| 3083 f() { | 3082 f() { |
| 3084 dynamic x; | 3083 dynamic x; |
| 3085 if (x is int) { | 3084 if (x is int) { |
| 3086 int y = x; | 3085 int y = x; |
| 3087 String z = /*warning:INVALID_ASSIGNMENT*/x; | 3086 String z = /*severe:INVALID_ASSIGNMENT*/x; |
| 3088 } | 3087 } |
| 3089 } | 3088 } |
| 3090 g() { | 3089 g() { |
| 3091 Object x; | 3090 Object x; |
| 3092 if (x is int) { | 3091 if (x is int) { |
| 3093 int y = x; | 3092 int y = x; |
| 3094 String z = /*warning:INVALID_ASSIGNMENT*/x; | 3093 String z = /*severe:INVALID_ASSIGNMENT*/x; |
| 3095 } | 3094 } |
| 3096 } | 3095 } |
| 3097 '''); | 3096 '''); |
| 3098 } | 3097 } |
| 3099 | 3098 |
| 3100 void test_typeSubtyping_assigningClass() { | 3099 void test_typeSubtyping_assigningClass() { |
| 3101 checkFile(''' | 3100 checkFile(''' |
| 3102 class A {} | 3101 class A {} |
| 3103 class B extends A {} | 3102 class B extends A {} |
| 3104 | 3103 |
| 3105 void main() { | 3104 void main() { |
| 3106 dynamic y; | 3105 dynamic y; |
| 3107 Object o; | 3106 Object o; |
| 3108 int i = 0; | 3107 int i = 0; |
| 3109 double d = 0.0; | 3108 double d = 0.0; |
| 3110 num n; | 3109 num n; |
| 3111 A a; | 3110 A a; |
| 3112 B b; | 3111 B b; |
| 3113 y = a; | 3112 y = a; |
| 3114 o = a; | 3113 o = a; |
| 3115 i = /*warning:INVALID_ASSIGNMENT*/a; | 3114 i = /*severe:INVALID_ASSIGNMENT*/a; |
| 3116 d = /*warning:INVALID_ASSIGNMENT*/a; | 3115 d = /*severe:INVALID_ASSIGNMENT*/a; |
| 3117 n = /*warning:INVALID_ASSIGNMENT*/a; | 3116 n = /*severe:INVALID_ASSIGNMENT*/a; |
| 3118 a = a; | 3117 a = a; |
| 3119 b = /*info:DOWN_CAST_IMPLICIT*/a; | 3118 b = /*info:DOWN_CAST_IMPLICIT*/a; |
| 3120 } | 3119 } |
| 3121 '''); | 3120 '''); |
| 3122 } | 3121 } |
| 3123 | 3122 |
| 3124 void test_typeSubtyping_assigningSubclass() { | 3123 void test_typeSubtyping_assigningSubclass() { |
| 3125 checkFile(''' | 3124 checkFile(''' |
| 3126 class A {} | 3125 class A {} |
| 3127 class B extends A {} | 3126 class B extends A {} |
| 3128 class C extends A {} | 3127 class C extends A {} |
| 3129 | 3128 |
| 3130 void main() { | 3129 void main() { |
| 3131 dynamic y; | 3130 dynamic y; |
| 3132 Object o; | 3131 Object o; |
| 3133 int i = 0; | 3132 int i = 0; |
| 3134 double d = 0.0; | 3133 double d = 0.0; |
| 3135 num n; | 3134 num n; |
| 3136 A a; | 3135 A a; |
| 3137 B b; | 3136 B b; |
| 3138 C c; | 3137 C c; |
| 3139 y = b; | 3138 y = b; |
| 3140 o = b; | 3139 o = b; |
| 3141 i = /*warning:INVALID_ASSIGNMENT*/b; | 3140 i = /*severe:INVALID_ASSIGNMENT*/b; |
| 3142 d = /*warning:INVALID_ASSIGNMENT*/b; | 3141 d = /*severe:INVALID_ASSIGNMENT*/b; |
| 3143 n = /*warning:INVALID_ASSIGNMENT*/b; | 3142 n = /*severe:INVALID_ASSIGNMENT*/b; |
| 3144 a = b; | 3143 a = b; |
| 3145 b = b; | 3144 b = b; |
| 3146 c = /*warning:INVALID_ASSIGNMENT*/b; | 3145 c = /*severe:INVALID_ASSIGNMENT*/b; |
| 3147 } | 3146 } |
| 3148 '''); | 3147 '''); |
| 3149 } | 3148 } |
| 3150 | 3149 |
| 3151 void test_typeSubtyping_dynamicDowncasts() { | 3150 void test_typeSubtyping_dynamicDowncasts() { |
| 3152 checkFile(''' | 3151 checkFile(''' |
| 3153 class A {} | 3152 class A {} |
| 3154 class B extends A {} | 3153 class B extends A {} |
| 3155 | 3154 |
| 3156 void main() { | 3155 void main() { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 D bot; | 3207 D bot; |
| 3209 { | 3208 { |
| 3210 top = top; | 3209 top = top; |
| 3211 top = left; | 3210 top = left; |
| 3212 top = right; | 3211 top = right; |
| 3213 top = bot; | 3212 top = bot; |
| 3214 } | 3213 } |
| 3215 { | 3214 { |
| 3216 left = /*info:DOWN_CAST_IMPLICIT*/top; | 3215 left = /*info:DOWN_CAST_IMPLICIT*/top; |
| 3217 left = left; | 3216 left = left; |
| 3218 left = /*warning:INVALID_ASSIGNMENT*/right; | 3217 left = /*severe:INVALID_ASSIGNMENT*/right; |
| 3219 left = bot; | 3218 left = bot; |
| 3220 } | 3219 } |
| 3221 { | 3220 { |
| 3222 right = /*info:DOWN_CAST_IMPLICIT*/top; | 3221 right = /*info:DOWN_CAST_IMPLICIT*/top; |
| 3223 right = /*warning:INVALID_ASSIGNMENT*/left; | 3222 right = /*severe:INVALID_ASSIGNMENT*/left; |
| 3224 right = right; | 3223 right = right; |
| 3225 right = bot; | 3224 right = bot; |
| 3226 } | 3225 } |
| 3227 { | 3226 { |
| 3228 bot = /*info:DOWN_CAST_IMPLICIT*/top; | 3227 bot = /*info:DOWN_CAST_IMPLICIT*/top; |
| 3229 bot = /*info:DOWN_CAST_IMPLICIT*/left; | 3228 bot = /*info:DOWN_CAST_IMPLICIT*/left; |
| 3230 bot = /*info:DOWN_CAST_IMPLICIT*/right; | 3229 bot = /*info:DOWN_CAST_IMPLICIT*/right; |
| 3231 bot = bot; | 3230 bot = bot; |
| 3232 } | 3231 } |
| 3233 } | 3232 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3246 foo() => new A(); | 3245 foo() => new A(); |
| 3247 | 3246 |
| 3248 test() { | 3247 test() { |
| 3249 A a = new A(); | 3248 A a = new A(); |
| 3250 var c = foo(); | 3249 var c = foo(); |
| 3251 dynamic d; | 3250 dynamic d; |
| 3252 | 3251 |
| 3253 ~a; | 3252 ~a; |
| 3254 (/*info:DYNAMIC_INVOKE*/~d); | 3253 (/*info:DYNAMIC_INVOKE*/~d); |
| 3255 | 3254 |
| 3256 !/*warning:NON_BOOL_NEGATION_EXPRESSION*/a; | 3255 !/*severe:NON_BOOL_NEGATION_EXPRESSION*/a; |
| 3257 !/*info:DYNAMIC_CAST*/d; | 3256 !/*info:DYNAMIC_CAST*/d; |
| 3258 | 3257 |
| 3259 -a; | 3258 -a; |
| 3260 (/*info:DYNAMIC_INVOKE*/-d); | 3259 (/*info:DYNAMIC_INVOKE*/-d); |
| 3261 | 3260 |
| 3262 ++a; | 3261 ++a; |
| 3263 --a; | 3262 --a; |
| 3264 (/*info:DYNAMIC_INVOKE*/++d); | 3263 (/*info:DYNAMIC_INVOKE*/++d); |
| 3265 (/*info:DYNAMIC_INVOKE*/--d); | 3264 (/*info:DYNAMIC_INVOKE*/--d); |
| 3266 | 3265 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3295 } | 3294 } |
| 3296 '''); | 3295 '''); |
| 3297 } | 3296 } |
| 3298 | 3297 |
| 3299 void test_voidSubtyping() { | 3298 void test_voidSubtyping() { |
| 3300 // Regression test for https://github.com/dart-lang/sdk/issues/25069 | 3299 // Regression test for https://github.com/dart-lang/sdk/issues/25069 |
| 3301 checkFile(''' | 3300 checkFile(''' |
| 3302 typedef int Foo(); | 3301 typedef int Foo(); |
| 3303 void foo() {} | 3302 void foo() {} |
| 3304 void main () { | 3303 void main () { |
| 3305 Foo x = /*warning:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); | 3304 Foo x = /*severe:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); |
| 3306 } | 3305 } |
| 3307 '''); | 3306 '''); |
| 3308 } | 3307 } |
| 3309 } | 3308 } |
| OLD | NEW |