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

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

Issue 2253923002: fix #27088, future then upwards inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.task.strong.checker_test; 5 library analyzer.test.src.task.strong.checker_test;
6 6
7 import '../../../reflective_tests.dart'; 7 import '../../../reflective_tests.dart';
8 import 'strong_test_helper.dart'; 8 import 'strong_test_helper.dart';
9 9
10 void main() { 10 void main() {
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop, 972 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop,
973 aa, 973 aa,
974 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aTop, 974 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aTop,
975 botA, 975 botA,
976 /*warning:DOWN_CAST_COMPOSITE*/botTop 976 /*warning:DOWN_CAST_COMPOSITE*/botTop
977 ); 977 );
978 apply/*<BotA>*/( 978 apply/*<BotA>*/(
979 (dynamic x) => new A(), 979 (dynamic x) => new A(),
980 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object), 980 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object),
981 (A x) => x, 981 (A x) => x,
982 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => (x as Object), 982 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => (/*info:UNNECESSARY_CAST* /x as Object),
983 botA, 983 botA,
984 /*warning:DOWN_CAST_COMPOSITE*/botTop 984 /*warning:DOWN_CAST_COMPOSITE*/botTop
985 ); 985 );
986 } 986 }
987 { 987 {
988 AA f; 988 AA f;
989 f = topA; 989 f = topA;
990 f = /*error:INVALID_ASSIGNMENT*/topTop; 990 f = /*error:INVALID_ASSIGNMENT*/topTop;
991 f = aa; 991 f = aa;
992 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function 992 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function
993 f = /*warning:DOWN_CAST_COMPOSITE*/botA; 993 f = /*warning:DOWN_CAST_COMPOSITE*/botA;
994 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 994 f = /*warning:DOWN_CAST_COMPOSITE*/botTop;
995 apply/*<AA>*/( 995 apply/*<AA>*/(
996 topA, 996 topA,
997 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop, 997 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop,
998 aa, 998 aa,
999 /*error:STATIC_TYPE_ERROR*/aTop, // known function 999 /*error:STATIC_TYPE_ERROR*/aTop, // known function
1000 /*warning:DOWN_CAST_COMPOSITE*/botA, 1000 /*warning:DOWN_CAST_COMPOSITE*/botA,
1001 /*warning:DOWN_CAST_COMPOSITE*/botTop 1001 /*warning:DOWN_CAST_COMPOSITE*/botTop
1002 ); 1002 );
1003 apply/*<AA>*/( 1003 apply/*<AA>*/(
1004 (dynamic x) => new A(), 1004 (dynamic x) => new A(),
1005 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object), 1005 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object),
1006 (A x) => x, 1006 (A x) => x,
1007 /*error:STATIC_TYPE_ERROR*/(A x) => (x as Object), // known function 1007 /*error:STATIC_TYPE_ERROR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Objec t), // known function
1008 /*warning:DOWN_CAST_COMPOSITE*/botA, 1008 /*warning:DOWN_CAST_COMPOSITE*/botA,
1009 /*warning:DOWN_CAST_COMPOSITE*/botTop 1009 /*warning:DOWN_CAST_COMPOSITE*/botTop
1010 ); 1010 );
1011 } 1011 }
1012 { 1012 {
1013 TopTop f; 1013 TopTop f;
1014 f = topA; 1014 f = topA;
1015 f = topTop; 1015 f = topTop;
1016 f = /*error:INVALID_ASSIGNMENT*/aa; 1016 f = /*error:INVALID_ASSIGNMENT*/aa;
1017 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function 1017 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function
1018 f = /*error:INVALID_ASSIGNMENT*/botA; 1018 f = /*error:INVALID_ASSIGNMENT*/botA;
1019 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1019 f = /*warning:DOWN_CAST_COMPOSITE*/botTop;
1020 apply/*<TopTop>*/( 1020 apply/*<TopTop>*/(
1021 topA, 1021 topA,
1022 topTop, 1022 topTop,
1023 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aa, 1023 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aa,
1024 /*error:STATIC_TYPE_ERROR*/aTop, // known function 1024 /*error:STATIC_TYPE_ERROR*/aTop, // known function
1025 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1025 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1026 /*warning:DOWN_CAST_COMPOSITE*/botTop 1026 /*warning:DOWN_CAST_COMPOSITE*/botTop
1027 ); 1027 );
1028 apply/*<TopTop>*/( 1028 apply/*<TopTop>*/(
1029 (dynamic x) => new A(), 1029 (dynamic x) => new A(),
1030 (dynamic x) => (x as Object), 1030 (dynamic x) => (x as Object),
1031 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => x, 1031 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => x,
1032 /*error:STATIC_TYPE_ERROR*/(A x) => (x as Object), // known function 1032 /*error:STATIC_TYPE_ERROR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Objec t), // known function
1033 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1033 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1034 /*warning:DOWN_CAST_COMPOSITE*/botTop 1034 /*warning:DOWN_CAST_COMPOSITE*/botTop
1035 ); 1035 );
1036 } 1036 }
1037 { 1037 {
1038 TopA f; 1038 TopA f;
1039 f = topA; 1039 f = topA;
1040 f = /*error:STATIC_TYPE_ERROR*/topTop; // known function 1040 f = /*error:STATIC_TYPE_ERROR*/topTop; // known function
1041 f = /*error:STATIC_TYPE_ERROR*/aa; // known function 1041 f = /*error:STATIC_TYPE_ERROR*/aa; // known function
1042 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function 1042 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function
1043 f = /*warning:DOWN_CAST_COMPOSITE*/botA; 1043 f = /*warning:DOWN_CAST_COMPOSITE*/botA;
1044 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1044 f = /*warning:DOWN_CAST_COMPOSITE*/botTop;
1045 apply/*<TopA>*/( 1045 apply/*<TopA>*/(
1046 topA, 1046 topA,
1047 /*error:STATIC_TYPE_ERROR*/topTop, // known function 1047 /*error:STATIC_TYPE_ERROR*/topTop, // known function
1048 /*error:STATIC_TYPE_ERROR*/aa, // known function 1048 /*error:STATIC_TYPE_ERROR*/aa, // known function
1049 /*error:STATIC_TYPE_ERROR*/aTop, // known function 1049 /*error:STATIC_TYPE_ERROR*/aTop, // known function
1050 /*warning:DOWN_CAST_COMPOSITE*/botA, 1050 /*warning:DOWN_CAST_COMPOSITE*/botA,
1051 /*warning:DOWN_CAST_COMPOSITE*/botTop 1051 /*warning:DOWN_CAST_COMPOSITE*/botTop
1052 ); 1052 );
1053 apply/*<TopA>*/( 1053 apply/*<TopA>*/(
1054 (dynamic x) => new A(), 1054 (dynamic x) => new A(),
1055 /*error:STATIC_TYPE_ERROR*/(dynamic x) => (x as Object), // known functi on 1055 /*error:STATIC_TYPE_ERROR*/(dynamic x) => (x as Object), // known functi on
1056 /*error:STATIC_TYPE_ERROR*/(A x) => x, // known function 1056 /*error:STATIC_TYPE_ERROR*/(A x) => x, // known function
1057 /*error:STATIC_TYPE_ERROR*/(A x) => (x as Object), // known function 1057 /*error:STATIC_TYPE_ERROR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Objec t), // known function
1058 /*warning:DOWN_CAST_COMPOSITE*/botA, 1058 /*warning:DOWN_CAST_COMPOSITE*/botA,
1059 /*warning:DOWN_CAST_COMPOSITE*/botTop 1059 /*warning:DOWN_CAST_COMPOSITE*/botTop
1060 ); 1060 );
1061 } 1061 }
1062 } 1062 }
1063 '''); 1063 ''');
1064 } 1064 }
1065 1065
1066 void test_functionTypingAndSubtyping_dynamicFunctions_clasuresAreNotFuzzy() { 1066 void test_functionTypingAndSubtyping_dynamicFunctions_clasuresAreNotFuzzy() {
1067 // Regression test for 1067 // Regression test for
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 } 1626 }
1627 int i2i(int x) => x; 1627 int i2i(int x) => x;
1628 num n2n(num x) => x; 1628 num n2n(num x) => x;
1629 void main() { 1629 void main() {
1630 { 1630 {
1631 I2I f; 1631 I2I f;
1632 f = new A(); 1632 f = new A();
1633 f = /*error:INVALID_ASSIGNMENT*/new B(); 1633 f = /*error:INVALID_ASSIGNMENT*/new B();
1634 f = i2i; 1634 f = i2i;
1635 f = /*error:INVALID_ASSIGNMENT*/n2n; 1635 f = /*error:INVALID_ASSIGNMENT*/n2n;
1636 f = /*warning:DOWN_CAST_COMPOSITE*/i2i as Object; 1636 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/i2i as Object;
1637 f = /*warning:DOWN_CAST_COMPOSITE*/n2n as Function; 1637 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/n2n as Function;
1638 } 1638 }
1639 { 1639 {
1640 N2N f; 1640 N2N f;
1641 f = /*error:INVALID_ASSIGNMENT*/new A(); 1641 f = /*error:INVALID_ASSIGNMENT*/new A();
1642 f = new B(); 1642 f = new B();
1643 f = /*error:INVALID_ASSIGNMENT*/i2i; 1643 f = /*error:INVALID_ASSIGNMENT*/i2i;
1644 f = n2n; 1644 f = n2n;
1645 f = /*warning:DOWN_CAST_COMPOSITE*/i2i as Object; 1645 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/i2i as Object;
1646 f = /*warning:DOWN_CAST_COMPOSITE*/n2n as Function; 1646 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/n2n as Function;
1647 } 1647 }
1648 { 1648 {
1649 A f; 1649 A f;
1650 f = new A(); 1650 f = new A();
1651 f = /*error:INVALID_ASSIGNMENT*/new B(); 1651 f = /*error:INVALID_ASSIGNMENT*/new B();
1652 f = /*error:INVALID_ASSIGNMENT*/i2i; 1652 f = /*error:INVALID_ASSIGNMENT*/i2i;
1653 f = /*error:INVALID_ASSIGNMENT*/n2n; 1653 f = /*error:INVALID_ASSIGNMENT*/n2n;
1654 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; 1654 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/i2i as Object;
1655 f = /*info:DOWN_CAST_IMPLICIT*/n2n as Function; 1655 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/n2n as Function;
1656 } 1656 }
1657 { 1657 {
1658 B f; 1658 B f;
1659 f = /*error:INVALID_ASSIGNMENT*/new A(); 1659 f = /*error:INVALID_ASSIGNMENT*/new A();
1660 f = new B(); 1660 f = new B();
1661 f = /*error:INVALID_ASSIGNMENT*/i2i; 1661 f = /*error:INVALID_ASSIGNMENT*/i2i;
1662 f = /*error:INVALID_ASSIGNMENT*/n2n; 1662 f = /*error:INVALID_ASSIGNMENT*/n2n;
1663 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; 1663 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/i2i as Object;
1664 f = /*info:DOWN_CAST_IMPLICIT*/n2n as Function; 1664 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/n2n as Function;
1665 } 1665 }
1666 { 1666 {
1667 Function f; 1667 Function f;
1668 f = new A(); 1668 f = new A();
1669 f = new B(); 1669 f = new B();
1670 f = i2i; 1670 f = i2i;
1671 f = n2n; 1671 f = n2n;
1672 f = /*info:DOWN_CAST_IMPLICIT*/i2i as Object; 1672 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/i2i as Object;
1673 f = (n2n as Function); 1673 f = /*info:UNNECESSARY_CAST*/n2n as Function;
1674 } 1674 }
1675 } 1675 }
1676 '''); 1676 ''');
1677 } 1677 }
1678 1678
1679 void test_functionTypingAndSubtyping_staticMethodVariance() { 1679 void test_functionTypingAndSubtyping_staticMethodVariance() {
1680 checkFile(''' 1680 checkFile('''
1681 class A {} 1681 class A {}
1682 class B extends A {} 1682 class B extends A {}
1683 1683
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 /*=T*/ g/*<T>*/() => null; 1981 /*=T*/ g/*<T>*/() => null;
1982 1982
1983 /*error:IMPLICIT_DYNAMIC_FUNCTION*/f(d); 1983 /*error:IMPLICIT_DYNAMIC_FUNCTION*/f(d);
1984 f(42); 1984 f(42);
1985 /*error:IMPLICIT_DYNAMIC_FUNCTION*/g(); 1985 /*error:IMPLICIT_DYNAMIC_FUNCTION*/g();
1986 d = /*error:IMPLICIT_DYNAMIC_FUNCTION*/g(); 1986 d = /*error:IMPLICIT_DYNAMIC_FUNCTION*/g();
1987 i = g(); 1987 i = g();
1988 1988
1989 /*error:IMPLICIT_DYNAMIC_INVOKE*/(/*<T>*/(/*=T*/ t) => t)(d); 1989 /*error:IMPLICIT_DYNAMIC_INVOKE*/(/*<T>*/(/*=T*/ t) => t)(d);
1990 (/*<T>*/(/*=T*/ t) => t)(42); 1990 (/*<T>*/(/*=T*/ t) => t)(42);
1991 (/*<T>*/() => null as dynamic/*=T*/)/*<int>*/(); 1991 (/*<T>*/() => /*info:UNNECESSARY_CAST*/null as dynamic/*=T*/)/*<int>*/();
1992 } 1992 }
1993 '''); 1993 ''');
1994 check(implicitDynamic: false); 1994 check(implicitDynamic: false);
1995 } 1995 }
1996 void test_implicitDynamic_listLiteral() { 1996 void test_implicitDynamic_listLiteral() {
1997 addFile(r''' 1997 addFile(r'''
1998 1998
1999 var l0 = /*error:IMPLICIT_DYNAMIC_LIST_LITERAL*/[]; 1999 var l0 = /*error:IMPLICIT_DYNAMIC_LIST_LITERAL*/[];
2000 List l1 = /*error:IMPLICIT_DYNAMIC_LIST_LITERAL*/[]; 2000 List l1 = /*error:IMPLICIT_DYNAMIC_LIST_LITERAL*/[];
2001 List<dynamic> l2 = /*error:IMPLICIT_DYNAMIC_LIST_LITERAL*/[]; 2001 List<dynamic> l2 = /*error:IMPLICIT_DYNAMIC_LIST_LITERAL*/[];
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is DI2I; 2548 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is DI2I;
2549 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is ID2I; 2549 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is ID2I;
2550 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is II2D; 2550 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is II2D;
2551 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is DD2I; 2551 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is DD2I;
2552 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is DI2D; 2552 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is DI2D;
2553 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is ID2D; 2553 b = /*info:NON_GROUND_TYPE_CHECK_INFO*/bar is ID2D;
2554 b = bar is DD2D; 2554 b = bar is DD2D;
2555 2555
2556 // For as, the validity of checks is deferred to runtime. 2556 // For as, the validity of checks is deferred to runtime.
2557 Function f; 2557 Function f;
2558 f = foo as I2I; 2558 f = /*info:UNNECESSARY_CAST*/foo as I2I;
2559 f = foo as D2I; 2559 f = /*info:UNNECESSARY_CAST*/foo as D2I;
2560 f = foo as I2D; 2560 f = /*info:UNNECESSARY_CAST*/foo as I2D;
2561 f = foo as D2D; 2561 f = /*info:UNNECESSARY_CAST*/foo as D2D;
2562 2562
2563 f = bar as II2I; 2563 f = /*info:UNNECESSARY_CAST*/bar as II2I;
2564 f = bar as DI2I; 2564 f = /*info:UNNECESSARY_CAST*/bar as DI2I;
2565 f = bar as ID2I; 2565 f = /*info:UNNECESSARY_CAST*/bar as ID2I;
2566 f = bar as II2D; 2566 f = /*info:UNNECESSARY_CAST*/bar as II2D;
2567 f = bar as DD2I; 2567 f = /*info:UNNECESSARY_CAST*/bar as DD2I;
2568 f = bar as DI2D; 2568 f = /*info:UNNECESSARY_CAST*/bar as DI2D;
2569 f = bar as ID2D; 2569 f = /*info:UNNECESSARY_CAST*/bar as ID2D;
2570 f = bar as DD2D; 2570 f = /*info:UNNECESSARY_CAST*/bar as DD2D;
2571 } 2571 }
2572 '''); 2572 ''');
2573 } 2573 }
2574 2574
2575 void test_leastUpperBounds() { 2575 void test_leastUpperBounds() {
2576 checkFile(''' 2576 checkFile('''
2577 typedef T Returns<T>(); 2577 typedef T Returns<T>();
2578 2578
2579 // regression test for https://github.com/dart-lang/sdk/issues/26094 2579 // regression test for https://github.com/dart-lang/sdk/issues/26094
2580 class A <S extends Returns<S>, T extends Returns<T>> { 2580 class A <S extends Returns<S>, T extends Returns<T>> {
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3747 // Regression test for https://github.com/dart-lang/sdk/issues/25069 3747 // Regression test for https://github.com/dart-lang/sdk/issues/25069
3748 checkFile(''' 3748 checkFile('''
3749 typedef int Foo(); 3749 typedef int Foo();
3750 void foo() {} 3750 void foo() {}
3751 void main () { 3751 void main () {
3752 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); 3752 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo();
3753 } 3753 }
3754 '''); 3754 ''');
3755 } 3755 }
3756 } 3756 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/analysis_context_factory.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698