| 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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 } | 829 } |
| 830 } | 830 } |
| 831 ''' | 831 ''' |
| 832 }); | 832 }); |
| 833 }); | 833 }); |
| 834 | 834 |
| 835 test('Function typing and subtyping: higher order function variables', () { | 835 test('Function typing and subtyping: higher order function variables', () { |
| 836 testChecker({ | 836 testChecker({ |
| 837 '/main.dart': ''' | 837 '/main.dart': ''' |
| 838 | 838 |
| 839 class A {} | 839 class A {} |
| 840 class B extends A {} | 840 class B extends A {} |
| 841 | 841 |
| 842 typedef T Function2<S, T>(S z); | 842 typedef T Function2<S, T>(S z); |
| 843 | 843 |
| 844 void main() { | 844 void main() { |
| 845 { | 845 { |
| 846 Function2<Function2<A, B>, Function2<B, A>> top; | 846 Function2<Function2<A, B>, Function2<B, A>> top; |
| 847 Function2<Function2<B, A>, Function2<B, A>> right; | 847 Function2<Function2<B, A>, Function2<B, A>> right; |
| 848 Function2<Function2<A, B>, Function2<A, B>> left; | 848 Function2<Function2<A, B>, Function2<A, B>> left; |
| 849 Function2<Function2<B, A>, Function2<A, B>> bot; | 849 Function2<Function2<B, A>, Function2<A, B>> bot; |
| 850 | 850 |
| 851 top = right; | 851 top = right; |
| 852 top = bot; | 852 top = bot; |
| 853 top = top; | 853 top = top; |
| 854 top = left; | 854 top = left; |
| 855 | 855 |
| 856 left = /*pass should be warning:DownCastComposite*/top; | 856 left = /*warning:DownCastComposite*/top; |
| 857 left = left; | 857 left = left; |
| 858 left = /*pass should be severe:StaticTypeError*/right; | 858 left = |
| 859 left = bot; | 859 /*warning:DownCastComposite should be severe:StaticTypeError*/right; |
| 860 left = bot; |
| 860 | 861 |
| 861 right = /*pass should be warning:DownCastComposite*/top; | 862 right = /*warning:DownCastComposite*/top; |
| 862 right = /*pass should be severe:StaticTypeError*/left; | 863 right = |
| 863 right = right; | 864 /*warning:DownCastComposite should be severe:StaticTypeError*/left; |
| 864 right = bot; | 865 right = right; |
| 866 right = bot; |
| 865 | 867 |
| 866 bot = /*pass should be warning:DownCastComposite*/top; | 868 bot = /*warning:DownCastComposite*/top; |
| 867 bot = /*pass should be warning:DownCastComposite*/left; | 869 bot = /*warning:DownCastComposite*/left; |
| 868 bot = /*pass should be warning:DownCastComposite*/right; | 870 bot = /*warning:DownCastComposite*/right; |
| 869 bot = bot; | 871 bot = bot; |
| 870 } | |
| 871 } | 872 } |
| 873 } |
| 872 ''' | 874 ''' |
| 873 }); | 875 }); |
| 874 }); | 876 }); |
| 875 | 877 |
| 876 test('Function typing and subtyping: named and optional parameters', () { | 878 test('Function typing and subtyping: named and optional parameters', () { |
| 877 testChecker({ | 879 testChecker({ |
| 878 '/main.dart': ''' | 880 '/main.dart': ''' |
| 879 | 881 |
| 880 class A {} | 882 class A {} |
| 881 | 883 |
| (...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 | 2733 |
| 2732 baz1() sync* { yield* (/*info:DynamicCast*/x); } | 2734 baz1() sync* { yield* (/*info:DynamicCast*/x); } |
| 2733 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } | 2735 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } |
| 2734 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } | 2736 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } |
| 2735 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2737 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
| 2736 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } | 2738 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } |
| 2737 ''' | 2739 ''' |
| 2738 })); | 2740 })); |
| 2739 }); | 2741 }); |
| 2740 } | 2742 } |
| OLD | NEW |