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 analyzer.test.src.task.strong.checker_test; | 8 library analyzer.test.src.task.strong.checker_test; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 testChecker('Function typing and subtyping: void', { | 957 testChecker('Function typing and subtyping: void', { |
958 '/main.dart': ''' | 958 '/main.dart': ''' |
959 | 959 |
960 class A { | 960 class A { |
961 void bar() => null; | 961 void bar() => null; |
962 void foo() => bar; // allowed | 962 void foo() => bar; // allowed |
963 } | 963 } |
964 ''' | 964 ''' |
965 }); | 965 }); |
966 | 966 |
| 967 testChecker('Function subtyping: uninferred closure', { |
| 968 '/main.dart': ''' |
| 969 typedef num Num2Num(num x); |
| 970 void main() { |
| 971 Num2Num g = /*info:INFERRED_TYPE_CLOSURE,severe:STATIC_TYPE_ERROR*/(int
x) { return x; }; |
| 972 print(g(42)); |
| 973 } |
| 974 ''' |
| 975 }); |
| 976 |
967 testChecker('Relaxed casts', { | 977 testChecker('Relaxed casts', { |
968 '/main.dart': ''' | 978 '/main.dart': ''' |
969 | 979 |
970 class A {} | 980 class A {} |
971 | 981 |
972 class L<T> {} | 982 class L<T> {} |
973 class M<T> extends L<T> {} | 983 class M<T> extends L<T> {} |
974 // L<dynamic|Object> | 984 // L<dynamic|Object> |
975 // / \ | 985 // / \ |
976 // M<dynamic|Object> L<A> | 986 // M<dynamic|Object> L<A> |
(...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2552 | 2562 |
2553 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2563 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
2554 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2564 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
2555 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} | 2565 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} |
2556 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2566 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
2557 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } | 2567 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } |
2558 ''' | 2568 ''' |
2559 }); | 2569 }); |
2560 }); | 2570 }); |
2561 } | 2571 } |
OLD | NEW |