| 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 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 num n = 3; | 1679 num n = 3; |
| 1680 int i = 3; | 1680 int i = 3; |
| 1681 String s = "hello"; | 1681 String s = "hello"; |
| 1682 { | 1682 { |
| 1683 List<int> l = <int>[i]; | 1683 List<int> l = <int>[i]; |
| 1684 l = <int>[/*warning:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/s]; | 1684 l = <int>[/*warning:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/s]; |
| 1685 l = <int>[/*info:DOWN_CAST_IMPLICIT*/n]; | 1685 l = <int>[/*info:DOWN_CAST_IMPLICIT*/n]; |
| 1686 l = <int>[i, /*info:DOWN_CAST_IMPLICIT*/n, /*warning:LIST_ELEMENT
_TYPE_NOT_ASSIGNABLE*/s]; | 1686 l = <int>[i, /*info:DOWN_CAST_IMPLICIT*/n, /*warning:LIST_ELEMENT
_TYPE_NOT_ASSIGNABLE*/s]; |
| 1687 } | 1687 } |
| 1688 { | 1688 { |
| 1689 List l = [i]; | 1689 List l = /*info:INFERRED_TYPE_LITERAL*/[i]; |
| 1690 l = [s]; | 1690 l = /*info:INFERRED_TYPE_LITERAL*/[s]; |
| 1691 l = [n]; | 1691 l = /*info:INFERRED_TYPE_LITERAL*/[n]; |
| 1692 l = [i, n, s]; | 1692 l = /*info:INFERRED_TYPE_LITERAL*/[i, n, s]; |
| 1693 } | 1693 } |
| 1694 { | 1694 { |
| 1695 Map<String, int> m = <String, int>{s: i}; | 1695 Map<String, int> m = <String, int>{s: i}; |
| 1696 m = <String, int>{s: /*warning:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s}; | 1696 m = <String, int>{s: /*warning:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s}; |
| 1697 m = <String, int>{s: /*info:DOWN_CAST_IMPLICIT*/n}; | 1697 m = <String, int>{s: /*info:DOWN_CAST_IMPLICIT*/n}; |
| 1698 m = <String, int>{s: i, | 1698 m = <String, int>{s: i, |
| 1699 s: /*info:DOWN_CAST_IMPLICIT*/n, | 1699 s: /*info:DOWN_CAST_IMPLICIT*/n, |
| 1700 s: /*warning:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s}; | 1700 s: /*warning:MAP_VALUE_TYPE_NOT_ASSIGNABLE*/s}; |
| 1701 } | 1701 } |
| 1702 // TODO(leafp): We can't currently test for key errors since the | 1702 // TODO(leafp): We can't currently test for key errors since the |
| 1703 // error marker binds to the entire entry. | 1703 // error marker binds to the entire entry. |
| 1704 { | 1704 { |
| 1705 Map m = {s: i}; | 1705 Map m = /*info:INFERRED_TYPE_LITERAL*/{s: i}; |
| 1706 m = {s: s}; | 1706 m = /*info:INFERRED_TYPE_LITERAL*/{s: s}; |
| 1707 m = {s: n}; | 1707 m = /*info:INFERRED_TYPE_LITERAL*/{s: n}; |
| 1708 m = {s: i, | 1708 m = /*info:INFERRED_TYPE_LITERAL*/ |
| 1709 {s: i, |
| 1709 s: n, | 1710 s: n, |
| 1710 s: s}; | 1711 s: s}; |
| 1711 m = {i: s, | 1712 m = /*info:INFERRED_TYPE_LITERAL*/ |
| 1713 {i: s, |
| 1712 n: s, | 1714 n: s, |
| 1713 s: s}; | 1715 s: s}; |
| 1714 } | 1716 } |
| 1715 } | 1717 } |
| 1716 '''); | 1718 '''); |
| 1717 }); | 1719 }); |
| 1718 | 1720 |
| 1719 test('casts in constant contexts', () { | 1721 test('casts in constant contexts', () { |
| 1720 checkFile(''' | 1722 checkFile(''' |
| 1721 class A { | 1723 class A { |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3215 | 3217 |
| 3216 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } | 3218 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } |
| 3217 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } | 3219 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } |
| 3218 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } | 3220 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } |
| 3219 Iterable<int> baz4() sync* { yield* bar3(); } | 3221 Iterable<int> baz4() sync* { yield* bar3(); } |
| 3220 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new
List(); } | 3222 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new
List(); } |
| 3221 '''); | 3223 '''); |
| 3222 }); | 3224 }); |
| 3223 }); | 3225 }); |
| 3224 } | 3226 } |
| OLD | NEW |