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 /// General type checking tests | 5 /// General type checking tests |
6 library dev_compiler.test.checker_test; | 6 library dev_compiler.test.checker_test; |
7 | 7 |
8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
9 | 9 |
10 import 'package:dev_compiler/src/testing.dart'; | 10 import 'package:dev_compiler/src/testing.dart'; |
(...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 | 2679 |
2680 foo1() async => x; | 2680 foo1() async => x; |
2681 Future foo2() async => x; | 2681 Future foo2() async => x; |
2682 Future<int> foo3() async => (/*info:DynamicCast*/x); | 2682 Future<int> foo3() async => (/*info:DynamicCast*/x); |
2683 Future<int> foo4() async => (/*severe:StaticTypeError*/new Future<int>(x
)); | 2683 Future<int> foo4() async => (/*severe:StaticTypeError*/new Future<int>(x
)); |
2684 | 2684 |
2685 bar1() async { return x; } | 2685 bar1() async { return x; } |
2686 Future bar2() async { return x; } | 2686 Future bar2() async { return x; } |
2687 Future<int> bar3() async { return (/*info:DynamicCast*/x); } | 2687 Future<int> bar3() async { return (/*info:DynamicCast*/x); } |
2688 Future<int> bar4() async { return (/*severe:StaticTypeError*/new Future<
int>(x)); } | 2688 Future<int> bar4() async { return (/*severe:StaticTypeError*/new Future<
int>(x)); } |
| 2689 |
| 2690 int y; |
| 2691 Future<int> z; |
| 2692 |
| 2693 void baz() async { |
| 2694 int a = /*info:DynamicCast*/await /*info:DynamicCast*/x; |
| 2695 int b = await /*severe:StaticTypeError*/y; |
| 2696 int c = await z; |
| 2697 String d = /*severe:StaticTypeError*/await z; |
| 2698 } |
2689 ''' | 2699 ''' |
2690 })); | 2700 })); |
2691 | 2701 |
2692 test('async*', () => testChecker({ | 2702 test('async*', () => testChecker({ |
2693 '/main.dart': ''' | 2703 '/main.dart': ''' |
2694 import 'dart:async'; | 2704 import 'dart:async'; |
2695 | 2705 |
2696 dynamic x; | 2706 dynamic x; |
2697 | 2707 |
2698 bar1() async* { yield x; } | 2708 bar1() async* { yield x; } |
(...skipping 22 matching lines...) Expand all Loading... |
2721 | 2731 |
2722 baz1() sync* { yield* (/*info:DynamicCast*/x); } | 2732 baz1() sync* { yield* (/*info:DynamicCast*/x); } |
2723 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } | 2733 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } |
2724 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } | 2734 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } |
2725 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2735 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
2726 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } | 2736 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } |
2727 ''' | 2737 ''' |
2728 })); | 2738 })); |
2729 }); | 2739 }); |
2730 } | 2740 } |
OLD | NEW |