OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 | 6 |
7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
8 import 'package:analyzer/src/dart/analysis/driver.dart'; | 8 import 'package:analyzer/src/dart/analysis/driver.dart'; |
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
10 | 10 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 var library = await _encodeDecodeLibrary(r''' | 381 var library = await _encodeDecodeLibrary(r''' |
382 var vPlusIntInt = 1 + 2; | 382 var vPlusIntInt = 1 + 2; |
383 var vPlusIntDouble = 1 + 2.0; | 383 var vPlusIntDouble = 1 + 2.0; |
384 var vPlusDoubleInt = 1.0 + 2; | 384 var vPlusDoubleInt = 1.0 + 2; |
385 var vPlusDoubleDouble = 1.0 + 2.0; | 385 var vPlusDoubleDouble = 1.0 + 2.0; |
386 var vMinusIntInt = 1 - 2; | 386 var vMinusIntInt = 1 - 2; |
387 var vMinusIntDouble = 1 - 2.0; | 387 var vMinusIntDouble = 1 - 2.0; |
388 var vMinusDoubleInt = 1.0 - 2; | 388 var vMinusDoubleInt = 1.0 - 2; |
389 var vMinusDoubleDouble = 1.0 - 2.0; | 389 var vMinusDoubleDouble = 1.0 - 2.0; |
390 '''); | 390 '''); |
391 checkElementText( | 391 checkElementText(library, r''' |
392 library, | |
393 r''' | |
394 int vPlusIntInt; | 392 int vPlusIntInt; |
395 double vPlusIntDouble; | 393 double vPlusIntDouble; |
396 double vPlusDoubleInt; | 394 double vPlusDoubleInt; |
397 double vPlusDoubleDouble; | 395 double vPlusDoubleDouble; |
398 int vMinusIntInt; | 396 int vMinusIntInt; |
399 double vMinusIntDouble; | 397 double vMinusIntDouble; |
400 double vMinusDoubleInt; | 398 double vMinusDoubleInt; |
401 double vMinusDoubleDouble; | 399 double vMinusDoubleDouble; |
402 '''); | 400 '''); |
403 } | 401 } |
404 | 402 |
405 test_initializer_as() async { | 403 test_initializer_as() async { |
406 var library = await _encodeDecodeLibrary(r''' | 404 var library = await _encodeDecodeLibrary(r''' |
407 var V = 1 as num; | 405 var V = 1 as num; |
408 '''); | 406 '''); |
409 checkElementText( | 407 checkElementText(library, r''' |
410 library, | |
411 r''' | |
412 num V; | 408 num V; |
413 '''); | 409 '''); |
414 } | 410 } |
415 | 411 |
416 test_initializer_await() async { | 412 test_initializer_await() async { |
417 var library = await _encodeDecodeLibrary(r''' | 413 var library = await _encodeDecodeLibrary(r''' |
418 import 'dart:async'; | 414 import 'dart:async'; |
419 int fValue() => 42; | 415 int fValue() => 42; |
420 Future<int> fFuture() async => 42; | 416 Future<int> fFuture() async => 42; |
421 var uValue = () async => await fValue(); | 417 var uValue = () async => await fValue(); |
422 var uFuture = () async => await fFuture(); | 418 var uFuture = () async => await fFuture(); |
423 '''); | 419 '''); |
424 checkElementText( | 420 checkElementText(library, r''' |
425 library, | |
426 r''' | |
427 import 'dart:async'; | 421 import 'dart:async'; |
428 () → Future<int> uValue; | 422 () → Future<int> uValue; |
429 () → Future<int> uFuture; | 423 () → Future<int> uFuture; |
430 int fValue() {} | 424 int fValue() {} |
431 Future<int> fFuture() async {} | 425 Future<int> fFuture() async {} |
432 '''); | 426 '''); |
433 } | 427 } |
434 | 428 |
435 test_initializer_bitwise() async { | 429 test_initializer_bitwise() async { |
436 var library = await _encodeDecodeLibrary(r''' | 430 var library = await _encodeDecodeLibrary(r''' |
437 var vBitXor = 1 ^ 2; | 431 var vBitXor = 1 ^ 2; |
438 var vBitAnd = 1 & 2; | 432 var vBitAnd = 1 & 2; |
439 var vBitOr = 1 | 2; | 433 var vBitOr = 1 | 2; |
440 var vBitShiftLeft = 1 << 2; | 434 var vBitShiftLeft = 1 << 2; |
441 var vBitShiftRight = 1 >> 2; | 435 var vBitShiftRight = 1 >> 2; |
442 '''); | 436 '''); |
443 checkElementText( | 437 checkElementText(library, r''' |
444 library, | |
445 r''' | |
446 int vBitXor; | 438 int vBitXor; |
447 int vBitAnd; | 439 int vBitAnd; |
448 int vBitOr; | 440 int vBitOr; |
449 int vBitShiftLeft; | 441 int vBitShiftLeft; |
450 int vBitShiftRight; | 442 int vBitShiftRight; |
451 '''); | 443 '''); |
452 } | 444 } |
453 | 445 |
454 test_initializer_cascade() async { | 446 test_initializer_cascade() async { |
455 var library = await _encodeDecodeLibrary(r''' | 447 var library = await _encodeDecodeLibrary(r''' |
456 class A { | 448 class A { |
457 int a; | 449 int a; |
458 void m() {} | 450 void m() {} |
459 } | 451 } |
460 var vSetField = new A()..a = 1; | 452 var vSetField = new A()..a = 1; |
461 var vInvokeMethod = new A()..m(); | 453 var vInvokeMethod = new A()..m(); |
462 var vBoth = new A()..a = 1..m(); | 454 var vBoth = new A()..a = 1..m(); |
463 '''); | 455 '''); |
464 checkElementText( | 456 checkElementText(library, r''' |
465 library, | |
466 r''' | |
467 class A { | 457 class A { |
468 int a; | 458 int a; |
469 void m() {} | 459 void m() {} |
470 } | 460 } |
471 A vSetField; | 461 A vSetField; |
472 A vInvokeMethod; | 462 A vInvokeMethod; |
473 A vBoth; | 463 A vBoth; |
474 '''); | 464 '''); |
475 } | 465 } |
476 | 466 |
477 test_initializer_conditional() async { | 467 test_initializer_conditional() async { |
478 var library = await _encodeDecodeLibrary(r''' | 468 var library = await _encodeDecodeLibrary(r''' |
479 var V = true ? 1 : 2.3; | 469 var V = true ? 1 : 2.3; |
480 '''); | 470 '''); |
481 checkElementText( | 471 checkElementText(library, r''' |
482 library, | |
483 r''' | |
484 num V; | 472 num V; |
485 '''); | 473 '''); |
486 } | 474 } |
487 | 475 |
488 test_initializer_equality() async { | 476 test_initializer_equality() async { |
489 var library = await _encodeDecodeLibrary(r''' | 477 var library = await _encodeDecodeLibrary(r''' |
490 var vEq = 1 == 2; | 478 var vEq = 1 == 2; |
491 var vNotEq = 1 != 2; | 479 var vNotEq = 1 != 2; |
492 '''); | 480 '''); |
493 checkElementText( | 481 checkElementText(library, r''' |
494 library, | |
495 r''' | |
496 bool vEq; | 482 bool vEq; |
497 bool vNotEq; | 483 bool vNotEq; |
498 '''); | 484 '''); |
499 } | 485 } |
500 | 486 |
501 test_initializer_error_assign() async { | 487 test_initializer_error_assign() async { |
502 var library = await _encodeDecodeLibrary(r''' | 488 var library = await _encodeDecodeLibrary(r''' |
503 var a = 1; | 489 var a = 1; |
504 var t1 = (a = 2); | 490 var t1 = (a = 2); |
505 var t2 = (a += 2); | 491 var t2 = (a += 2); |
506 '''); | 492 '''); |
507 checkElementText( | 493 checkElementText(library, r''' |
508 library, | |
509 r''' | |
510 int a; | 494 int a; |
511 dynamic t1/*error: assignment*/; | 495 dynamic t1/*error: assignment*/; |
512 dynamic t2/*error: assignment*/; | 496 dynamic t2/*error: assignment*/; |
513 '''); | 497 '''); |
514 } | 498 } |
515 | 499 |
516 test_initializer_error_assign_prefixed() async { | 500 test_initializer_error_assign_prefixed() async { |
517 var library = await _encodeDecodeLibrary(r''' | 501 var library = await _encodeDecodeLibrary(r''' |
518 class A { | 502 class A { |
519 int f; | 503 int f; |
520 } | 504 } |
521 var a = new A(); | 505 var a = new A(); |
522 var t1 = (a.f = 1); | 506 var t1 = (a.f = 1); |
523 var t2 = (a.f += 2); | 507 var t2 = (a.f += 2); |
524 '''); | 508 '''); |
525 checkElementText( | 509 checkElementText(library, r''' |
526 library, | |
527 r''' | |
528 class A { | 510 class A { |
529 int f; | 511 int f; |
530 } | 512 } |
531 A a; | 513 A a; |
532 dynamic t1/*error: assignment*/; | 514 dynamic t1/*error: assignment*/; |
533 dynamic t2/*error: assignment*/; | 515 dynamic t2/*error: assignment*/; |
534 '''); | 516 '''); |
535 } | 517 } |
536 | 518 |
537 test_initializer_error_assign_prefixed_viaInterface() async { | 519 test_initializer_error_assign_prefixed_viaInterface() async { |
538 var library = await _encodeDecodeLibrary(r''' | 520 var library = await _encodeDecodeLibrary(r''' |
539 class I { | 521 class I { |
540 int f; | 522 int f; |
541 } | 523 } |
542 abstract class C implements I {} | 524 abstract class C implements I {} |
543 C c; | 525 C c; |
544 var t1 = (c.f = 1); | 526 var t1 = (c.f = 1); |
545 var t2 = (c.f += 2); | 527 var t2 = (c.f += 2); |
546 '''); | 528 '''); |
547 checkElementText( | 529 checkElementText(library, r''' |
548 library, | |
549 r''' | |
550 class I { | 530 class I { |
551 int f; | 531 int f; |
552 } | 532 } |
553 abstract class C implements I { | 533 abstract class C implements I { |
554 } | 534 } |
555 C c; | 535 C c; |
556 dynamic t1/*error: assignment*/; | 536 dynamic t1/*error: assignment*/; |
557 dynamic t2/*error: assignment*/; | 537 dynamic t2/*error: assignment*/; |
558 '''); | 538 '''); |
559 } | 539 } |
560 | 540 |
561 test_initializer_error_assign_viaInterface() async { | 541 test_initializer_error_assign_viaInterface() async { |
562 var library = await _encodeDecodeLibrary(r''' | 542 var library = await _encodeDecodeLibrary(r''' |
563 class I { | 543 class I { |
564 int f; | 544 int f; |
565 } | 545 } |
566 abstract class C implements I {} | 546 abstract class C implements I {} |
567 C getC() => null; | 547 C getC() => null; |
568 var t1 = (getC().f = 1); | 548 var t1 = (getC().f = 1); |
569 var t2 = (getC().f += 2); | 549 var t2 = (getC().f += 2); |
570 '''); | 550 '''); |
571 checkElementText( | 551 checkElementText(library, r''' |
572 library, | |
573 r''' | |
574 class I { | 552 class I { |
575 int f; | 553 int f; |
576 } | 554 } |
577 abstract class C implements I { | 555 abstract class C implements I { |
578 } | 556 } |
579 dynamic t1/*error: assignment*/; | 557 dynamic t1/*error: assignment*/; |
580 dynamic t2/*error: assignment*/; | 558 dynamic t2/*error: assignment*/; |
581 C getC() {} | 559 C getC() {} |
582 '''); | 560 '''); |
583 } | 561 } |
(...skipping 28 matching lines...) Expand all Loading... |
612 var t12 = new B().a.f; | 590 var t12 = new B().a.f; |
613 var t13 = new C().b.a.f; | 591 var t13 = new C().b.a.f; |
614 var t21 = newA().f; | 592 var t21 = newA().f; |
615 var t22 = newB().a.f; | 593 var t22 = newB().a.f; |
616 var t23 = newC().b.a.f; | 594 var t23 = newC().b.a.f; |
617 } | 595 } |
618 A newA() => new A(); | 596 A newA() => new A(); |
619 B newB() => new B(); | 597 B newB() => new B(); |
620 C newC() => new C(); | 598 C newC() => new C(); |
621 '''); | 599 '''); |
622 checkElementText( | 600 checkElementText(library, r''' |
623 library, | |
624 r''' | |
625 class A { | 601 class A { |
626 int f; | 602 int f; |
627 } | 603 } |
628 class B { | 604 class B { |
629 A a; | 605 A a; |
630 } | 606 } |
631 class C { | 607 class C { |
632 B b; | 608 B b; |
633 } | 609 } |
634 class X { | 610 class X { |
(...skipping 17 matching lines...) Expand all Loading... |
652 } | 628 } |
653 | 629 |
654 test_initializer_error_extractProperty() async { | 630 test_initializer_error_extractProperty() async { |
655 var library = await _encodeDecodeLibrary(r''' | 631 var library = await _encodeDecodeLibrary(r''' |
656 class C { | 632 class C { |
657 bool b; | 633 bool b; |
658 } | 634 } |
659 C f() => null; | 635 C f() => null; |
660 var x = f().b; | 636 var x = f().b; |
661 '''); | 637 '''); |
662 checkElementText( | 638 checkElementText(library, r''' |
663 library, | |
664 r''' | |
665 class C { | 639 class C { |
666 bool b; | 640 bool b; |
667 } | 641 } |
668 dynamic x/*error: instanceGetter*/; | 642 dynamic x/*error: instanceGetter*/; |
669 C f() {} | 643 C f() {} |
670 '''); | 644 '''); |
671 } | 645 } |
672 | 646 |
673 test_initializer_error_extractProperty_inOtherLibraryCycle() async { | 647 test_initializer_error_extractProperty_inOtherLibraryCycle() async { |
674 addFile( | 648 addFile('/a.dart', r''' |
675 '/a.dart', | |
676 r''' | |
677 import 'b.dart'; | 649 import 'b.dart'; |
678 var x = new C().f; | 650 var x = new C().f; |
679 '''); | 651 '''); |
680 addFile( | 652 addFile('/b.dart', r''' |
681 '/b.dart', | |
682 r''' | |
683 class C { | 653 class C { |
684 var f = 0; | 654 var f = 0; |
685 } | 655 } |
686 '''); | 656 '''); |
687 var library = await _encodeDecodeLibrary(r''' | 657 var library = await _encodeDecodeLibrary(r''' |
688 import 'a.dart'; | 658 import 'a.dart'; |
689 var t1 = x; | 659 var t1 = x; |
690 '''); | 660 '''); |
691 checkElementText( | 661 checkElementText(library, r''' |
692 library, | |
693 r''' | |
694 import 'a.dart'; | 662 import 'a.dart'; |
695 dynamic t1; | 663 dynamic t1; |
696 '''); | 664 '''); |
697 } | 665 } |
698 | 666 |
699 test_initializer_error_extractProperty_inStaticField() async { | 667 test_initializer_error_extractProperty_inStaticField() async { |
700 var library = await _encodeDecodeLibrary(r''' | 668 var library = await _encodeDecodeLibrary(r''' |
701 class A { | 669 class A { |
702 int f; | 670 int f; |
703 } | 671 } |
704 class B { | 672 class B { |
705 static var t = new A().f; | 673 static var t = new A().f; |
706 } | 674 } |
707 '''); | 675 '''); |
708 checkElementText( | 676 checkElementText(library, r''' |
709 library, | |
710 r''' | |
711 class A { | 677 class A { |
712 int f; | 678 int f; |
713 } | 679 } |
714 class B { | 680 class B { |
715 static dynamic t/*error: instanceGetter*/; | 681 static dynamic t/*error: instanceGetter*/; |
716 } | 682 } |
717 '''); | 683 '''); |
718 } | 684 } |
719 | 685 |
720 test_initializer_error_extractProperty_prefixedIdentifier() async { | 686 test_initializer_error_extractProperty_prefixedIdentifier() async { |
721 var library = await _encodeDecodeLibrary(r''' | 687 var library = await _encodeDecodeLibrary(r''' |
722 class C { | 688 class C { |
723 bool b; | 689 bool b; |
724 } | 690 } |
725 C c; | 691 C c; |
726 var x = c.b; | 692 var x = c.b; |
727 '''); | 693 '''); |
728 checkElementText( | 694 checkElementText(library, r''' |
729 library, | |
730 r''' | |
731 class C { | 695 class C { |
732 bool b; | 696 bool b; |
733 } | 697 } |
734 C c; | 698 C c; |
735 dynamic x/*error: instanceGetter*/; | 699 dynamic x/*error: instanceGetter*/; |
736 '''); | 700 '''); |
737 } | 701 } |
738 | 702 |
739 test_initializer_error_extractProperty_prefixedIdentifier_viaInterface() async
{ | 703 test_initializer_error_extractProperty_prefixedIdentifier_viaInterface() async
{ |
740 var library = await _encodeDecodeLibrary(r''' | 704 var library = await _encodeDecodeLibrary(r''' |
741 class I { | 705 class I { |
742 bool b; | 706 bool b; |
743 } | 707 } |
744 abstract class C implements I {} | 708 abstract class C implements I {} |
745 C c; | 709 C c; |
746 var x = c.b; | 710 var x = c.b; |
747 '''); | 711 '''); |
748 checkElementText( | 712 checkElementText(library, r''' |
749 library, | |
750 r''' | |
751 class I { | 713 class I { |
752 bool b; | 714 bool b; |
753 } | 715 } |
754 abstract class C implements I { | 716 abstract class C implements I { |
755 } | 717 } |
756 C c; | 718 C c; |
757 dynamic x/*error: instanceGetter*/; | 719 dynamic x/*error: instanceGetter*/; |
758 '''); | 720 '''); |
759 } | 721 } |
760 | 722 |
761 test_initializer_error_extractProperty_viaInterface() async { | 723 test_initializer_error_extractProperty_viaInterface() async { |
762 var library = await _encodeDecodeLibrary(r''' | 724 var library = await _encodeDecodeLibrary(r''' |
763 class I { | 725 class I { |
764 bool b; | 726 bool b; |
765 } | 727 } |
766 abstract class C implements I {} | 728 abstract class C implements I {} |
767 C f() => null; | 729 C f() => null; |
768 var x = f().b; | 730 var x = f().b; |
769 '''); | 731 '''); |
770 checkElementText( | 732 checkElementText(library, r''' |
771 library, | |
772 r''' | |
773 class I { | 733 class I { |
774 bool b; | 734 bool b; |
775 } | 735 } |
776 abstract class C implements I { | 736 abstract class C implements I { |
777 } | 737 } |
778 dynamic x/*error: instanceGetter*/; | 738 dynamic x/*error: instanceGetter*/; |
779 C f() {} | 739 C f() {} |
780 '''); | 740 '''); |
781 } | 741 } |
782 | 742 |
783 test_initializer_error_instanceGetterOfObject() async { | 743 test_initializer_error_instanceGetterOfObject() async { |
784 var library = await _encodeDecodeLibrary(r''' | 744 var library = await _encodeDecodeLibrary(r''' |
785 dynamic f() => null; | 745 dynamic f() => null; |
786 var s = f().toString(); | 746 var s = f().toString(); |
787 var h = f().hashCode; | 747 var h = f().hashCode; |
788 '''); | 748 '''); |
789 checkElementText( | 749 checkElementText(library, r''' |
790 library, | |
791 r''' | |
792 String s; | 750 String s; |
793 dynamic h/*error: instanceGetter*/; | 751 dynamic h/*error: instanceGetter*/; |
794 dynamic f() {} | 752 dynamic f() {} |
795 '''); | 753 '''); |
796 } | 754 } |
797 | 755 |
798 test_initializer_error_instanceGetterOfObject_prefixed() async { | 756 test_initializer_error_instanceGetterOfObject_prefixed() async { |
799 var library = await _encodeDecodeLibrary(r''' | 757 var library = await _encodeDecodeLibrary(r''' |
800 dynamic d; | 758 dynamic d; |
801 var s = d.toString(); | 759 var s = d.toString(); |
802 var h = d.hashCode; | 760 var h = d.hashCode; |
803 '''); | 761 '''); |
804 checkElementText( | 762 checkElementText(library, r''' |
805 library, | |
806 r''' | |
807 dynamic d; | 763 dynamic d; |
808 String s; | 764 String s; |
809 dynamic h/*error: instanceGetter*/; | 765 dynamic h/*error: instanceGetter*/; |
810 '''); | 766 '''); |
811 } | 767 } |
812 | 768 |
813 test_initializer_error_methodInvocation_cycle_topLevel() async { | 769 test_initializer_error_methodInvocation_cycle_topLevel() async { |
814 var library = await _encodeDecodeLibrary(r''' | 770 var library = await _encodeDecodeLibrary(r''' |
815 var a = b.foo(); | 771 var a = b.foo(); |
816 var b = a.foo(); | 772 var b = a.foo(); |
817 '''); | 773 '''); |
818 checkElementText( | 774 checkElementText(library, r''' |
819 library, | |
820 r''' | |
821 dynamic a/*error: dependencyCycle*/; | 775 dynamic a/*error: dependencyCycle*/; |
822 dynamic b/*error: dependencyCycle*/; | 776 dynamic b/*error: dependencyCycle*/; |
823 '''); | 777 '''); |
824 } | 778 } |
825 | 779 |
826 test_initializer_error_methodInvocation_cycle_topLevel_self() async { | 780 test_initializer_error_methodInvocation_cycle_topLevel_self() async { |
827 var library = await _encodeDecodeLibrary(r''' | 781 var library = await _encodeDecodeLibrary(r''' |
828 var a = a.foo(); | 782 var a = a.foo(); |
829 '''); | 783 '''); |
830 checkElementText( | 784 checkElementText(library, r''' |
831 library, | |
832 r''' | |
833 dynamic a/*error: dependencyCycle*/; | 785 dynamic a/*error: dependencyCycle*/; |
834 '''); | 786 '''); |
835 } | 787 } |
836 | 788 |
837 test_initializer_error_referenceToFieldOfStaticField() async { | 789 test_initializer_error_referenceToFieldOfStaticField() async { |
838 var library = await _encodeDecodeLibrary(r''' | 790 var library = await _encodeDecodeLibrary(r''' |
839 class C { | 791 class C { |
840 static D d; | 792 static D d; |
841 } | 793 } |
842 class D { | 794 class D { |
843 int i; | 795 int i; |
844 } | 796 } |
845 final x = C.d.i; | 797 final x = C.d.i; |
846 '''); | 798 '''); |
847 checkElementText( | 799 checkElementText(library, r''' |
848 library, | |
849 r''' | |
850 class C { | 800 class C { |
851 static D d; | 801 static D d; |
852 } | 802 } |
853 class D { | 803 class D { |
854 int i; | 804 int i; |
855 } | 805 } |
856 final dynamic x/*error: instanceGetter*/; | 806 final dynamic x/*error: instanceGetter*/; |
857 '''); | 807 '''); |
858 } | 808 } |
859 | 809 |
860 test_initializer_error_referenceToFieldOfStaticGetter() async { | 810 test_initializer_error_referenceToFieldOfStaticGetter() async { |
861 var library = await _encodeDecodeLibrary(r''' | 811 var library = await _encodeDecodeLibrary(r''' |
862 class C { | 812 class C { |
863 static D get d => null; | 813 static D get d => null; |
864 } | 814 } |
865 class D { | 815 class D { |
866 int i; | 816 int i; |
867 } | 817 } |
868 var x = C.d.i; | 818 var x = C.d.i; |
869 '''); | 819 '''); |
870 checkElementText( | 820 checkElementText(library, r''' |
871 library, | |
872 r''' | |
873 class C { | 821 class C { |
874 static D get d {} | 822 static D get d {} |
875 } | 823 } |
876 class D { | 824 class D { |
877 int i; | 825 int i; |
878 } | 826 } |
879 dynamic x/*error: instanceGetter*/; | 827 dynamic x/*error: instanceGetter*/; |
880 '''); | 828 '''); |
881 } | 829 } |
882 | 830 |
883 test_initializer_extractIndex() async { | 831 test_initializer_extractIndex() async { |
884 var library = await _encodeDecodeLibrary(r''' | 832 var library = await _encodeDecodeLibrary(r''' |
885 var a = [0, 1.2]; | 833 var a = [0, 1.2]; |
886 var b0 = a[0]; | 834 var b0 = a[0]; |
887 var b1 = a[1]; | 835 var b1 = a[1]; |
888 '''); | 836 '''); |
889 checkElementText( | 837 checkElementText(library, r''' |
890 library, | |
891 r''' | |
892 List<num> a; | 838 List<num> a; |
893 num b0; | 839 num b0; |
894 num b1; | 840 num b1; |
895 '''); | 841 '''); |
896 } | 842 } |
897 | 843 |
898 test_initializer_functionExpression() async { | 844 test_initializer_functionExpression() async { |
899 var library = await _encodeDecodeLibrary(r''' | 845 var library = await _encodeDecodeLibrary(r''' |
900 import 'dart:async'; | 846 import 'dart:async'; |
901 var vFuture = new Future<int>(42); | 847 var vFuture = new Future<int>(42); |
902 var v_noParameters_inferredReturnType = () => 42; | 848 var v_noParameters_inferredReturnType = () => 42; |
903 var v_hasParameter_withType_inferredReturnType = (String a) => 42; | 849 var v_hasParameter_withType_inferredReturnType = (String a) => 42; |
904 var v_hasParameter_withType_returnParameter = (String a) => a; | 850 var v_hasParameter_withType_returnParameter = (String a) => a; |
905 var v_async_returnValue = () async => 42; | 851 var v_async_returnValue = () async => 42; |
906 var v_async_returnFuture = () async => vFuture; | 852 var v_async_returnFuture = () async => vFuture; |
907 '''); | 853 '''); |
908 checkElementText( | 854 checkElementText(library, r''' |
909 library, | |
910 r''' | |
911 import 'dart:async'; | 855 import 'dart:async'; |
912 Future<int> vFuture; | 856 Future<int> vFuture; |
913 () → int v_noParameters_inferredReturnType; | 857 () → int v_noParameters_inferredReturnType; |
914 (String) → int v_hasParameter_withType_inferredReturnType; | 858 (String) → int v_hasParameter_withType_inferredReturnType; |
915 (String) → String v_hasParameter_withType_returnParameter; | 859 (String) → String v_hasParameter_withType_returnParameter; |
916 () → Future<int> v_async_returnValue; | 860 () → Future<int> v_async_returnValue; |
917 () → Future<int> v_async_returnFuture; | 861 () → Future<int> v_async_returnFuture; |
918 '''); | 862 '''); |
919 } | 863 } |
920 | 864 |
921 @failingTest | 865 @failingTest |
922 test_initializer_functionExpressionInvocation_noTypeParameters() async { | 866 test_initializer_functionExpressionInvocation_noTypeParameters() async { |
923 var library = await _encodeDecodeLibrary(r''' | 867 var library = await _encodeDecodeLibrary(r''' |
924 var v = (() => 42)(); | 868 var v = (() => 42)(); |
925 '''); | 869 '''); |
926 // TODO(scheglov) add more function expression tests | 870 // TODO(scheglov) add more function expression tests |
927 checkElementText( | 871 checkElementText(library, r''' |
928 library, | |
929 r''' | |
930 int v; | 872 int v; |
931 '''); | 873 '''); |
932 } | 874 } |
933 | 875 |
934 test_initializer_functionInvocation_hasTypeParameters() async { | 876 test_initializer_functionInvocation_hasTypeParameters() async { |
935 var library = await _encodeDecodeLibrary(r''' | 877 var library = await _encodeDecodeLibrary(r''' |
936 T f<T>() => null; | 878 T f<T>() => null; |
937 var vHasTypeArgument = f<int>(); | 879 var vHasTypeArgument = f<int>(); |
938 var vNoTypeArgument = f(); | 880 var vNoTypeArgument = f(); |
939 '''); | 881 '''); |
940 checkElementText( | 882 checkElementText(library, r''' |
941 library, | |
942 r''' | |
943 int vHasTypeArgument; | 883 int vHasTypeArgument; |
944 dynamic vNoTypeArgument; | 884 dynamic vNoTypeArgument; |
945 T f<T>() {} | 885 T f<T>() {} |
946 '''); | 886 '''); |
947 } | 887 } |
948 | 888 |
949 test_initializer_functionInvocation_noTypeParameters() async { | 889 test_initializer_functionInvocation_noTypeParameters() async { |
950 var library = await _encodeDecodeLibrary(r''' | 890 var library = await _encodeDecodeLibrary(r''' |
951 String f(int p) => null; | 891 String f(int p) => null; |
952 var vOkArgumentType = f(1); | 892 var vOkArgumentType = f(1); |
953 var vWrongArgumentType = f(2.0); | 893 var vWrongArgumentType = f(2.0); |
954 '''); | 894 '''); |
955 checkElementText( | 895 checkElementText(library, r''' |
956 library, | |
957 r''' | |
958 String vOkArgumentType; | 896 String vOkArgumentType; |
959 String vWrongArgumentType; | 897 String vWrongArgumentType; |
960 String f(int p) {} | 898 String f(int p) {} |
961 '''); | 899 '''); |
962 } | 900 } |
963 | 901 |
964 test_initializer_identifier() async { | 902 test_initializer_identifier() async { |
965 var library = await _encodeDecodeLibrary(r''' | 903 var library = await _encodeDecodeLibrary(r''' |
966 String topLevelFunction(int p) => null; | 904 String topLevelFunction(int p) => null; |
967 var topLevelVariable = 0; | 905 var topLevelVariable = 0; |
968 int get topLevelGetter => 0; | 906 int get topLevelGetter => 0; |
969 class A { | 907 class A { |
970 static var staticClassVariable = 0; | 908 static var staticClassVariable = 0; |
971 static int get staticGetter => 0; | 909 static int get staticGetter => 0; |
972 static String staticClassMethod(int p) => null; | 910 static String staticClassMethod(int p) => null; |
973 String instanceClassMethod(int p) => null; | 911 String instanceClassMethod(int p) => null; |
974 } | 912 } |
975 var r_topLevelFunction = topLevelFunction; | 913 var r_topLevelFunction = topLevelFunction; |
976 var r_topLevelVariable = topLevelVariable; | 914 var r_topLevelVariable = topLevelVariable; |
977 var r_topLevelGetter = topLevelGetter; | 915 var r_topLevelGetter = topLevelGetter; |
978 var r_staticClassVariable = A.staticClassVariable; | 916 var r_staticClassVariable = A.staticClassVariable; |
979 var r_staticGetter = A.staticGetter; | 917 var r_staticGetter = A.staticGetter; |
980 var r_staticClassMethod = A.staticClassMethod; | 918 var r_staticClassMethod = A.staticClassMethod; |
981 var instanceOfA = new A(); | 919 var instanceOfA = new A(); |
982 var r_instanceClassMethod = instanceOfA.instanceClassMethod; | 920 var r_instanceClassMethod = instanceOfA.instanceClassMethod; |
983 '''); | 921 '''); |
984 checkElementText( | 922 checkElementText(library, r''' |
985 library, | |
986 r''' | |
987 class A { | 923 class A { |
988 static int staticClassVariable; | 924 static int staticClassVariable; |
989 static int get staticGetter {} | 925 static int get staticGetter {} |
990 static String staticClassMethod(int p) {} | 926 static String staticClassMethod(int p) {} |
991 String instanceClassMethod(int p) {} | 927 String instanceClassMethod(int p) {} |
992 } | 928 } |
993 int topLevelVariable; | 929 int topLevelVariable; |
994 (int) → String r_topLevelFunction; | 930 (int) → String r_topLevelFunction; |
995 int r_topLevelVariable; | 931 int r_topLevelVariable; |
996 int r_topLevelGetter; | 932 int r_topLevelGetter; |
(...skipping 10 matching lines...) Expand all Loading... |
1007 test_initializer_identifier_error_cycle_classField() async { | 943 test_initializer_identifier_error_cycle_classField() async { |
1008 var library = await _encodeDecodeLibrary(r''' | 944 var library = await _encodeDecodeLibrary(r''' |
1009 class A { | 945 class A { |
1010 static var a = B.b; | 946 static var a = B.b; |
1011 } | 947 } |
1012 class B { | 948 class B { |
1013 static var b = A.a; | 949 static var b = A.a; |
1014 } | 950 } |
1015 var c = A.a; | 951 var c = A.a; |
1016 '''); | 952 '''); |
1017 checkElementText( | 953 checkElementText(library, r''' |
1018 library, | |
1019 r''' | |
1020 class A { | 954 class A { |
1021 static dynamic a/*error: dependencyCycle*/; | 955 static dynamic a/*error: dependencyCycle*/; |
1022 } | 956 } |
1023 class B { | 957 class B { |
1024 static dynamic b/*error: dependencyCycle*/; | 958 static dynamic b/*error: dependencyCycle*/; |
1025 } | 959 } |
1026 dynamic c; | 960 dynamic c; |
1027 '''); | 961 '''); |
1028 } | 962 } |
1029 | 963 |
1030 test_initializer_identifier_error_cycle_mix() async { | 964 test_initializer_identifier_error_cycle_mix() async { |
1031 var library = await _encodeDecodeLibrary(r''' | 965 var library = await _encodeDecodeLibrary(r''' |
1032 class A { | 966 class A { |
1033 static var a = b; | 967 static var a = b; |
1034 } | 968 } |
1035 var b = A.a; | 969 var b = A.a; |
1036 var c = b; | 970 var c = b; |
1037 '''); | 971 '''); |
1038 checkElementText( | 972 checkElementText(library, r''' |
1039 library, | |
1040 r''' | |
1041 class A { | 973 class A { |
1042 static dynamic a/*error: dependencyCycle*/; | 974 static dynamic a/*error: dependencyCycle*/; |
1043 } | 975 } |
1044 dynamic b/*error: dependencyCycle*/; | 976 dynamic b/*error: dependencyCycle*/; |
1045 dynamic c; | 977 dynamic c; |
1046 '''); | 978 '''); |
1047 } | 979 } |
1048 | 980 |
1049 test_initializer_identifier_error_cycle_topLevel() async { | 981 test_initializer_identifier_error_cycle_topLevel() async { |
1050 var library = await _encodeDecodeLibrary(r''' | 982 var library = await _encodeDecodeLibrary(r''' |
1051 var a = b; | 983 var a = b; |
1052 var b = c; | 984 var b = c; |
1053 var c = a; | 985 var c = a; |
1054 var d = a; | 986 var d = a; |
1055 '''); | 987 '''); |
1056 checkElementText( | 988 checkElementText(library, r''' |
1057 library, | |
1058 r''' | |
1059 dynamic a/*error: dependencyCycle*/; | 989 dynamic a/*error: dependencyCycle*/; |
1060 dynamic b/*error: dependencyCycle*/; | 990 dynamic b/*error: dependencyCycle*/; |
1061 dynamic c/*error: dependencyCycle*/; | 991 dynamic c/*error: dependencyCycle*/; |
1062 dynamic d; | 992 dynamic d; |
1063 '''); | 993 '''); |
1064 } | 994 } |
1065 | 995 |
1066 test_initializer_identifier_formalParameter() async { | 996 test_initializer_identifier_formalParameter() async { |
1067 // TODO(scheglov) I don't understand this yet | 997 // TODO(scheglov) I don't understand this yet |
1068 } | 998 } |
1069 | 999 |
1070 @failingTest | 1000 @failingTest |
1071 test_initializer_instanceCreation_hasTypeParameter() async { | 1001 test_initializer_instanceCreation_hasTypeParameter() async { |
1072 var library = await _encodeDecodeLibrary(r''' | 1002 var library = await _encodeDecodeLibrary(r''' |
1073 class A<T> {} | 1003 class A<T> {} |
1074 var a = new A<int>(); | 1004 var a = new A<int>(); |
1075 var b = new A(); | 1005 var b = new A(); |
1076 '''); | 1006 '''); |
1077 // TODO(scheglov) test for inference failure error | 1007 // TODO(scheglov) test for inference failure error |
1078 checkElementText( | 1008 checkElementText(library, r''' |
1079 library, | |
1080 r''' | |
1081 class A<T> { | 1009 class A<T> { |
1082 } | 1010 } |
1083 A<int> a; | 1011 A<int> a; |
1084 dynamic b; | 1012 dynamic b; |
1085 '''); | 1013 '''); |
1086 } | 1014 } |
1087 | 1015 |
1088 test_initializer_instanceCreation_noTypeParameters() async { | 1016 test_initializer_instanceCreation_noTypeParameters() async { |
1089 var library = await _encodeDecodeLibrary(r''' | 1017 var library = await _encodeDecodeLibrary(r''' |
1090 class A {} | 1018 class A {} |
1091 var a = new A(); | 1019 var a = new A(); |
1092 '''); | 1020 '''); |
1093 checkElementText( | 1021 checkElementText(library, r''' |
1094 library, | |
1095 r''' | |
1096 class A { | 1022 class A { |
1097 } | 1023 } |
1098 A a; | 1024 A a; |
1099 '''); | 1025 '''); |
1100 } | 1026 } |
1101 | 1027 |
1102 test_initializer_is() async { | 1028 test_initializer_is() async { |
1103 var library = await _encodeDecodeLibrary(r''' | 1029 var library = await _encodeDecodeLibrary(r''' |
1104 var a = 1.2; | 1030 var a = 1.2; |
1105 var b = a is int; | 1031 var b = a is int; |
1106 '''); | 1032 '''); |
1107 checkElementText( | 1033 checkElementText(library, r''' |
1108 library, | |
1109 r''' | |
1110 double a; | 1034 double a; |
1111 bool b; | 1035 bool b; |
1112 '''); | 1036 '''); |
1113 } | 1037 } |
1114 | 1038 |
1115 @failingTest | 1039 @failingTest |
1116 test_initializer_literal() async { | 1040 test_initializer_literal() async { |
1117 var library = await _encodeDecodeLibrary(r''' | 1041 var library = await _encodeDecodeLibrary(r''' |
1118 var vNull = null; | 1042 var vNull = null; |
1119 var vBoolFalse = false; | 1043 var vBoolFalse = false; |
1120 var vBoolTrue = true; | 1044 var vBoolTrue = true; |
1121 var vInt = 1; | 1045 var vInt = 1; |
1122 var vIntLong = 0x9876543210987654321; | 1046 var vIntLong = 0x9876543210987654321; |
1123 var vDouble = 2.3; | 1047 var vDouble = 2.3; |
1124 var vString = 'abc'; | 1048 var vString = 'abc'; |
1125 var vStringConcat = 'aaa' 'bbb'; | 1049 var vStringConcat = 'aaa' 'bbb'; |
1126 var vStringInterpolation = 'aaa ${true} ${42} bbb'; | 1050 var vStringInterpolation = 'aaa ${true} ${42} bbb'; |
1127 var vSymbol = #aaa.bbb.ccc; | 1051 var vSymbol = #aaa.bbb.ccc; |
1128 '''); | 1052 '''); |
1129 checkElementText( | 1053 checkElementText(library, r''' |
1130 library, | |
1131 r''' | |
1132 Null vNull; | 1054 Null vNull; |
1133 bool vBoolFalse; | 1055 bool vBoolFalse; |
1134 bool vBoolTrue; | 1056 bool vBoolTrue; |
1135 int vInt; | 1057 int vInt; |
1136 int vIntLong; | 1058 int vIntLong; |
1137 double vDouble; | 1059 double vDouble; |
1138 String vString; | 1060 String vString; |
1139 String vStringConcat; | 1061 String vStringConcat; |
1140 String vStringInterpolation; | 1062 String vStringInterpolation; |
1141 Symbol vSymbol; | 1063 Symbol vSymbol; |
1142 '''); | 1064 '''); |
1143 } | 1065 } |
1144 | 1066 |
1145 test_initializer_literal_list_typed() async { | 1067 test_initializer_literal_list_typed() async { |
1146 var library = await _encodeDecodeLibrary(r''' | 1068 var library = await _encodeDecodeLibrary(r''' |
1147 var vObject = <Object>[1, 2, 3]; | 1069 var vObject = <Object>[1, 2, 3]; |
1148 var vNum = <num>[1, 2, 3]; | 1070 var vNum = <num>[1, 2, 3]; |
1149 var vNumEmpty = <num>[]; | 1071 var vNumEmpty = <num>[]; |
1150 var vInt = <int>[1, 2, 3]; | 1072 var vInt = <int>[1, 2, 3]; |
1151 '''); | 1073 '''); |
1152 checkElementText( | 1074 checkElementText(library, r''' |
1153 library, | |
1154 r''' | |
1155 List<Object> vObject; | 1075 List<Object> vObject; |
1156 List<num> vNum; | 1076 List<num> vNum; |
1157 List<num> vNumEmpty; | 1077 List<num> vNumEmpty; |
1158 List<int> vInt; | 1078 List<int> vInt; |
1159 '''); | 1079 '''); |
1160 } | 1080 } |
1161 | 1081 |
1162 test_initializer_literal_list_untyped() async { | 1082 test_initializer_literal_list_untyped() async { |
1163 var library = await _encodeDecodeLibrary(r''' | 1083 var library = await _encodeDecodeLibrary(r''' |
1164 var vInt = [1, 2, 3]; | 1084 var vInt = [1, 2, 3]; |
1165 var vNum = [1, 2.0]; | 1085 var vNum = [1, 2.0]; |
1166 var vObject = [1, 2.0, '333']; | 1086 var vObject = [1, 2.0, '333']; |
1167 '''); | 1087 '''); |
1168 checkElementText( | 1088 checkElementText(library, r''' |
1169 library, | |
1170 r''' | |
1171 List<int> vInt; | 1089 List<int> vInt; |
1172 List<num> vNum; | 1090 List<num> vNum; |
1173 List<Object> vObject; | 1091 List<Object> vObject; |
1174 '''); | 1092 '''); |
1175 } | 1093 } |
1176 | 1094 |
1177 @failingTest | 1095 @failingTest |
1178 test_initializer_literal_list_untyped_empty() async { | 1096 test_initializer_literal_list_untyped_empty() async { |
1179 var library = await _encodeDecodeLibrary(r''' | 1097 var library = await _encodeDecodeLibrary(r''' |
1180 var vNonConst = []; | 1098 var vNonConst = []; |
1181 var vConst = const []; | 1099 var vConst = const []; |
1182 '''); | 1100 '''); |
1183 checkElementText( | 1101 checkElementText(library, r''' |
1184 library, | |
1185 r''' | |
1186 List<dynamic> vNonConst; | 1102 List<dynamic> vNonConst; |
1187 List<Null> vConst; | 1103 List<Null> vConst; |
1188 '''); | 1104 '''); |
1189 } | 1105 } |
1190 | 1106 |
1191 test_initializer_literal_map_typed() async { | 1107 test_initializer_literal_map_typed() async { |
1192 var library = await _encodeDecodeLibrary(r''' | 1108 var library = await _encodeDecodeLibrary(r''' |
1193 var vObjectObject = <Object, Object>{1: 'a'}; | 1109 var vObjectObject = <Object, Object>{1: 'a'}; |
1194 var vComparableObject = <Comparable<int>, Object>{1: 'a'}; | 1110 var vComparableObject = <Comparable<int>, Object>{1: 'a'}; |
1195 var vNumString = <num, String>{1: 'a'}; | 1111 var vNumString = <num, String>{1: 'a'}; |
1196 var vNumStringEmpty = <num, String>{}; | 1112 var vNumStringEmpty = <num, String>{}; |
1197 var vIntString = <int, String>{}; | 1113 var vIntString = <int, String>{}; |
1198 '''); | 1114 '''); |
1199 checkElementText( | 1115 checkElementText(library, r''' |
1200 library, | |
1201 r''' | |
1202 Map<Object, Object> vObjectObject; | 1116 Map<Object, Object> vObjectObject; |
1203 Map<Comparable<int>, Object> vComparableObject; | 1117 Map<Comparable<int>, Object> vComparableObject; |
1204 Map<num, String> vNumString; | 1118 Map<num, String> vNumString; |
1205 Map<num, String> vNumStringEmpty; | 1119 Map<num, String> vNumStringEmpty; |
1206 Map<int, String> vIntString; | 1120 Map<int, String> vIntString; |
1207 '''); | 1121 '''); |
1208 } | 1122 } |
1209 | 1123 |
1210 test_initializer_literal_map_untyped() async { | 1124 test_initializer_literal_map_untyped() async { |
1211 var library = await _encodeDecodeLibrary(r''' | 1125 var library = await _encodeDecodeLibrary(r''' |
1212 var vIntString = {1: 'a', 2: 'b'}; | 1126 var vIntString = {1: 'a', 2: 'b'}; |
1213 var vNumString = {1: 'a', 2.0: 'b'}; | 1127 var vNumString = {1: 'a', 2.0: 'b'}; |
1214 var vIntObject = {1: 'a', 2: 3.0}; | 1128 var vIntObject = {1: 'a', 2: 3.0}; |
1215 '''); | 1129 '''); |
1216 checkElementText( | 1130 checkElementText(library, r''' |
1217 library, | |
1218 r''' | |
1219 Map<int, String> vIntString; | 1131 Map<int, String> vIntString; |
1220 Map<num, String> vNumString; | 1132 Map<num, String> vNumString; |
1221 Map<int, Object> vIntObject; | 1133 Map<int, Object> vIntObject; |
1222 '''); | 1134 '''); |
1223 } | 1135 } |
1224 | 1136 |
1225 @failingTest | 1137 @failingTest |
1226 test_initializer_literal_map_untyped_empty() async { | 1138 test_initializer_literal_map_untyped_empty() async { |
1227 var library = await _encodeDecodeLibrary(r''' | 1139 var library = await _encodeDecodeLibrary(r''' |
1228 var vNonConst = {}; | 1140 var vNonConst = {}; |
1229 var vConst = const {}; | 1141 var vConst = const {}; |
1230 '''); | 1142 '''); |
1231 checkElementText( | 1143 checkElementText(library, r''' |
1232 library, | |
1233 r''' | |
1234 Map<dynamic, dynamic> vNonConst; | 1144 Map<dynamic, dynamic> vNonConst; |
1235 Map<Null, Null> vConst; | 1145 Map<Null, Null> vConst; |
1236 '''); | 1146 '''); |
1237 } | 1147 } |
1238 | 1148 |
1239 test_initializer_logicalBool() async { | 1149 test_initializer_logicalBool() async { |
1240 var library = await _encodeDecodeLibrary(r''' | 1150 var library = await _encodeDecodeLibrary(r''' |
1241 var a = true; | 1151 var a = true; |
1242 var b = true; | 1152 var b = true; |
1243 var vEq = 1 == 2; | 1153 var vEq = 1 == 2; |
1244 var vAnd = a && b; | 1154 var vAnd = a && b; |
1245 var vOr = a || b; | 1155 var vOr = a || b; |
1246 '''); | 1156 '''); |
1247 checkElementText( | 1157 checkElementText(library, r''' |
1248 library, | |
1249 r''' | |
1250 bool a; | 1158 bool a; |
1251 bool b; | 1159 bool b; |
1252 bool vEq; | 1160 bool vEq; |
1253 bool vAnd; | 1161 bool vAnd; |
1254 bool vOr; | 1162 bool vOr; |
1255 '''); | 1163 '''); |
1256 } | 1164 } |
1257 | 1165 |
1258 @failingTest | 1166 @failingTest |
1259 test_initializer_methodInvocation_hasTypeParameters() async { | 1167 test_initializer_methodInvocation_hasTypeParameters() async { |
1260 var library = await _encodeDecodeLibrary(r''' | 1168 var library = await _encodeDecodeLibrary(r''' |
1261 class A { | 1169 class A { |
1262 List<T> m<T>() => null; | 1170 List<T> m<T>() => null; |
1263 } | 1171 } |
1264 var vWithTypeArgument = new A().m<int>(); | 1172 var vWithTypeArgument = new A().m<int>(); |
1265 var vWithoutTypeArgument = new A().m(); | 1173 var vWithoutTypeArgument = new A().m(); |
1266 '''); | 1174 '''); |
1267 // TODO(scheglov) test for inference failure error | 1175 // TODO(scheglov) test for inference failure error |
1268 checkElementText( | 1176 checkElementText(library, r''' |
1269 library, | |
1270 r''' | |
1271 class A { | 1177 class A { |
1272 List<T> m<T>(int p) {} | 1178 List<T> m<T>(int p) {} |
1273 } | 1179 } |
1274 List<int> vWithTypeArgument; | 1180 List<int> vWithTypeArgument; |
1275 dynamic vWithoutTypeArgument; | 1181 dynamic vWithoutTypeArgument; |
1276 '''); | 1182 '''); |
1277 } | 1183 } |
1278 | 1184 |
1279 test_initializer_methodInvocation_noTypeParameters() async { | 1185 test_initializer_methodInvocation_noTypeParameters() async { |
1280 var library = await _encodeDecodeLibrary(r''' | 1186 var library = await _encodeDecodeLibrary(r''' |
1281 class A { | 1187 class A { |
1282 String m(int p) => null; | 1188 String m(int p) => null; |
1283 } | 1189 } |
1284 var instanceOfA = new A(); | 1190 var instanceOfA = new A(); |
1285 var v1 = instanceOfA.m(); | 1191 var v1 = instanceOfA.m(); |
1286 var v2 = new A().m(); | 1192 var v2 = new A().m(); |
1287 '''); | 1193 '''); |
1288 checkElementText( | 1194 checkElementText(library, r''' |
1289 library, | |
1290 r''' | |
1291 class A { | 1195 class A { |
1292 String m(int p) {} | 1196 String m(int p) {} |
1293 } | 1197 } |
1294 A instanceOfA; | 1198 A instanceOfA; |
1295 String v1; | 1199 String v1; |
1296 String v2; | 1200 String v2; |
1297 '''); | 1201 '''); |
1298 } | 1202 } |
1299 | 1203 |
1300 test_initializer_multiplicative() async { | 1204 test_initializer_multiplicative() async { |
1301 var library = await _encodeDecodeLibrary(r''' | 1205 var library = await _encodeDecodeLibrary(r''' |
1302 var vModuloIntInt = 1 % 2; | 1206 var vModuloIntInt = 1 % 2; |
1303 var vModuloIntDouble = 1 % 2.0; | 1207 var vModuloIntDouble = 1 % 2.0; |
1304 var vMultiplyIntInt = 1 * 2; | 1208 var vMultiplyIntInt = 1 * 2; |
1305 var vMultiplyIntDouble = 1 * 2.0; | 1209 var vMultiplyIntDouble = 1 * 2.0; |
1306 var vMultiplyDoubleInt = 1.0 * 2; | 1210 var vMultiplyDoubleInt = 1.0 * 2; |
1307 var vMultiplyDoubleDouble = 1.0 * 2.0; | 1211 var vMultiplyDoubleDouble = 1.0 * 2.0; |
1308 var vDivideIntInt = 1 / 2; | 1212 var vDivideIntInt = 1 / 2; |
1309 var vDivideIntDouble = 1 / 2.0; | 1213 var vDivideIntDouble = 1 / 2.0; |
1310 var vDivideDoubleInt = 1.0 / 2; | 1214 var vDivideDoubleInt = 1.0 / 2; |
1311 var vDivideDoubleDouble = 1.0 / 2.0; | 1215 var vDivideDoubleDouble = 1.0 / 2.0; |
1312 var vFloorDivide = 1 ~/ 2; | 1216 var vFloorDivide = 1 ~/ 2; |
1313 '''); | 1217 '''); |
1314 checkElementText( | 1218 checkElementText(library, r''' |
1315 library, | |
1316 r''' | |
1317 int vModuloIntInt; | 1219 int vModuloIntInt; |
1318 double vModuloIntDouble; | 1220 double vModuloIntDouble; |
1319 int vMultiplyIntInt; | 1221 int vMultiplyIntInt; |
1320 double vMultiplyIntDouble; | 1222 double vMultiplyIntDouble; |
1321 double vMultiplyDoubleInt; | 1223 double vMultiplyDoubleInt; |
1322 double vMultiplyDoubleDouble; | 1224 double vMultiplyDoubleDouble; |
1323 double vDivideIntInt; | 1225 double vDivideIntInt; |
1324 double vDivideIntDouble; | 1226 double vDivideIntDouble; |
1325 double vDivideDoubleInt; | 1227 double vDivideDoubleInt; |
1326 double vDivideDoubleDouble; | 1228 double vDivideDoubleDouble; |
1327 int vFloorDivide; | 1229 int vFloorDivide; |
1328 '''); | 1230 '''); |
1329 } | 1231 } |
1330 | 1232 |
1331 @failingTest | 1233 @failingTest |
1332 test_initializer_onlyLeft() async { | 1234 test_initializer_onlyLeft() async { |
1333 var library = await _encodeDecodeLibrary(r''' | 1235 var library = await _encodeDecodeLibrary(r''' |
1334 var a = 1; | 1236 var a = 1; |
1335 var vEq = a == ((a = 2) == 0); | 1237 var vEq = a == ((a = 2) == 0); |
1336 var vNotEq = a != ((a = 2) == 0); | 1238 var vNotEq = a != ((a = 2) == 0); |
1337 '''); | 1239 '''); |
1338 checkElementText( | 1240 checkElementText(library, r''' |
1339 library, | |
1340 r''' | |
1341 int a; | 1241 int a; |
1342 bool vEq; | 1242 bool vEq; |
1343 bool vNotEq; | 1243 bool vNotEq; |
1344 '''); | 1244 '''); |
1345 } | 1245 } |
1346 | 1246 |
1347 test_initializer_parenthesized() async { | 1247 test_initializer_parenthesized() async { |
1348 var library = await _encodeDecodeLibrary(r''' | 1248 var library = await _encodeDecodeLibrary(r''' |
1349 var V = (42); | 1249 var V = (42); |
1350 '''); | 1250 '''); |
1351 checkElementText( | 1251 checkElementText(library, r''' |
1352 library, | |
1353 r''' | |
1354 int V; | 1252 int V; |
1355 '''); | 1253 '''); |
1356 } | 1254 } |
1357 | 1255 |
1358 @failingTest | 1256 @failingTest |
1359 test_initializer_postfix() async { | 1257 test_initializer_postfix() async { |
1360 var library = await _encodeDecodeLibrary(r''' | 1258 var library = await _encodeDecodeLibrary(r''' |
1361 var vInt = 1; | 1259 var vInt = 1; |
1362 var vDouble = 2; | 1260 var vDouble = 2; |
1363 var vIncInt = vInt++; | 1261 var vIncInt = vInt++; |
1364 var vDecInt = vInt--; | 1262 var vDecInt = vInt--; |
1365 var vIncDouble = vDouble++; | 1263 var vIncDouble = vDouble++; |
1366 var vDecDouble = vDouble--; | 1264 var vDecDouble = vDouble--; |
1367 '''); | 1265 '''); |
1368 checkElementText( | 1266 checkElementText(library, r''' |
1369 library, | |
1370 r''' | |
1371 int vInt; | 1267 int vInt; |
1372 int vDouble; | 1268 int vDouble; |
1373 int vIncInt; | 1269 int vIncInt; |
1374 int vDecInt; | 1270 int vDecInt; |
1375 double vIncDouble; | 1271 double vIncDouble; |
1376 double vDecDouble; | 1272 double vDecDouble; |
1377 '''); | 1273 '''); |
1378 } | 1274 } |
1379 | 1275 |
1380 @failingTest | 1276 @failingTest |
1381 test_initializer_prefix_incDec() async { | 1277 test_initializer_prefix_incDec() async { |
1382 var library = await _encodeDecodeLibrary(r''' | 1278 var library = await _encodeDecodeLibrary(r''' |
1383 var vInt = 1; | 1279 var vInt = 1; |
1384 var vDouble = 2.0; | 1280 var vDouble = 2.0; |
1385 var vIncInt = ++vInt; | 1281 var vIncInt = ++vInt; |
1386 var vDecInt = --vInt; | 1282 var vDecInt = --vInt; |
1387 var vIncDouble = ++vDouble; | 1283 var vIncDouble = ++vDouble; |
1388 var vDecInt = --vDouble; | 1284 var vDecInt = --vDouble; |
1389 '''); | 1285 '''); |
1390 checkElementText( | 1286 checkElementText(library, r''' |
1391 library, | |
1392 r''' | |
1393 int vInt; | 1287 int vInt; |
1394 double vDouble; | 1288 double vDouble; |
1395 int vIncInt; | 1289 int vIncInt; |
1396 int vDecInt; | 1290 int vDecInt; |
1397 double vIncDouble; | 1291 double vIncDouble; |
1398 double vDecInt; | 1292 double vDecInt; |
1399 '''); | 1293 '''); |
1400 } | 1294 } |
1401 | 1295 |
1402 @failingTest | 1296 @failingTest |
1403 test_initializer_prefix_incDec_custom() async { | 1297 test_initializer_prefix_incDec_custom() async { |
1404 var library = await _encodeDecodeLibrary(r''' | 1298 var library = await _encodeDecodeLibrary(r''' |
1405 class A { | 1299 class A { |
1406 B operator+(int v) => null; | 1300 B operator+(int v) => null; |
1407 } | 1301 } |
1408 class B {} | 1302 class B {} |
1409 var a = new A(); | 1303 var a = new A(); |
1410 var vInc = ++a; | 1304 var vInc = ++a; |
1411 var vDec = --a; | 1305 var vDec = --a; |
1412 '''); | 1306 '''); |
1413 checkElementText( | 1307 checkElementText(library, r''' |
1414 library, | |
1415 r''' | |
1416 A a; | 1308 A a; |
1417 B vInc; | 1309 B vInc; |
1418 B vDec; | 1310 B vDec; |
1419 '''); | 1311 '''); |
1420 } | 1312 } |
1421 | 1313 |
1422 test_initializer_prefix_not() async { | 1314 test_initializer_prefix_not() async { |
1423 var library = await _encodeDecodeLibrary(r''' | 1315 var library = await _encodeDecodeLibrary(r''' |
1424 var vNot = !true; | 1316 var vNot = !true; |
1425 '''); | 1317 '''); |
1426 checkElementText( | 1318 checkElementText(library, r''' |
1427 library, | |
1428 r''' | |
1429 bool vNot; | 1319 bool vNot; |
1430 '''); | 1320 '''); |
1431 } | 1321 } |
1432 | 1322 |
1433 test_initializer_prefix_other() async { | 1323 test_initializer_prefix_other() async { |
1434 var library = await _encodeDecodeLibrary(r''' | 1324 var library = await _encodeDecodeLibrary(r''' |
1435 var vNegateInt = -1; | 1325 var vNegateInt = -1; |
1436 var vNegateDouble = -1.0; | 1326 var vNegateDouble = -1.0; |
1437 var vComplement = ~1; | 1327 var vComplement = ~1; |
1438 '''); | 1328 '''); |
1439 checkElementText( | 1329 checkElementText(library, r''' |
1440 library, | |
1441 r''' | |
1442 int vNegateInt; | 1330 int vNegateInt; |
1443 double vNegateDouble; | 1331 double vNegateDouble; |
1444 int vComplement; | 1332 int vComplement; |
1445 '''); | 1333 '''); |
1446 } | 1334 } |
1447 | 1335 |
1448 test_initializer_relational() async { | 1336 test_initializer_relational() async { |
1449 var library = await _encodeDecodeLibrary(r''' | 1337 var library = await _encodeDecodeLibrary(r''' |
1450 var vLess = 1 < 2; | 1338 var vLess = 1 < 2; |
1451 var vLessOrEqual = 1 <= 2; | 1339 var vLessOrEqual = 1 <= 2; |
1452 var vGreater = 1 > 2; | 1340 var vGreater = 1 > 2; |
1453 var vGreaterOrEqual = 1 >= 2; | 1341 var vGreaterOrEqual = 1 >= 2; |
1454 '''); | 1342 '''); |
1455 checkElementText( | 1343 checkElementText(library, r''' |
1456 library, | |
1457 r''' | |
1458 bool vLess; | 1344 bool vLess; |
1459 bool vLessOrEqual; | 1345 bool vLessOrEqual; |
1460 bool vGreater; | 1346 bool vGreater; |
1461 bool vGreaterOrEqual; | 1347 bool vGreaterOrEqual; |
1462 '''); | 1348 '''); |
1463 } | 1349 } |
1464 | 1350 |
1465 @failingTest | 1351 @failingTest |
1466 test_initializer_throw() async { | 1352 test_initializer_throw() async { |
1467 var library = await _encodeDecodeLibrary(r''' | 1353 var library = await _encodeDecodeLibrary(r''' |
1468 var V = throw 42; | 1354 var V = throw 42; |
1469 '''); | 1355 '''); |
1470 checkElementText( | 1356 checkElementText(library, r''' |
1471 library, | |
1472 r''' | |
1473 Null V; | 1357 Null V; |
1474 '''); | 1358 '''); |
1475 } | 1359 } |
1476 | 1360 |
1477 test_instanceField_error_noSetterParameter() async { | 1361 test_instanceField_error_noSetterParameter() async { |
1478 var library = await _encodeDecodeLibrary(r''' | 1362 var library = await _encodeDecodeLibrary(r''' |
1479 abstract class A { | 1363 abstract class A { |
1480 int x; | 1364 int x; |
1481 } | 1365 } |
1482 class B implements A { | 1366 class B implements A { |
1483 set x() {} | 1367 set x() {} |
1484 } | 1368 } |
1485 '''); | 1369 '''); |
1486 checkElementText( | 1370 checkElementText(library, r''' |
1487 library, | |
1488 r''' | |
1489 abstract class A { | 1371 abstract class A { |
1490 int x; | 1372 int x; |
1491 } | 1373 } |
1492 class B implements A { | 1374 class B implements A { |
1493 void set x() {} | 1375 void set x() {} |
1494 } | 1376 } |
1495 '''); | 1377 '''); |
1496 } | 1378 } |
1497 | 1379 |
1498 test_instanceField_fieldFormal() async { | 1380 test_instanceField_fieldFormal() async { |
1499 var library = await _encodeDecodeLibrary(r''' | 1381 var library = await _encodeDecodeLibrary(r''' |
1500 class A { | 1382 class A { |
1501 var f = 0; | 1383 var f = 0; |
1502 A([this.f = 'hello']); | 1384 A([this.f = 'hello']); |
1503 } | 1385 } |
1504 '''); | 1386 '''); |
1505 checkElementText( | 1387 checkElementText(library, r''' |
1506 library, | |
1507 r''' | |
1508 class A { | 1388 class A { |
1509 int f; | 1389 int f; |
1510 A([int this.f]); | 1390 A([int this.f]); |
1511 } | 1391 } |
1512 '''); | 1392 '''); |
1513 } | 1393 } |
1514 | 1394 |
1515 test_instanceField_fromField() async { | 1395 test_instanceField_fromField() async { |
1516 var library = await _encodeDecodeLibrary(r''' | 1396 var library = await _encodeDecodeLibrary(r''' |
1517 abstract class A { | 1397 abstract class A { |
(...skipping 28 matching lines...) Expand all Loading... |
1546 | 1426 |
1547 test_instanceField_fromField_explicitDynamic() async { | 1427 test_instanceField_fromField_explicitDynamic() async { |
1548 var library = await _encodeDecodeLibrary(r''' | 1428 var library = await _encodeDecodeLibrary(r''' |
1549 abstract class A { | 1429 abstract class A { |
1550 dynamic x; | 1430 dynamic x; |
1551 } | 1431 } |
1552 class B implements A { | 1432 class B implements A { |
1553 var x = 1; | 1433 var x = 1; |
1554 } | 1434 } |
1555 '''); | 1435 '''); |
1556 checkElementText( | 1436 checkElementText(library, r''' |
1557 library, | |
1558 r''' | |
1559 abstract class A { | 1437 abstract class A { |
1560 dynamic x; | 1438 dynamic x; |
1561 } | 1439 } |
1562 class B implements A { | 1440 class B implements A { |
1563 dynamic x; | 1441 dynamic x; |
1564 } | 1442 } |
1565 '''); | 1443 '''); |
1566 } | 1444 } |
1567 | 1445 |
1568 test_instanceField_fromField_generic() async { | 1446 test_instanceField_fromField_generic() async { |
(...skipping 30 matching lines...) Expand all Loading... |
1599 | 1477 |
1600 test_instanceField_fromField_implicitDynamic() async { | 1478 test_instanceField_fromField_implicitDynamic() async { |
1601 var library = await _encodeDecodeLibrary(r''' | 1479 var library = await _encodeDecodeLibrary(r''' |
1602 abstract class A { | 1480 abstract class A { |
1603 var x; | 1481 var x; |
1604 } | 1482 } |
1605 class B implements A { | 1483 class B implements A { |
1606 var x = 1; | 1484 var x = 1; |
1607 } | 1485 } |
1608 '''); | 1486 '''); |
1609 checkElementText( | 1487 checkElementText(library, r''' |
1610 library, | |
1611 r''' | |
1612 abstract class A { | 1488 abstract class A { |
1613 dynamic x; | 1489 dynamic x; |
1614 } | 1490 } |
1615 class B implements A { | 1491 class B implements A { |
1616 dynamic x; | 1492 dynamic x; |
1617 } | 1493 } |
1618 '''); | 1494 '''); |
1619 } | 1495 } |
1620 | 1496 |
1621 test_instanceField_fromField_narrowType() async { | 1497 test_instanceField_fromField_narrowType() async { |
1622 var library = await _encodeDecodeLibrary(r''' | 1498 var library = await _encodeDecodeLibrary(r''' |
1623 abstract class A { | 1499 abstract class A { |
1624 num x; | 1500 num x; |
1625 } | 1501 } |
1626 class B implements A { | 1502 class B implements A { |
1627 var x = 1; | 1503 var x = 1; |
1628 } | 1504 } |
1629 '''); | 1505 '''); |
1630 checkElementText( | 1506 checkElementText(library, r''' |
1631 library, | |
1632 r''' | |
1633 abstract class A { | 1507 abstract class A { |
1634 num x; | 1508 num x; |
1635 } | 1509 } |
1636 class B implements A { | 1510 class B implements A { |
1637 num x; | 1511 num x; |
1638 } | 1512 } |
1639 '''); | 1513 '''); |
1640 } | 1514 } |
1641 | 1515 |
1642 test_instanceField_fromGetter() async { | 1516 test_instanceField_fromGetter() async { |
1643 var library = await _encodeDecodeLibrary(r''' | 1517 var library = await _encodeDecodeLibrary(r''' |
1644 abstract class A { | 1518 abstract class A { |
1645 int get x; | 1519 int get x; |
1646 int get y; | 1520 int get y; |
1647 int get z; | 1521 int get z; |
1648 } | 1522 } |
1649 class B implements A { | 1523 class B implements A { |
1650 var x; | 1524 var x; |
1651 get y => null; | 1525 get y => null; |
1652 set z(_) {} | 1526 set z(_) {} |
1653 } | 1527 } |
1654 '''); | 1528 '''); |
1655 checkElementText( | 1529 checkElementText(library, r''' |
1656 library, | |
1657 r''' | |
1658 abstract class A { | 1530 abstract class A { |
1659 int get x; | 1531 int get x; |
1660 int get y; | 1532 int get y; |
1661 int get z; | 1533 int get z; |
1662 } | 1534 } |
1663 class B implements A { | 1535 class B implements A { |
1664 int x; | 1536 int x; |
1665 int get y {} | 1537 int get y {} |
1666 void set z(int _) {} | 1538 void set z(int _) {} |
1667 } | 1539 } |
1668 '''); | 1540 '''); |
1669 } | 1541 } |
1670 | 1542 |
1671 test_instanceField_fromGetter_generic() async { | 1543 test_instanceField_fromGetter_generic() async { |
1672 var library = await _encodeDecodeLibrary(r''' | 1544 var library = await _encodeDecodeLibrary(r''' |
1673 abstract class A<E> { | 1545 abstract class A<E> { |
1674 E get x; | 1546 E get x; |
1675 E get y; | 1547 E get y; |
1676 E get z; | 1548 E get z; |
1677 } | 1549 } |
1678 class B<T> implements A<T> { | 1550 class B<T> implements A<T> { |
1679 var x; | 1551 var x; |
1680 get y => null; | 1552 get y => null; |
1681 set z(_) {} | 1553 set z(_) {} |
1682 } | 1554 } |
1683 '''); | 1555 '''); |
1684 checkElementText( | 1556 checkElementText(library, r''' |
1685 library, | |
1686 r''' | |
1687 abstract class A<E> { | 1557 abstract class A<E> { |
1688 E get x; | 1558 E get x; |
1689 E get y; | 1559 E get y; |
1690 E get z; | 1560 E get z; |
1691 } | 1561 } |
1692 class B<T> implements A<T> { | 1562 class B<T> implements A<T> { |
1693 T x; | 1563 T x; |
1694 T get y {} | 1564 T get y {} |
1695 void set z(T _) {} | 1565 void set z(T _) {} |
1696 } | 1566 } |
1697 '''); | 1567 '''); |
1698 } | 1568 } |
1699 | 1569 |
1700 test_instanceField_fromGetter_multiple_different() async { | 1570 test_instanceField_fromGetter_multiple_different() async { |
1701 var library = await _encodeDecodeLibrary(r''' | 1571 var library = await _encodeDecodeLibrary(r''' |
1702 abstract class A { | 1572 abstract class A { |
1703 int get x; | 1573 int get x; |
1704 } | 1574 } |
1705 abstract class B { | 1575 abstract class B { |
1706 String get x; | 1576 String get x; |
1707 } | 1577 } |
1708 class C implements A, B { | 1578 class C implements A, B { |
1709 get x => null; | 1579 get x => null; |
1710 } | 1580 } |
1711 '''); | 1581 '''); |
1712 // TODO(scheglov) test for inference failure error | 1582 // TODO(scheglov) test for inference failure error |
1713 checkElementText( | 1583 checkElementText(library, r''' |
1714 library, | |
1715 r''' | |
1716 abstract class A { | 1584 abstract class A { |
1717 int get x; | 1585 int get x; |
1718 } | 1586 } |
1719 abstract class B { | 1587 abstract class B { |
1720 String get x; | 1588 String get x; |
1721 } | 1589 } |
1722 class C implements A, B { | 1590 class C implements A, B { |
1723 dynamic get x {} | 1591 dynamic get x {} |
1724 } | 1592 } |
1725 '''); | 1593 '''); |
1726 } | 1594 } |
1727 | 1595 |
1728 test_instanceField_fromGetter_multiple_different_dynamic() async { | 1596 test_instanceField_fromGetter_multiple_different_dynamic() async { |
1729 var library = await _encodeDecodeLibrary(r''' | 1597 var library = await _encodeDecodeLibrary(r''' |
1730 abstract class A { | 1598 abstract class A { |
1731 int get x; | 1599 int get x; |
1732 } | 1600 } |
1733 abstract class B { | 1601 abstract class B { |
1734 dynamic get x; | 1602 dynamic get x; |
1735 } | 1603 } |
1736 class C implements A, B { | 1604 class C implements A, B { |
1737 get x => null; | 1605 get x => null; |
1738 } | 1606 } |
1739 '''); | 1607 '''); |
1740 // TODO(scheglov) test for inference failure error | 1608 // TODO(scheglov) test for inference failure error |
1741 checkElementText( | 1609 checkElementText(library, r''' |
1742 library, | |
1743 r''' | |
1744 abstract class A { | 1610 abstract class A { |
1745 int get x; | 1611 int get x; |
1746 } | 1612 } |
1747 abstract class B { | 1613 abstract class B { |
1748 dynamic get x; | 1614 dynamic get x; |
1749 } | 1615 } |
1750 class C implements A, B { | 1616 class C implements A, B { |
1751 dynamic get x {} | 1617 dynamic get x {} |
1752 } | 1618 } |
1753 '''); | 1619 '''); |
1754 } | 1620 } |
1755 | 1621 |
1756 test_instanceField_fromGetter_multiple_different_generic() async { | 1622 test_instanceField_fromGetter_multiple_different_generic() async { |
1757 var library = await _encodeDecodeLibrary(r''' | 1623 var library = await _encodeDecodeLibrary(r''' |
1758 abstract class A<T> { | 1624 abstract class A<T> { |
1759 T get x; | 1625 T get x; |
1760 } | 1626 } |
1761 abstract class B<T> { | 1627 abstract class B<T> { |
1762 T get x; | 1628 T get x; |
1763 } | 1629 } |
1764 class C implements A<int>, B<String> { | 1630 class C implements A<int>, B<String> { |
1765 get x => null; | 1631 get x => null; |
1766 } | 1632 } |
1767 '''); | 1633 '''); |
1768 // TODO(scheglov) test for inference failure error | 1634 // TODO(scheglov) test for inference failure error |
1769 checkElementText( | 1635 checkElementText(library, r''' |
1770 library, | |
1771 r''' | |
1772 abstract class A<T> { | 1636 abstract class A<T> { |
1773 T get x; | 1637 T get x; |
1774 } | 1638 } |
1775 abstract class B<T> { | 1639 abstract class B<T> { |
1776 T get x; | 1640 T get x; |
1777 } | 1641 } |
1778 class C implements A<int>, B<String> { | 1642 class C implements A<int>, B<String> { |
1779 dynamic get x {} | 1643 dynamic get x {} |
1780 } | 1644 } |
1781 '''); | 1645 '''); |
1782 } | 1646 } |
1783 | 1647 |
1784 test_instanceField_fromGetter_multiple_same() async { | 1648 test_instanceField_fromGetter_multiple_same() async { |
1785 var library = await _encodeDecodeLibrary(r''' | 1649 var library = await _encodeDecodeLibrary(r''' |
1786 abstract class A { | 1650 abstract class A { |
1787 int get x; | 1651 int get x; |
1788 } | 1652 } |
1789 abstract class B { | 1653 abstract class B { |
1790 int get x; | 1654 int get x; |
1791 } | 1655 } |
1792 class C implements A, B { | 1656 class C implements A, B { |
1793 get x => null; | 1657 get x => null; |
1794 } | 1658 } |
1795 '''); | 1659 '''); |
1796 checkElementText( | 1660 checkElementText(library, r''' |
1797 library, | |
1798 r''' | |
1799 abstract class A { | 1661 abstract class A { |
1800 int get x; | 1662 int get x; |
1801 } | 1663 } |
1802 abstract class B { | 1664 abstract class B { |
1803 int get x; | 1665 int get x; |
1804 } | 1666 } |
1805 class C implements A, B { | 1667 class C implements A, B { |
1806 int get x {} | 1668 int get x {} |
1807 } | 1669 } |
1808 '''); | 1670 '''); |
1809 } | 1671 } |
1810 | 1672 |
1811 test_instanceField_fromGetterSetter_different_field() async { | 1673 test_instanceField_fromGetterSetter_different_field() async { |
1812 var library = await _encodeDecodeLibrary(r''' | 1674 var library = await _encodeDecodeLibrary(r''' |
1813 abstract class A { | 1675 abstract class A { |
1814 int get x; | 1676 int get x; |
1815 int get y; | 1677 int get y; |
1816 } | 1678 } |
1817 abstract class B { | 1679 abstract class B { |
1818 void set x(String _); | 1680 void set x(String _); |
1819 void set y(String _); | 1681 void set y(String _); |
1820 } | 1682 } |
1821 class C implements A, B { | 1683 class C implements A, B { |
1822 var x; | 1684 var x; |
1823 final y; | 1685 final y; |
1824 } | 1686 } |
1825 '''); | 1687 '''); |
1826 checkElementText( | 1688 checkElementText(library, r''' |
1827 library, | |
1828 r''' | |
1829 abstract class A { | 1689 abstract class A { |
1830 int get x; | 1690 int get x; |
1831 int get y; | 1691 int get y; |
1832 } | 1692 } |
1833 abstract class B { | 1693 abstract class B { |
1834 void set x(String _); | 1694 void set x(String _); |
1835 void set y(String _); | 1695 void set y(String _); |
1836 } | 1696 } |
1837 class C implements A, B { | 1697 class C implements A, B { |
1838 dynamic x/*error: overrideConflictFieldType*/; | 1698 dynamic x/*error: overrideConflictFieldType*/; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 abstract class A { | 1769 abstract class A { |
1910 int get x; | 1770 int get x; |
1911 } | 1771 } |
1912 abstract class B { | 1772 abstract class B { |
1913 void set x(int _); | 1773 void set x(int _); |
1914 } | 1774 } |
1915 class C implements A, B { | 1775 class C implements A, B { |
1916 var x; | 1776 var x; |
1917 } | 1777 } |
1918 '''); | 1778 '''); |
1919 checkElementText( | 1779 checkElementText(library, r''' |
1920 library, | |
1921 r''' | |
1922 abstract class A { | 1780 abstract class A { |
1923 int get x; | 1781 int get x; |
1924 } | 1782 } |
1925 abstract class B { | 1783 abstract class B { |
1926 void set x(int _); | 1784 void set x(int _); |
1927 } | 1785 } |
1928 class C implements A, B { | 1786 class C implements A, B { |
1929 int x; | 1787 int x; |
1930 } | 1788 } |
1931 '''); | 1789 '''); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 void set x(int _); | 1857 void set x(int _); |
2000 void set y(int _); | 1858 void set y(int _); |
2001 void set z(int _); | 1859 void set z(int _); |
2002 } | 1860 } |
2003 class B implements A { | 1861 class B implements A { |
2004 var x; | 1862 var x; |
2005 get y => null; | 1863 get y => null; |
2006 set z(_) {} | 1864 set z(_) {} |
2007 } | 1865 } |
2008 '''); | 1866 '''); |
2009 checkElementText( | 1867 checkElementText(library, r''' |
2010 library, | |
2011 r''' | |
2012 abstract class A { | 1868 abstract class A { |
2013 void set x(int _); | 1869 void set x(int _); |
2014 void set y(int _); | 1870 void set y(int _); |
2015 void set z(int _); | 1871 void set z(int _); |
2016 } | 1872 } |
2017 class B implements A { | 1873 class B implements A { |
2018 int x; | 1874 int x; |
2019 int get y {} | 1875 int get y {} |
2020 void set z(int _) {} | 1876 void set z(int _) {} |
2021 } | 1877 } |
2022 '''); | 1878 '''); |
2023 } | 1879 } |
2024 | 1880 |
2025 test_instanceField_fromSetter_multiple_different() async { | 1881 test_instanceField_fromSetter_multiple_different() async { |
2026 var library = await _encodeDecodeLibrary(r''' | 1882 var library = await _encodeDecodeLibrary(r''' |
2027 abstract class A { | 1883 abstract class A { |
2028 void set x(int _); | 1884 void set x(int _); |
2029 } | 1885 } |
2030 abstract class B { | 1886 abstract class B { |
2031 void set x(String _); | 1887 void set x(String _); |
2032 } | 1888 } |
2033 class C implements A, B { | 1889 class C implements A, B { |
2034 get x => null; | 1890 get x => null; |
2035 } | 1891 } |
2036 '''); | 1892 '''); |
2037 checkElementText( | 1893 checkElementText(library, r''' |
2038 library, | |
2039 r''' | |
2040 abstract class A { | 1894 abstract class A { |
2041 void set x(int _); | 1895 void set x(int _); |
2042 } | 1896 } |
2043 abstract class B { | 1897 abstract class B { |
2044 void set x(String _); | 1898 void set x(String _); |
2045 } | 1899 } |
2046 class C implements A, B { | 1900 class C implements A, B { |
2047 dynamic get x {} | 1901 dynamic get x {} |
2048 } | 1902 } |
2049 '''); | 1903 '''); |
2050 } | 1904 } |
2051 | 1905 |
2052 test_instanceField_fromSetter_multiple_same() async { | 1906 test_instanceField_fromSetter_multiple_same() async { |
2053 var library = await _encodeDecodeLibrary(r''' | 1907 var library = await _encodeDecodeLibrary(r''' |
2054 abstract class A { | 1908 abstract class A { |
2055 void set x(int _); | 1909 void set x(int _); |
2056 } | 1910 } |
2057 abstract class B { | 1911 abstract class B { |
2058 void set x(int _); | 1912 void set x(int _); |
2059 } | 1913 } |
2060 class C implements A, B { | 1914 class C implements A, B { |
2061 get x => null; | 1915 get x => null; |
2062 } | 1916 } |
2063 '''); | 1917 '''); |
2064 checkElementText( | 1918 checkElementText(library, r''' |
2065 library, | |
2066 r''' | |
2067 abstract class A { | 1919 abstract class A { |
2068 void set x(int _); | 1920 void set x(int _); |
2069 } | 1921 } |
2070 abstract class B { | 1922 abstract class B { |
2071 void set x(int _); | 1923 void set x(int _); |
2072 } | 1924 } |
2073 class C implements A, B { | 1925 class C implements A, B { |
2074 int get x {} | 1926 int get x {} |
2075 } | 1927 } |
2076 '''); | 1928 '''); |
2077 } | 1929 } |
2078 | 1930 |
2079 test_instanceField_functionTypeAlias_doesNotUseItsTypeParameter() async { | 1931 test_instanceField_functionTypeAlias_doesNotUseItsTypeParameter() async { |
2080 var library = await _encodeDecodeLibrary(r''' | 1932 var library = await _encodeDecodeLibrary(r''' |
2081 typedef F<T>(); | 1933 typedef F<T>(); |
2082 | 1934 |
2083 class A<T> { | 1935 class A<T> { |
2084 F<T> get x => null; | 1936 F<T> get x => null; |
2085 List<F<T>> get y => null; | 1937 List<F<T>> get y => null; |
2086 } | 1938 } |
2087 | 1939 |
2088 class B extends A<int> { | 1940 class B extends A<int> { |
2089 get x => null; | 1941 get x => null; |
2090 get y => null; | 1942 get y => null; |
2091 } | 1943 } |
2092 '''); | 1944 '''); |
2093 checkElementText( | 1945 checkElementText(library, r''' |
2094 library, | |
2095 r''' | |
2096 typedef dynamic F<T>(); | 1946 typedef dynamic F<T>(); |
2097 class A<T> { | 1947 class A<T> { |
2098 F<T> get x {} | 1948 F<T> get x {} |
2099 List<F<T>> get y {} | 1949 List<F<T>> get y {} |
2100 } | 1950 } |
2101 class B extends A<int> { | 1951 class B extends A<int> { |
2102 F<int> get x {} | 1952 F<int> get x {} |
2103 List<F<int>> get y {} | 1953 List<F<int>> get y {} |
2104 } | 1954 } |
2105 '''); | 1955 '''); |
(...skipping 28 matching lines...) Expand all Loading... |
2134 test_instanceField_inheritsCovariant_fromSetter_setter() async { | 1984 test_instanceField_inheritsCovariant_fromSetter_setter() async { |
2135 var library = await _encodeDecodeLibrary(r''' | 1985 var library = await _encodeDecodeLibrary(r''' |
2136 abstract class A { | 1986 abstract class A { |
2137 num get x; | 1987 num get x; |
2138 void set x(covariant num _); | 1988 void set x(covariant num _); |
2139 } | 1989 } |
2140 class B implements A { | 1990 class B implements A { |
2141 set x(int _) {} | 1991 set x(int _) {} |
2142 } | 1992 } |
2143 '''); | 1993 '''); |
2144 checkElementText( | 1994 checkElementText(library, r''' |
2145 library, | |
2146 r''' | |
2147 abstract class A { | 1995 abstract class A { |
2148 num get x; | 1996 num get x; |
2149 void set x(covariant num _); | 1997 void set x(covariant num _); |
2150 } | 1998 } |
2151 class B implements A { | 1999 class B implements A { |
2152 void set x(covariant int _) {} | 2000 void set x(covariant int _) {} |
2153 } | 2001 } |
2154 '''); | 2002 '''); |
2155 } | 2003 } |
2156 | 2004 |
2157 test_instanceField_initializer() async { | 2005 test_instanceField_initializer() async { |
2158 var library = await _encodeDecodeLibrary(r''' | 2006 var library = await _encodeDecodeLibrary(r''' |
2159 class A { | 2007 class A { |
2160 var t1 = 1; | 2008 var t1 = 1; |
2161 var t2 = 2.0; | 2009 var t2 = 2.0; |
2162 var t3 = null; | 2010 var t3 = null; |
2163 } | 2011 } |
2164 '''); | 2012 '''); |
2165 checkElementText( | 2013 checkElementText(library, r''' |
2166 library, | |
2167 r''' | |
2168 class A { | 2014 class A { |
2169 int t1; | 2015 int t1; |
2170 double t2; | 2016 double t2; |
2171 dynamic t3; | 2017 dynamic t3; |
2172 } | 2018 } |
2173 '''); | 2019 '''); |
2174 } | 2020 } |
2175 | 2021 |
2176 test_method_error_conflict_parameterType_generic() async { | 2022 test_method_error_conflict_parameterType_generic() async { |
2177 var library = await _encodeDecodeLibrary(r''' | 2023 var library = await _encodeDecodeLibrary(r''' |
2178 class A<T> { | 2024 class A<T> { |
2179 void m(T a) {} | 2025 void m(T a) {} |
2180 } | 2026 } |
2181 class B<E> { | 2027 class B<E> { |
2182 void m(E a) {} | 2028 void m(E a) {} |
2183 } | 2029 } |
2184 class C extends A<int> implements B<double> { | 2030 class C extends A<int> implements B<double> { |
2185 m(a) {} | 2031 m(a) {} |
2186 } | 2032 } |
2187 '''); | 2033 '''); |
2188 checkElementText( | 2034 checkElementText(library, r''' |
2189 library, | |
2190 r''' | |
2191 class A<T> { | 2035 class A<T> { |
2192 void m(T a) {} | 2036 void m(T a) {} |
2193 } | 2037 } |
2194 class B<E> { | 2038 class B<E> { |
2195 void m(E a) {} | 2039 void m(E a) {} |
2196 } | 2040 } |
2197 class C extends A<int> implements B<double> { | 2041 class C extends A<int> implements B<double> { |
2198 void m(dynamic a/*error: overrideConflictParameterType*/) {} | 2042 void m(dynamic a/*error: overrideConflictParameterType*/) {} |
2199 } | 2043 } |
2200 '''); | 2044 '''); |
2201 } | 2045 } |
2202 | 2046 |
2203 test_method_error_conflict_parameterType_notGeneric() async { | 2047 test_method_error_conflict_parameterType_notGeneric() async { |
2204 var library = await _encodeDecodeLibrary(r''' | 2048 var library = await _encodeDecodeLibrary(r''' |
2205 class A { | 2049 class A { |
2206 void m(int a) {} | 2050 void m(int a) {} |
2207 } | 2051 } |
2208 class B { | 2052 class B { |
2209 void m(String a) {} | 2053 void m(String a) {} |
2210 } | 2054 } |
2211 class C extends A implements B { | 2055 class C extends A implements B { |
2212 m(a) {} | 2056 m(a) {} |
2213 } | 2057 } |
2214 '''); | 2058 '''); |
2215 checkElementText( | 2059 checkElementText(library, r''' |
2216 library, | |
2217 r''' | |
2218 class A { | 2060 class A { |
2219 void m(int a) {} | 2061 void m(int a) {} |
2220 } | 2062 } |
2221 class B { | 2063 class B { |
2222 void m(String a) {} | 2064 void m(String a) {} |
2223 } | 2065 } |
2224 class C extends A implements B { | 2066 class C extends A implements B { |
2225 void m(dynamic a/*error: overrideConflictParameterType*/) {} | 2067 void m(dynamic a/*error: overrideConflictParameterType*/) {} |
2226 } | 2068 } |
2227 '''); | 2069 '''); |
2228 } | 2070 } |
2229 | 2071 |
2230 test_method_error_conflict_returnType_generic() async { | 2072 test_method_error_conflict_returnType_generic() async { |
2231 var library = await _encodeDecodeLibrary(r''' | 2073 var library = await _encodeDecodeLibrary(r''' |
2232 class A<K, V> { | 2074 class A<K, V> { |
2233 V m(K a) {} | 2075 V m(K a) {} |
2234 } | 2076 } |
2235 class B<T> { | 2077 class B<T> { |
2236 T m(int a) {} | 2078 T m(int a) {} |
2237 } | 2079 } |
2238 class C extends A<int, String> implements B<double> { | 2080 class C extends A<int, String> implements B<double> { |
2239 m(a) {} | 2081 m(a) {} |
2240 } | 2082 } |
2241 '''); | 2083 '''); |
2242 // TODO(scheglov) test for inference failure error | 2084 // TODO(scheglov) test for inference failure error |
2243 checkElementText( | 2085 checkElementText(library, r''' |
2244 library, | |
2245 r''' | |
2246 class A<K, V> { | 2086 class A<K, V> { |
2247 V m(K a) {} | 2087 V m(K a) {} |
2248 } | 2088 } |
2249 class B<T> { | 2089 class B<T> { |
2250 T m(int a) {} | 2090 T m(int a) {} |
2251 } | 2091 } |
2252 class C extends A<int, String> implements B<double> { | 2092 class C extends A<int, String> implements B<double> { |
2253 dynamic m(int a) {} | 2093 dynamic m(int a) {} |
2254 } | 2094 } |
2255 '''); | 2095 '''); |
2256 } | 2096 } |
2257 | 2097 |
2258 test_method_error_conflict_returnType_notGeneric() async { | 2098 test_method_error_conflict_returnType_notGeneric() async { |
2259 var library = await _encodeDecodeLibrary(r''' | 2099 var library = await _encodeDecodeLibrary(r''' |
2260 class A { | 2100 class A { |
2261 int m() {} | 2101 int m() {} |
2262 } | 2102 } |
2263 class B { | 2103 class B { |
2264 String m() {} | 2104 String m() {} |
2265 } | 2105 } |
2266 class C extends A implements B { | 2106 class C extends A implements B { |
2267 m() {} | 2107 m() {} |
2268 } | 2108 } |
2269 '''); | 2109 '''); |
2270 // TODO(scheglov) test for inference failure error | 2110 // TODO(scheglov) test for inference failure error |
2271 checkElementText( | 2111 checkElementText(library, r''' |
2272 library, | |
2273 r''' | |
2274 class A { | 2112 class A { |
2275 int m() {} | 2113 int m() {} |
2276 } | 2114 } |
2277 class B { | 2115 class B { |
2278 String m() {} | 2116 String m() {} |
2279 } | 2117 } |
2280 class C extends A implements B { | 2118 class C extends A implements B { |
2281 dynamic m() {} | 2119 dynamic m() {} |
2282 } | 2120 } |
2283 '''); | 2121 '''); |
2284 } | 2122 } |
2285 | 2123 |
2286 test_method_error_hasMethod_noParameter_required() async { | 2124 test_method_error_hasMethod_noParameter_required() async { |
2287 var library = await _encodeDecodeLibrary(r''' | 2125 var library = await _encodeDecodeLibrary(r''' |
2288 class A { | 2126 class A { |
2289 void m(int a) {} | 2127 void m(int a) {} |
2290 } | 2128 } |
2291 class B extends A { | 2129 class B extends A { |
2292 m(a, b) {} | 2130 m(a, b) {} |
2293 } | 2131 } |
2294 '''); | 2132 '''); |
2295 // It's an error to add a new required parameter, but it is not a | 2133 // It's an error to add a new required parameter, but it is not a |
2296 // top-level type inference error. | 2134 // top-level type inference error. |
2297 checkElementText( | 2135 checkElementText(library, r''' |
2298 library, | |
2299 r''' | |
2300 class A { | 2136 class A { |
2301 void m(int a) {} | 2137 void m(int a) {} |
2302 } | 2138 } |
2303 class B extends A { | 2139 class B extends A { |
2304 void m(int a, dynamic b) {} | 2140 void m(int a, dynamic b) {} |
2305 } | 2141 } |
2306 '''); | 2142 '''); |
2307 } | 2143 } |
2308 | 2144 |
2309 test_method_missing_hasMethod_noParameter_named() async { | 2145 test_method_missing_hasMethod_noParameter_named() async { |
2310 var library = await _encodeDecodeLibrary(r''' | 2146 var library = await _encodeDecodeLibrary(r''' |
2311 class A { | 2147 class A { |
2312 void m(int a) {} | 2148 void m(int a) {} |
2313 } | 2149 } |
2314 class B extends A { | 2150 class B extends A { |
2315 m(a, {b}) {} | 2151 m(a, {b}) {} |
2316 } | 2152 } |
2317 '''); | 2153 '''); |
2318 checkElementText( | 2154 checkElementText(library, r''' |
2319 library, | |
2320 r''' | |
2321 class A { | 2155 class A { |
2322 void m(int a) {} | 2156 void m(int a) {} |
2323 } | 2157 } |
2324 class B extends A { | 2158 class B extends A { |
2325 void m(int a, {dynamic b}) {} | 2159 void m(int a, {dynamic b}) {} |
2326 } | 2160 } |
2327 '''); | 2161 '''); |
2328 } | 2162 } |
2329 | 2163 |
2330 test_method_missing_hasMethod_noParameter_optional() async { | 2164 test_method_missing_hasMethod_noParameter_optional() async { |
2331 var library = await _encodeDecodeLibrary(r''' | 2165 var library = await _encodeDecodeLibrary(r''' |
2332 class A { | 2166 class A { |
2333 void m(int a) {} | 2167 void m(int a) {} |
2334 } | 2168 } |
2335 class B extends A { | 2169 class B extends A { |
2336 m(a, [b]) {} | 2170 m(a, [b]) {} |
2337 } | 2171 } |
2338 '''); | 2172 '''); |
2339 checkElementText( | 2173 checkElementText(library, r''' |
2340 library, | |
2341 r''' | |
2342 class A { | 2174 class A { |
2343 void m(int a) {} | 2175 void m(int a) {} |
2344 } | 2176 } |
2345 class B extends A { | 2177 class B extends A { |
2346 void m(int a, [dynamic b]) {} | 2178 void m(int a, [dynamic b]) {} |
2347 } | 2179 } |
2348 '''); | 2180 '''); |
2349 } | 2181 } |
2350 | 2182 |
2351 test_method_missing_hasMethod_withoutTypes() async { | 2183 test_method_missing_hasMethod_withoutTypes() async { |
2352 var library = await _encodeDecodeLibrary(r''' | 2184 var library = await _encodeDecodeLibrary(r''' |
2353 class A { | 2185 class A { |
2354 m(a) {} | 2186 m(a) {} |
2355 } | 2187 } |
2356 class B extends A { | 2188 class B extends A { |
2357 m(a) {} | 2189 m(a) {} |
2358 } | 2190 } |
2359 '''); | 2191 '''); |
2360 checkElementText( | 2192 checkElementText(library, r''' |
2361 library, | |
2362 r''' | |
2363 class A { | 2193 class A { |
2364 dynamic m(dynamic a) {} | 2194 dynamic m(dynamic a) {} |
2365 } | 2195 } |
2366 class B extends A { | 2196 class B extends A { |
2367 dynamic m(dynamic a) {} | 2197 dynamic m(dynamic a) {} |
2368 } | 2198 } |
2369 '''); | 2199 '''); |
2370 } | 2200 } |
2371 | 2201 |
2372 test_method_missing_noMember() async { | 2202 test_method_missing_noMember() async { |
2373 var library = await _encodeDecodeLibrary(r''' | 2203 var library = await _encodeDecodeLibrary(r''' |
2374 class A { | 2204 class A { |
2375 int foo(String a) => null; | 2205 int foo(String a) => null; |
2376 } | 2206 } |
2377 class B extends A { | 2207 class B extends A { |
2378 m(a) {} | 2208 m(a) {} |
2379 } | 2209 } |
2380 '''); | 2210 '''); |
2381 checkElementText( | 2211 checkElementText(library, r''' |
2382 library, | |
2383 r''' | |
2384 class A { | 2212 class A { |
2385 int foo(String a) {} | 2213 int foo(String a) {} |
2386 } | 2214 } |
2387 class B extends A { | 2215 class B extends A { |
2388 dynamic m(dynamic a) {} | 2216 dynamic m(dynamic a) {} |
2389 } | 2217 } |
2390 '''); | 2218 '''); |
2391 } | 2219 } |
2392 | 2220 |
2393 test_method_missing_notMethod() async { | 2221 test_method_missing_notMethod() async { |
2394 var library = await _encodeDecodeLibrary(r''' | 2222 var library = await _encodeDecodeLibrary(r''' |
2395 class A { | 2223 class A { |
2396 int m = 42; | 2224 int m = 42; |
2397 } | 2225 } |
2398 class B extends A { | 2226 class B extends A { |
2399 m(a) {} | 2227 m(a) {} |
2400 } | 2228 } |
2401 '''); | 2229 '''); |
2402 checkElementText( | 2230 checkElementText(library, r''' |
2403 library, | |
2404 r''' | |
2405 class A { | 2231 class A { |
2406 int m; | 2232 int m; |
2407 } | 2233 } |
2408 class B extends A { | 2234 class B extends A { |
2409 dynamic m(dynamic a) {} | 2235 dynamic m(dynamic a) {} |
2410 } | 2236 } |
2411 '''); | 2237 '''); |
2412 } | 2238 } |
2413 | 2239 |
2414 test_method_OK_sequence_extendsExtends_generic() async { | 2240 test_method_OK_sequence_extendsExtends_generic() async { |
2415 var library = await _encodeDecodeLibrary(r''' | 2241 var library = await _encodeDecodeLibrary(r''' |
2416 class A<K, V> { | 2242 class A<K, V> { |
2417 V m(K a) {} | 2243 V m(K a) {} |
2418 } | 2244 } |
2419 class B<T> extends A<int, T> {} | 2245 class B<T> extends A<int, T> {} |
2420 class C extends B<String> { | 2246 class C extends B<String> { |
2421 m(a) {} | 2247 m(a) {} |
2422 } | 2248 } |
2423 '''); | 2249 '''); |
2424 checkElementText( | 2250 checkElementText(library, r''' |
2425 library, | |
2426 r''' | |
2427 class A<K, V> { | 2251 class A<K, V> { |
2428 V m(K a) {} | 2252 V m(K a) {} |
2429 } | 2253 } |
2430 class B<T> extends A<int, T> { | 2254 class B<T> extends A<int, T> { |
2431 } | 2255 } |
2432 class C extends B<String> { | 2256 class C extends B<String> { |
2433 String m(int a) {} | 2257 String m(int a) {} |
2434 } | 2258 } |
2435 '''); | 2259 '''); |
2436 } | 2260 } |
2437 | 2261 |
2438 test_method_OK_sequence_inferMiddle_extendsExtends() async { | 2262 test_method_OK_sequence_inferMiddle_extendsExtends() async { |
2439 var library = await _encodeDecodeLibrary(r''' | 2263 var library = await _encodeDecodeLibrary(r''' |
2440 class A { | 2264 class A { |
2441 String m(int a) {} | 2265 String m(int a) {} |
2442 } | 2266 } |
2443 class B extends A { | 2267 class B extends A { |
2444 m(a) {} | 2268 m(a) {} |
2445 } | 2269 } |
2446 class C extends B { | 2270 class C extends B { |
2447 m(a) {} | 2271 m(a) {} |
2448 } | 2272 } |
2449 '''); | 2273 '''); |
2450 checkElementText( | 2274 checkElementText(library, r''' |
2451 library, | |
2452 r''' | |
2453 class A { | 2275 class A { |
2454 String m(int a) {} | 2276 String m(int a) {} |
2455 } | 2277 } |
2456 class B extends A { | 2278 class B extends A { |
2457 String m(int a) {} | 2279 String m(int a) {} |
2458 } | 2280 } |
2459 class C extends B { | 2281 class C extends B { |
2460 String m(int a) {} | 2282 String m(int a) {} |
2461 } | 2283 } |
2462 '''); | 2284 '''); |
2463 } | 2285 } |
2464 | 2286 |
2465 test_method_OK_sequence_inferMiddle_extendsImplements() async { | 2287 test_method_OK_sequence_inferMiddle_extendsImplements() async { |
2466 var library = await _encodeDecodeLibrary(r''' | 2288 var library = await _encodeDecodeLibrary(r''' |
2467 class A { | 2289 class A { |
2468 String m(int a) {} | 2290 String m(int a) {} |
2469 } | 2291 } |
2470 class B implements A { | 2292 class B implements A { |
2471 m(a) {} | 2293 m(a) {} |
2472 } | 2294 } |
2473 class C extends B { | 2295 class C extends B { |
2474 m(a) {} | 2296 m(a) {} |
2475 } | 2297 } |
2476 '''); | 2298 '''); |
2477 checkElementText( | 2299 checkElementText(library, r''' |
2478 library, | |
2479 r''' | |
2480 class A { | 2300 class A { |
2481 String m(int a) {} | 2301 String m(int a) {} |
2482 } | 2302 } |
2483 class B implements A { | 2303 class B implements A { |
2484 String m(int a) {} | 2304 String m(int a) {} |
2485 } | 2305 } |
2486 class C extends B { | 2306 class C extends B { |
2487 String m(int a) {} | 2307 String m(int a) {} |
2488 } | 2308 } |
2489 '''); | 2309 '''); |
2490 } | 2310 } |
2491 | 2311 |
2492 test_method_OK_sequence_inferMiddle_extendsWith() async { | 2312 test_method_OK_sequence_inferMiddle_extendsWith() async { |
2493 var library = await _encodeDecodeLibrary(r''' | 2313 var library = await _encodeDecodeLibrary(r''' |
2494 class A { | 2314 class A { |
2495 String m(int a) {} | 2315 String m(int a) {} |
2496 } | 2316 } |
2497 class B extends Object with A { | 2317 class B extends Object with A { |
2498 m(a) {} | 2318 m(a) {} |
2499 } | 2319 } |
2500 class C extends B { | 2320 class C extends B { |
2501 m(a) {} | 2321 m(a) {} |
2502 } | 2322 } |
2503 '''); | 2323 '''); |
2504 checkElementText( | 2324 checkElementText(library, r''' |
2505 library, | |
2506 r''' | |
2507 class A { | 2325 class A { |
2508 String m(int a) {} | 2326 String m(int a) {} |
2509 } | 2327 } |
2510 class B extends Object with A { | 2328 class B extends Object with A { |
2511 synthetic B(); | 2329 synthetic B(); |
2512 String m(int a) {} | 2330 String m(int a) {} |
2513 } | 2331 } |
2514 class C extends B { | 2332 class C extends B { |
2515 String m(int a) {} | 2333 String m(int a) {} |
2516 } | 2334 } |
2517 '''); | 2335 '''); |
2518 } | 2336 } |
2519 | 2337 |
2520 test_method_OK_single_extends_direct_generic() async { | 2338 test_method_OK_single_extends_direct_generic() async { |
2521 var library = await _encodeDecodeLibrary(r''' | 2339 var library = await _encodeDecodeLibrary(r''' |
2522 class A<K, V> { | 2340 class A<K, V> { |
2523 V m(K a, double b) {} | 2341 V m(K a, double b) {} |
2524 } | 2342 } |
2525 class B extends A<int, String> { | 2343 class B extends A<int, String> { |
2526 m(a, b) {} | 2344 m(a, b) {} |
2527 } | 2345 } |
2528 '''); | 2346 '''); |
2529 checkElementText( | 2347 checkElementText(library, r''' |
2530 library, | |
2531 r''' | |
2532 class A<K, V> { | 2348 class A<K, V> { |
2533 V m(K a, double b) {} | 2349 V m(K a, double b) {} |
2534 } | 2350 } |
2535 class B extends A<int, String> { | 2351 class B extends A<int, String> { |
2536 String m(int a, double b) {} | 2352 String m(int a, double b) {} |
2537 } | 2353 } |
2538 '''); | 2354 '''); |
2539 } | 2355 } |
2540 | 2356 |
2541 test_method_OK_single_extends_direct_notGeneric() async { | 2357 test_method_OK_single_extends_direct_notGeneric() async { |
2542 var library = await _encodeDecodeLibrary(r''' | 2358 var library = await _encodeDecodeLibrary(r''' |
2543 class A { | 2359 class A { |
2544 String m(int a) {} | 2360 String m(int a) {} |
2545 } | 2361 } |
2546 class B extends A { | 2362 class B extends A { |
2547 m(a) {} | 2363 m(a) {} |
2548 } | 2364 } |
2549 '''); | 2365 '''); |
2550 checkElementText( | 2366 checkElementText(library, r''' |
2551 library, | |
2552 r''' | |
2553 class A { | 2367 class A { |
2554 String m(int a) {} | 2368 String m(int a) {} |
2555 } | 2369 } |
2556 class B extends A { | 2370 class B extends A { |
2557 String m(int a) {} | 2371 String m(int a) {} |
2558 } | 2372 } |
2559 '''); | 2373 '''); |
2560 } | 2374 } |
2561 | 2375 |
2562 test_method_OK_single_extends_direct_notGeneric_named() async { | 2376 test_method_OK_single_extends_direct_notGeneric_named() async { |
2563 var library = await _encodeDecodeLibrary(r''' | 2377 var library = await _encodeDecodeLibrary(r''' |
2564 class A { | 2378 class A { |
2565 String m(int a, {double b}) {} | 2379 String m(int a, {double b}) {} |
2566 } | 2380 } |
2567 class B extends A { | 2381 class B extends A { |
2568 m(a, {b}) {} | 2382 m(a, {b}) {} |
2569 } | 2383 } |
2570 '''); | 2384 '''); |
2571 checkElementText( | 2385 checkElementText(library, r''' |
2572 library, | |
2573 r''' | |
2574 class A { | 2386 class A { |
2575 String m(int a, {double b}) {} | 2387 String m(int a, {double b}) {} |
2576 } | 2388 } |
2577 class B extends A { | 2389 class B extends A { |
2578 String m(int a, {double b}) {} | 2390 String m(int a, {double b}) {} |
2579 } | 2391 } |
2580 '''); | 2392 '''); |
2581 } | 2393 } |
2582 | 2394 |
2583 test_method_OK_single_extends_direct_notGeneric_positional() async { | 2395 test_method_OK_single_extends_direct_notGeneric_positional() async { |
2584 var library = await _encodeDecodeLibrary(r''' | 2396 var library = await _encodeDecodeLibrary(r''' |
2585 class A { | 2397 class A { |
2586 String m(int a, [double b]) {} | 2398 String m(int a, [double b]) {} |
2587 } | 2399 } |
2588 class B extends A { | 2400 class B extends A { |
2589 m(a, [b]) {} | 2401 m(a, [b]) {} |
2590 } | 2402 } |
2591 '''); | 2403 '''); |
2592 checkElementText( | 2404 checkElementText(library, r''' |
2593 library, | |
2594 r''' | |
2595 class A { | 2405 class A { |
2596 String m(int a, [double b]) {} | 2406 String m(int a, [double b]) {} |
2597 } | 2407 } |
2598 class B extends A { | 2408 class B extends A { |
2599 String m(int a, [double b]) {} | 2409 String m(int a, [double b]) {} |
2600 } | 2410 } |
2601 '''); | 2411 '''); |
2602 } | 2412 } |
2603 | 2413 |
2604 test_method_OK_single_extends_indirect_generic() async { | 2414 test_method_OK_single_extends_indirect_generic() async { |
2605 var library = await _encodeDecodeLibrary(r''' | 2415 var library = await _encodeDecodeLibrary(r''' |
2606 class A<K, V> { | 2416 class A<K, V> { |
2607 V m(K a) {} | 2417 V m(K a) {} |
2608 } | 2418 } |
2609 class B<T> extends A<int, T> {} | 2419 class B<T> extends A<int, T> {} |
2610 class C extends B<String> { | 2420 class C extends B<String> { |
2611 m(a) {} | 2421 m(a) {} |
2612 } | 2422 } |
2613 '''); | 2423 '''); |
2614 checkElementText( | 2424 checkElementText(library, r''' |
2615 library, | |
2616 r''' | |
2617 class A<K, V> { | 2425 class A<K, V> { |
2618 V m(K a) {} | 2426 V m(K a) {} |
2619 } | 2427 } |
2620 class B<T> extends A<int, T> { | 2428 class B<T> extends A<int, T> { |
2621 } | 2429 } |
2622 class C extends B<String> { | 2430 class C extends B<String> { |
2623 String m(int a) {} | 2431 String m(int a) {} |
2624 } | 2432 } |
2625 '''); | 2433 '''); |
2626 } | 2434 } |
2627 | 2435 |
2628 test_method_OK_single_implements_direct_generic() async { | 2436 test_method_OK_single_implements_direct_generic() async { |
2629 var library = await _encodeDecodeLibrary(r''' | 2437 var library = await _encodeDecodeLibrary(r''' |
2630 abstract class A<K, V> { | 2438 abstract class A<K, V> { |
2631 V m(K a); | 2439 V m(K a); |
2632 } | 2440 } |
2633 class B implements A<int, String> { | 2441 class B implements A<int, String> { |
2634 m(a) {} | 2442 m(a) {} |
2635 } | 2443 } |
2636 '''); | 2444 '''); |
2637 checkElementText( | 2445 checkElementText(library, r''' |
2638 library, | |
2639 r''' | |
2640 abstract class A<K, V> { | 2446 abstract class A<K, V> { |
2641 V m(K a); | 2447 V m(K a); |
2642 } | 2448 } |
2643 class B implements A<int, String> { | 2449 class B implements A<int, String> { |
2644 String m(int a) {} | 2450 String m(int a) {} |
2645 } | 2451 } |
2646 '''); | 2452 '''); |
2647 } | 2453 } |
2648 | 2454 |
2649 test_method_OK_single_implements_direct_notGeneric() async { | 2455 test_method_OK_single_implements_direct_notGeneric() async { |
2650 var library = await _encodeDecodeLibrary(r''' | 2456 var library = await _encodeDecodeLibrary(r''' |
2651 abstract class A { | 2457 abstract class A { |
2652 String m(int a); | 2458 String m(int a); |
2653 } | 2459 } |
2654 class B implements A { | 2460 class B implements A { |
2655 m(a) {} | 2461 m(a) {} |
2656 } | 2462 } |
2657 '''); | 2463 '''); |
2658 checkElementText( | 2464 checkElementText(library, r''' |
2659 library, | |
2660 r''' | |
2661 abstract class A { | 2465 abstract class A { |
2662 String m(int a); | 2466 String m(int a); |
2663 } | 2467 } |
2664 class B implements A { | 2468 class B implements A { |
2665 String m(int a) {} | 2469 String m(int a) {} |
2666 } | 2470 } |
2667 '''); | 2471 '''); |
2668 } | 2472 } |
2669 | 2473 |
2670 test_method_OK_single_implements_indirect_generic() async { | 2474 test_method_OK_single_implements_indirect_generic() async { |
2671 var library = await _encodeDecodeLibrary(r''' | 2475 var library = await _encodeDecodeLibrary(r''' |
2672 abstract class A<K, V> { | 2476 abstract class A<K, V> { |
2673 V m(K a); | 2477 V m(K a); |
2674 } | 2478 } |
2675 abstract class B<T1, T2> extends A<T2, T1> {} | 2479 abstract class B<T1, T2> extends A<T2, T1> {} |
2676 class C implements B<int, String> { | 2480 class C implements B<int, String> { |
2677 m(a) {} | 2481 m(a) {} |
2678 } | 2482 } |
2679 '''); | 2483 '''); |
2680 checkElementText( | 2484 checkElementText(library, r''' |
2681 library, | |
2682 r''' | |
2683 abstract class A<K, V> { | 2485 abstract class A<K, V> { |
2684 V m(K a); | 2486 V m(K a); |
2685 } | 2487 } |
2686 abstract class B<T1, T2> extends A<T2, T1> { | 2488 abstract class B<T1, T2> extends A<T2, T1> { |
2687 } | 2489 } |
2688 class C implements B<int, String> { | 2490 class C implements B<int, String> { |
2689 int m(String a) {} | 2491 int m(String a) {} |
2690 } | 2492 } |
2691 '''); | 2493 '''); |
2692 } | 2494 } |
2693 | 2495 |
2694 test_method_OK_single_private_linkThroughOtherLibraryOfCycle() async { | 2496 test_method_OK_single_private_linkThroughOtherLibraryOfCycle() async { |
2695 String path = _p('/other.dart'); | 2497 String path = _p('/other.dart'); |
2696 provider.newFile( | 2498 provider.newFile(path, r''' |
2697 path, | |
2698 r''' | |
2699 import 'test.dart'; | 2499 import 'test.dart'; |
2700 class B extends A2 {} | 2500 class B extends A2 {} |
2701 '''); | 2501 '''); |
2702 var library = await _encodeDecodeLibrary(r''' | 2502 var library = await _encodeDecodeLibrary(r''' |
2703 import 'other.dart'; | 2503 import 'other.dart'; |
2704 class A1 { | 2504 class A1 { |
2705 int _foo() => 1; | 2505 int _foo() => 1; |
2706 } | 2506 } |
2707 class A2 extends A1 { | 2507 class A2 extends A1 { |
2708 _foo() => 2; | 2508 _foo() => 2; |
2709 } | 2509 } |
2710 '''); | 2510 '''); |
2711 checkElementText( | 2511 checkElementText(library, r''' |
2712 library, | |
2713 r''' | |
2714 import 'other.dart'; | 2512 import 'other.dart'; |
2715 class A1 { | 2513 class A1 { |
2716 int _foo() {} | 2514 int _foo() {} |
2717 } | 2515 } |
2718 class A2 extends A1 { | 2516 class A2 extends A1 { |
2719 int _foo() {} | 2517 int _foo() {} |
2720 } | 2518 } |
2721 '''); | 2519 '''); |
2722 } | 2520 } |
2723 | 2521 |
2724 test_method_OK_single_withExtends_notGeneric() async { | 2522 test_method_OK_single_withExtends_notGeneric() async { |
2725 var library = await _encodeDecodeLibrary(r''' | 2523 var library = await _encodeDecodeLibrary(r''' |
2726 class A { | 2524 class A { |
2727 String m(int a) {} | 2525 String m(int a) {} |
2728 } | 2526 } |
2729 class B extends Object with A { | 2527 class B extends Object with A { |
2730 m(a) {} | 2528 m(a) {} |
2731 } | 2529 } |
2732 '''); | 2530 '''); |
2733 checkElementText( | 2531 checkElementText(library, r''' |
2734 library, | |
2735 r''' | |
2736 class A { | 2532 class A { |
2737 String m(int a) {} | 2533 String m(int a) {} |
2738 } | 2534 } |
2739 class B extends Object with A { | 2535 class B extends Object with A { |
2740 synthetic B(); | 2536 synthetic B(); |
2741 String m(int a) {} | 2537 String m(int a) {} |
2742 } | 2538 } |
2743 '''); | 2539 '''); |
2744 } | 2540 } |
2745 | 2541 |
2746 test_method_OK_two_extendsImplements_generic() async { | 2542 test_method_OK_two_extendsImplements_generic() async { |
2747 var library = await _encodeDecodeLibrary(r''' | 2543 var library = await _encodeDecodeLibrary(r''' |
2748 class A<K, V> { | 2544 class A<K, V> { |
2749 V m(K a) {} | 2545 V m(K a) {} |
2750 } | 2546 } |
2751 class B<T> { | 2547 class B<T> { |
2752 T m(int a) {} | 2548 T m(int a) {} |
2753 } | 2549 } |
2754 class C extends A<int, String> implements B<String> { | 2550 class C extends A<int, String> implements B<String> { |
2755 m(a) {} | 2551 m(a) {} |
2756 } | 2552 } |
2757 '''); | 2553 '''); |
2758 checkElementText( | 2554 checkElementText(library, r''' |
2759 library, | |
2760 r''' | |
2761 class A<K, V> { | 2555 class A<K, V> { |
2762 V m(K a) {} | 2556 V m(K a) {} |
2763 } | 2557 } |
2764 class B<T> { | 2558 class B<T> { |
2765 T m(int a) {} | 2559 T m(int a) {} |
2766 } | 2560 } |
2767 class C extends A<int, String> implements B<String> { | 2561 class C extends A<int, String> implements B<String> { |
2768 String m(int a) {} | 2562 String m(int a) {} |
2769 } | 2563 } |
2770 '''); | 2564 '''); |
2771 } | 2565 } |
2772 | 2566 |
2773 test_method_OK_two_extendsImplements_notGeneric() async { | 2567 test_method_OK_two_extendsImplements_notGeneric() async { |
2774 var library = await _encodeDecodeLibrary(r''' | 2568 var library = await _encodeDecodeLibrary(r''' |
2775 class A { | 2569 class A { |
2776 String m(int a) {} | 2570 String m(int a) {} |
2777 } | 2571 } |
2778 class B { | 2572 class B { |
2779 String m(int a) {} | 2573 String m(int a) {} |
2780 } | 2574 } |
2781 class C extends A implements B { | 2575 class C extends A implements B { |
2782 m(a) {} | 2576 m(a) {} |
2783 } | 2577 } |
2784 '''); | 2578 '''); |
2785 checkElementText( | 2579 checkElementText(library, r''' |
2786 library, | |
2787 r''' | |
2788 class A { | 2580 class A { |
2789 String m(int a) {} | 2581 String m(int a) {} |
2790 } | 2582 } |
2791 class B { | 2583 class B { |
2792 String m(int a) {} | 2584 String m(int a) {} |
2793 } | 2585 } |
2794 class C extends A implements B { | 2586 class C extends A implements B { |
2795 String m(int a) {} | 2587 String m(int a) {} |
2796 } | 2588 } |
2797 '''); | 2589 '''); |
2798 } | 2590 } |
2799 | 2591 |
2800 Future<LibraryElement> _encodeDecodeLibrary(String text) async { | 2592 Future<LibraryElement> _encodeDecodeLibrary(String text) async { |
2801 String path = _p('/test.dart'); | 2593 String path = _p('/test.dart'); |
2802 provider.newFile(path, text); | 2594 provider.newFile(path, text); |
2803 UnitElementResult result = await driver.getUnitElement(path); | 2595 UnitElementResult result = await driver.getUnitElement(path); |
2804 return result.element.library; | 2596 return result.element.library; |
2805 } | 2597 } |
2806 | 2598 |
2807 String _p(String path) => provider.convertPath(path); | 2599 String _p(String path) => provider.convertPath(path); |
2808 } | 2600 } |
OLD | NEW |