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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 | 914 |
915 test_functionModifiers_async() async { | 915 test_functionModifiers_async() async { |
916 await checkFile(''' | 916 await checkFile(''' |
917 import 'dart:async'; | 917 import 'dart:async'; |
918 import 'dart:math' show Random; | 918 import 'dart:math' show Random; |
919 | 919 |
920 dynamic x; | 920 dynamic x; |
921 | 921 |
922 foo1() async => x; | 922 foo1() async => x; |
923 Future foo2() async => x; | 923 Future foo2() async => x; |
924 Future<int> foo3() async => x; | 924 Future<int> foo3() async => /*info:DYNAMIC_CAST*/x; |
925 Future<int> foo4() async => new Future<int>.value(x); | 925 Future<int> foo4() async => new Future<int>.value(x); |
926 Future<int> foo5() async => | 926 Future<int> foo5() async => |
927 /*error:RETURN_OF_INVALID_TYPE*/new Future<String>.value(x); | 927 /*error:RETURN_OF_INVALID_TYPE*/new Future<String>.value(x); |
928 | 928 |
929 bar1() async { return x; } | 929 bar1() async { return x; } |
930 Future bar2() async { return x; } | 930 Future bar2() async { return x; } |
931 Future<int> bar3() async { return x; } | 931 Future<int> bar3() async { return /*info:DYNAMIC_CAST*/x; } |
932 Future<int> bar4() async { return new Future<int>.value(x); } | 932 Future<int> bar4() async { return new Future<int>.value(x); } |
933 Future<int> bar5() async { | 933 Future<int> bar5() async { |
934 return /*error:RETURN_OF_INVALID_TYPE*/new Future<String>.value(x); | 934 return /*error:RETURN_OF_INVALID_TYPE*/new Future<String>.value(x); |
935 } | 935 } |
936 | 936 |
937 int y; | 937 int y; |
938 Future<int> z; | 938 Future<int> z; |
939 | 939 |
940 baz() async { | 940 baz() async { |
941 int a = /*info:DYNAMIC_CAST*/await x; | 941 int a = /*info:DYNAMIC_CAST*/await x; |
942 int b = await y; | 942 int b = await y; |
943 int c = await z; | 943 int c = await z; |
944 String d = /*error:INVALID_ASSIGNMENT*/await z; | 944 String d = /*error:INVALID_ASSIGNMENT*/await z; |
945 } | 945 } |
946 | 946 |
947 Future<bool> get issue_ddc_264 async { | 947 Future<bool> get issue_ddc_264 async { |
948 await 42; | 948 await 42; |
949 if (new Random().nextBool()) { | 949 if (new Random().nextBool()) { |
950 return true; | 950 return true; |
951 } else { | 951 } else { |
952 return new Future<bool>.value(false); | 952 return new Future<bool>.value(false); |
953 } | 953 } |
954 } | 954 } |
955 | 955 |
956 | 956 |
957 Future<String> issue_sdk_26404() async { | 957 Future<String> issue_sdk_26404() async { |
958 return (1 > 0) ? new Future<String>.value('hello') : "world"; | 958 return (/*info:DOWN_CAST_COMPOSITE*/(1 > 0) ? new Future<String>.value('hello' ) : "world"); |
vsm
2017/04/05 15:52:59
FYI - this is a cast from Object to FutureOr<Strin
Leaf
2017/04/05 20:47:27
The fact that the LUB is Object is WAI. The conse
vsm
2017/04/07 22:23:07
Makes sense. Yes, it'll work - just unnecessary c
| |
959 } | 959 } |
960 '''); | 960 '''); |
961 } | 961 } |
962 | 962 |
963 test_functionModifiers_asyncStar() async { | 963 test_functionModifiers_asyncStar() async { |
964 await checkFile(''' | 964 await checkFile(''' |
965 import 'dart:async'; | 965 import 'dart:async'; |
966 | 966 |
967 dynamic x; | 967 dynamic x; |
968 | 968 |
(...skipping 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4142 class CheckerTest_Driver extends CheckerTest { | 4142 class CheckerTest_Driver extends CheckerTest { |
4143 @override | 4143 @override |
4144 bool get enableNewAnalysisDriver => true; | 4144 bool get enableNewAnalysisDriver => true; |
4145 | 4145 |
4146 @failingTest | 4146 @failingTest |
4147 @override | 4147 @override |
4148 test_covariantOverride_fields() async { | 4148 test_covariantOverride_fields() async { |
4149 await super.test_covariantOverride_fields(); | 4149 await super.test_covariantOverride_fields(); |
4150 } | 4150 } |
4151 } | 4151 } |
OLD | NEW |