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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
7 /// General type checking tests | 7 /// General type checking tests |
8 library test.src.task.strong.checker_test; | 8 library test.src.task.strong.checker_test; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 }); | 269 }); |
270 | 270 |
271 testChecker('Unbound type name', { | 271 testChecker('Unbound type name', { |
272 '/main.dart': ''' | 272 '/main.dart': ''' |
273 void main() { | 273 void main() { |
274 /*pass should be severe:StaticTypeError*/AToB y; | 274 /*pass should be severe:StaticTypeError*/AToB y; |
275 } | 275 } |
276 ''' | 276 ''' |
277 }); | 277 }); |
278 | 278 |
| 279 // Regression test for https://github.com/dart-lang/sdk/issues/25069 |
| 280 testChecker('Void subtyping', { |
| 281 '/main.dart': ''' |
| 282 typedef int Foo(); |
| 283 void foo() {} |
| 284 void main () { |
| 285 Foo x = /*severe:StaticTypeError*/foo(); |
| 286 } |
| 287 ''' |
| 288 }); |
| 289 |
279 testChecker('Ground type subtyping: dynamic is top', { | 290 testChecker('Ground type subtyping: dynamic is top', { |
280 '/main.dart': ''' | 291 '/main.dart': ''' |
281 | 292 |
282 class A {} | 293 class A {} |
283 class B extends A {} | 294 class B extends A {} |
284 | 295 |
285 void main() { | 296 void main() { |
286 dynamic y; | 297 dynamic y; |
287 Object o; | 298 Object o; |
288 int i = 0; | 299 int i = 0; |
(...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 | 2415 |
2405 baz1() sync* { yield* (/*info:DynamicCast*/x); } | 2416 baz1() sync* { yield* (/*info:DynamicCast*/x); } |
2406 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } | 2417 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } |
2407 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } | 2418 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } |
2408 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2419 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
2409 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } | 2420 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } |
2410 ''' | 2421 ''' |
2411 }); | 2422 }); |
2412 }); | 2423 }); |
2413 } | 2424 } |
OLD | NEW |