| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.generated.strong_mode_test; | 5 library analyzer.test.generated.strong_mode_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/dart/element/type.dart'; | 9 import 'package:analyzer/dart/element/type.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 type = returnExp.expression.staticType; | 114 type = returnExp.expression.staticType; |
| 115 } | 115 } |
| 116 typeTest(type); | 116 typeTest(type); |
| 117 } | 117 } |
| 118 | 118 |
| 119 check("f0", _isFutureOfDynamic); | 119 check("f0", _isFutureOfDynamic); |
| 120 check("f1", _isFutureOfDynamic); | 120 check("f1", _isFutureOfDynamic); |
| 121 check("f2", _isFutureOfDynamic); | 121 check("f2", _isFutureOfDynamic); |
| 122 | 122 |
| 123 check("f3", _isFutureOfInt); | 123 check("f3", _isFutureOfInt); |
| 124 // This should be int when we handle the implicit Future<T> | T union | 124 check("f4", _isFutureOfInt); |
| 125 // https://github.com/dart-lang/sdk/issues/25322 | |
| 126 check("f4", _isFutureOfDynamic); | |
| 127 check("f5", _isFutureOfInt); | 125 check("f5", _isFutureOfInt); |
| 128 | 126 |
| 129 check("g0", _isFutureOfDynamic); | 127 check("g0", _isFutureOfDynamic); |
| 130 check("g1", _isFutureOfDynamic); | 128 check("g1", _isFutureOfDynamic); |
| 131 check("g2", _isFutureOfDynamic); | 129 check("g2", _isFutureOfDynamic); |
| 132 | 130 |
| 133 check("g3", _isFutureOfInt); | 131 check("g3", _isFutureOfInt); |
| 134 // This should be int when we handle the implicit Future<T> | T union | 132 check("g4", _isFutureOfInt); |
| 135 // https://github.com/dart-lang/sdk/issues/25322 | |
| 136 check("g4", _isFutureOfDynamic); | |
| 137 check("g5", _isFutureOfInt); | 133 check("g5", _isFutureOfInt); |
| 138 } | 134 } |
| 139 | 135 |
| 140 void test_async_propagation() { | 136 void test_async_propagation() { |
| 141 String code = r''' | 137 String code = r''' |
| 142 import "dart:async"; | 138 import "dart:async"; |
| 143 | 139 |
| 144 Future f0() => new Future.value(3); | 140 Future f0() => new Future.value(3); |
| 145 Future f1() async => new Future.value(3); | 141 Future f1() async => new Future.value(3); |
| 146 Future f2() async => await new Future.value(3); | 142 Future f2() async => await new Future.value(3); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 174 type = returnExp.expression.staticType; | 170 type = returnExp.expression.staticType; |
| 175 } | 171 } |
| 176 typeTest(type); | 172 typeTest(type); |
| 177 } | 173 } |
| 178 | 174 |
| 179 check("f0", _isFutureOfDynamic); | 175 check("f0", _isFutureOfDynamic); |
| 180 check("f1", _isFutureOfDynamic); | 176 check("f1", _isFutureOfDynamic); |
| 181 check("f2", _isFutureOfDynamic); | 177 check("f2", _isFutureOfDynamic); |
| 182 | 178 |
| 183 check("f3", _isFutureOfInt); | 179 check("f3", _isFutureOfInt); |
| 184 // This should be int when we handle the implicit Future<T> | T union | 180 check("f4", _isFutureOfInt); |
| 185 // https://github.com/dart-lang/sdk/issues/25322 | |
| 186 check("f4", _isFutureOfDynamic); | |
| 187 check("f5", _isFutureOfInt); | 181 check("f5", _isFutureOfInt); |
| 188 | 182 |
| 189 check("g0", _isFutureOfDynamic); | 183 check("g0", _isFutureOfDynamic); |
| 190 check("g1", _isFutureOfDynamic); | 184 check("g1", _isFutureOfDynamic); |
| 191 check("g2", _isFutureOfDynamic); | 185 check("g2", _isFutureOfDynamic); |
| 192 | 186 |
| 193 check("g3", _isFutureOfInt); | 187 check("g3", _isFutureOfInt); |
| 194 // This should be int when we handle the implicit Future<T> | T union | 188 check("g4", _isFutureOfInt); |
| 195 // https://github.com/dart-lang/sdk/issues/25322 | |
| 196 check("g4", _isFutureOfDynamic); | |
| 197 check("g5", _isFutureOfInt); | 189 check("g5", _isFutureOfInt); |
| 198 } | 190 } |
| 199 | 191 |
| 200 void test_async_star_method_propagation() { | 192 void test_async_star_method_propagation() { |
| 201 String code = r''' | 193 String code = r''' |
| 202 import "dart:async"; | 194 import "dart:async"; |
| 203 class A { | 195 class A { |
| 204 Stream g0() async* { yield []; } | 196 Stream g0() async* { yield []; } |
| 205 Stream g1() async* { yield* new Stream(); } | 197 Stream g1() async* { yield* new Stream(); } |
| 206 | 198 |
| (...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 main() { | 2300 main() { |
| 2309 var v = x; | 2301 var v = x; |
| 2310 v; // marker | 2302 v; // marker |
| 2311 } | 2303 } |
| 2312 int x = 3; | 2304 int x = 3; |
| 2313 '''; | 2305 '''; |
| 2314 assertPropagatedAssignedType(code, typeProvider.intType, null); | 2306 assertPropagatedAssignedType(code, typeProvider.intType, null); |
| 2315 assertTypeOfMarkedExpression(code, typeProvider.intType, null); | 2307 assertTypeOfMarkedExpression(code, typeProvider.intType, null); |
| 2316 } | 2308 } |
| 2317 } | 2309 } |
| OLD | NEW |