OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.src.task.strong.checker_test; | 5 library analyzer.test.src.task.strong.checker_test; |
6 | 6 |
7 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
8 | 8 |
9 import 'strong_test_helper.dart'; | 9 import 'strong_test_helper.dart'; |
10 | 10 |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 void main() { | 482 void main() { |
483 var a = new A(); | 483 var a = new A(); |
484 bar(a); | 484 bar(a); |
485 (/*info:DYNAMIC_INVOKE*/bar1(a)); | 485 (/*info:DYNAMIC_INVOKE*/bar1(a)); |
486 var b = bar; | 486 var b = bar; |
487 (/*info:DYNAMIC_INVOKE*/b(a)); | 487 (/*info:DYNAMIC_INVOKE*/b(a)); |
488 var f1 = foo; | 488 var f1 = foo; |
489 f1("hello"); | 489 f1("hello"); |
490 dynamic f2 = foo; | 490 dynamic f2 = foo; |
491 (/*info:DYNAMIC_INVOKE*/f2("hello")); | 491 (/*info:DYNAMIC_INVOKE*/f2("hello")); |
492 DynFun f3 = foo; | 492 DynFun f3 = /*info:USES_DYNAMIC_AS_BOTTOM*/foo; |
493 (/*info:DYNAMIC_INVOKE*/f3("hello")); | 493 (/*info:DYNAMIC_INVOKE*/f3("hello")); |
494 (/*info:DYNAMIC_INVOKE*/f3(42)); | 494 (/*info:DYNAMIC_INVOKE*/f3(42)); |
495 StrFun f4 = foo; | 495 StrFun f4 = foo; |
496 f4("hello"); | 496 f4("hello"); |
497 a.baz1("hello"); | 497 a.baz1("hello"); |
498 var b1 = a.baz1; | 498 var b1 = a.baz1; |
499 (/*info:DYNAMIC_INVOKE*/b1("hello")); | 499 (/*info:DYNAMIC_INVOKE*/b1("hello")); |
500 A.baz2("hello"); | 500 A.baz2("hello"); |
501 var b2 = A.baz2; | 501 var b2 = A.baz2; |
502 (/*info:DYNAMIC_INVOKE*/b2("hello")); | 502 (/*info:DYNAMIC_INVOKE*/b2("hello")); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); | 666 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); |
667 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/co
l(3.0); | 667 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/co
l(3.0); |
668 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); | 668 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); |
669 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/co
l(3.0); | 669 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/co
l(3.0); |
670 /*info:DYNAMIC_INVOKE*/f(3.0); | 670 /*info:DYNAMIC_INVOKE*/f(3.0); |
671 // Through type propagation, we know f is actually a B, hence the | 671 // Through type propagation, we know f is actually a B, hence the |
672 // hint. | 672 // hint. |
673 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/col(3); | 673 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/col(3); |
674 } | 674 } |
675 { | 675 { |
676 A f = new B(); | 676 A f = /*info:USES_DYNAMIC_AS_BOTTOM*/new B(); |
677 int x; | 677 int x; |
678 double y; | 678 double y; |
679 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); | 679 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); |
680 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); | 680 y = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); |
681 /*info:DYNAMIC_INVOKE*/f(3.0); | 681 /*info:DYNAMIC_INVOKE*/f(3.0); |
682 } | 682 } |
683 { | 683 { |
684 dynamic g = new B(); | 684 dynamic g = new B(); |
685 /*info:DYNAMIC_INVOKE*/g.call(32.0); | 685 /*info:DYNAMIC_INVOKE*/g.call(32.0); |
686 /*info:DYNAMIC_INVOKE*/g.col(42.0); | 686 /*info:DYNAMIC_INVOKE*/g.col(42.0); |
687 /*info:DYNAMIC_INVOKE*/g.foo(42.0); | 687 /*info:DYNAMIC_INVOKE*/g.foo(42.0); |
688 /*info:DYNAMIC_INVOKE*/g.x; | 688 /*info:DYNAMIC_INVOKE*/g.x; |
689 A f = new B(); | 689 A f = /*info:USES_DYNAMIC_AS_BOTTOM*/new B(); |
690 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/col(42.0); | 690 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/col(42.0); |
691 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/foo(42.0); | 691 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_METHOD*/foo(42.0); |
692 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_GETTER*/x; | 692 /*info:DYNAMIC_INVOKE*/f./*error:UNDEFINED_GETTER*/x; |
693 } | 693 } |
694 } | 694 } |
695 '''); | 695 '''); |
696 } | 696 } |
697 | 697 |
698 test_factoryConstructorDowncast() async { | 698 test_factoryConstructorDowncast() async { |
699 await checkFile(r''' | 699 await checkFile(r''' |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 f = bot; | 1055 f = bot; |
1056 } | 1056 } |
1057 } | 1057 } |
1058 '''); | 1058 '''); |
1059 } | 1059 } |
1060 | 1060 |
1061 test_functionTypingAndSubtyping_dynamic() async { | 1061 test_functionTypingAndSubtyping_dynamic() async { |
1062 await checkFile(''' | 1062 await checkFile(''' |
1063 class A {} | 1063 class A {} |
1064 | 1064 |
1065 typedef dynamic Top(dynamic x); // Top of the lattice | 1065 typedef dynamic Top(Null x); // Top of the lattice |
1066 typedef dynamic Left(A x); // Left branch | 1066 typedef dynamic Left(A x); // Left branch |
1067 typedef A Right(dynamic x); // Right branch | 1067 typedef A Right(Null x); // Right branch |
1068 typedef A Bottom(A x); // Bottom of the lattice | 1068 typedef A Bottom(A x); // Bottom of the lattice |
1069 | 1069 |
1070 void main() { | 1070 void main() { |
1071 Top top; | 1071 Top top; |
1072 Left left; | 1072 Left left; |
1073 Right right; | 1073 Right right; |
1074 Bottom bot; | 1074 Bottom bot; |
1075 { | 1075 { |
1076 Top f; | 1076 Top f; |
1077 f = top; | 1077 f = top; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 // \ / | 1116 // \ / |
1117 // Top -> A | 1117 // Top -> A |
1118 // | 1118 // |
1119 // Note that downcasts of known functions are promoted to | 1119 // Note that downcasts of known functions are promoted to |
1120 // static type errors, since they cannot succeed. | 1120 // static type errors, since they cannot succeed. |
1121 // This makes some of what look like downcasts turn into | 1121 // This makes some of what look like downcasts turn into |
1122 // type errors below. | 1122 // type errors below. |
1123 await checkFile(''' | 1123 await checkFile(''' |
1124 class A {} | 1124 class A {} |
1125 | 1125 |
1126 typedef dynamic BotTop(dynamic x); | 1126 typedef dynamic BotTop(Null x); |
1127 typedef dynamic ATop(A x); | 1127 typedef dynamic ATop(A x); |
1128 typedef A BotA(dynamic x); | 1128 typedef A BotA(Null x); |
1129 typedef A AA(A x); | 1129 typedef A AA(A x); |
1130 typedef A TopA(Object x); | 1130 typedef A TopA(Object x); |
1131 typedef dynamic TopTop(Object x); | 1131 typedef dynamic TopTop(Object x); |
1132 | 1132 |
1133 dynamic aTop(A x) => x; | 1133 dynamic aTop(A x) => x; |
1134 A aa(A x) => x; | 1134 A aa(A x) => x; |
1135 dynamic topTop(dynamic x) => x; | 1135 dynamic topTop(dynamic x) => x; |
1136 A topA(dynamic x) => /*info:DYNAMIC_CAST*/x; | 1136 A topA(dynamic x) => /*info:DYNAMIC_CAST*/x; |
1137 void apply<T>(T f0, T f1, T f2, | 1137 void apply<T>(T f0, T f1, T f2, |
1138 T f3, T f4, T f5) {} | 1138 T f3, T f4, T f5) {} |
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 } | 3084 } |
3085 | 3085 |
3086 test_leastUpperBounds_fuzzyArrows() async { | 3086 test_leastUpperBounds_fuzzyArrows() async { |
3087 await checkFile(r''' | 3087 await checkFile(r''' |
3088 typedef String TakesA<T>(T item); | 3088 typedef String TakesA<T>(T item); |
3089 | 3089 |
3090 void main() { | 3090 void main() { |
3091 TakesA<int> f; | 3091 TakesA<int> f; |
3092 TakesA<dynamic> g; | 3092 TakesA<dynamic> g; |
3093 TakesA<String> h; | 3093 TakesA<String> h; |
3094 g = h; | 3094 g = /*info:USES_DYNAMIC_AS_BOTTOM*/h; |
3095 f = /*info:DOWN_CAST_COMPOSITE*/f ?? g; | 3095 f = /*info:DOWN_CAST_COMPOSITE*/f ?? g; |
3096 } | 3096 } |
3097 '''); | 3097 '''); |
3098 } | 3098 } |
3099 | 3099 |
3100 test_loadLibrary() async { | 3100 test_loadLibrary() async { |
3101 addFile('''library lib1;''', name: '/lib1.dart'); | 3101 addFile('''library lib1;''', name: '/lib1.dart'); |
3102 await checkFile(r''' | 3102 await checkFile(r''' |
3103 import 'lib1.dart' deferred as lib1; | 3103 import 'lib1.dart' deferred as lib1; |
3104 import 'dart:async' show Future; | 3104 import 'dart:async' show Future; |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4458 class CheckerTest_Driver extends CheckerTest { | 4458 class CheckerTest_Driver extends CheckerTest { |
4459 @override | 4459 @override |
4460 bool get enableNewAnalysisDriver => true; | 4460 bool get enableNewAnalysisDriver => true; |
4461 | 4461 |
4462 @failingTest | 4462 @failingTest |
4463 @override | 4463 @override |
4464 test_covariantOverride_fields() async { | 4464 test_covariantOverride_fields() async { |
4465 await super.test_covariantOverride_fields(); | 4465 await super.test_covariantOverride_fields(); |
4466 } | 4466 } |
4467 } | 4467 } |
OLD | NEW |