| 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 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 /*=T*/ foo/*<T>*/(/*=T*/ x, /*=T*/ y) => x; | 1731 /*=T*/ foo/*<T>*/(/*=T*/ x, /*=T*/ y) => x; |
| 1732 /*=T*/ bar/*<T>*/({/*=T*/ x, /*=T*/ y}) => x; | 1732 /*=T*/ bar/*<T>*/({/*=T*/ x, /*=T*/ y}) => x; |
| 1733 | 1733 |
| 1734 main() { | 1734 main() { |
| 1735 String x; | 1735 String x; |
| 1736 // resolving these shouldn't crash. | 1736 // resolving these shouldn't crash. |
| 1737 foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/(1, 2, 3); | 1737 foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/(1, 2, 3); |
| 1738 x = foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/('1', '2', '3'); | 1738 x = foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/('1', '2', '3'); |
| 1739 foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*/(1); | 1739 foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*/(1); |
| 1740 x = foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*/('1'); | 1740 x = foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*/('1'); |
| 1741 x = /*severe:STATIC_TYPE_ERROR*/foo/*warning:EXTRA_POSITIONAL_ARGUME
NTS*/(1, 2, 3); | 1741 x = /*info:DYNAMIC_CAST*/foo/*warning:EXTRA_POSITIONAL_ARGUMENTS*/(1
, 2, 3); |
| 1742 x = /*severe:STATIC_TYPE_ERROR*/foo/*warning:NOT_ENOUGH_REQUIRED_ARG
UMENTS*/(1); | 1742 x = /*info:DYNAMIC_CAST*/foo/*warning:NOT_ENOUGH_REQUIRED_ARGUMENTS*
/(1); |
| 1743 | 1743 |
| 1744 // named arguments | 1744 // named arguments |
| 1745 bar(y: 1, x: 2, /*warning:UNDEFINED_NAMED_PARAMETER*/z: 3); | 1745 bar(y: 1, x: 2, /*warning:UNDEFINED_NAMED_PARAMETER*/z: 3); |
| 1746 x = bar(/*warning:UNDEFINED_NAMED_PARAMETER*/z: '1', x: '2', y: '3')
; | 1746 x = bar(/*warning:UNDEFINED_NAMED_PARAMETER*/z: '1', x: '2', y: '3')
; |
| 1747 bar(y: 1); | 1747 bar(y: 1); |
| 1748 x = bar(x: '1', /*warning:UNDEFINED_NAMED_PARAMETER*/z: 42); | 1748 x = bar(x: '1', /*warning:UNDEFINED_NAMED_PARAMETER*/z: 42); |
| 1749 x = /*severe:STATIC_TYPE_ERROR*/bar(y: 1, x: 2, /*warning:UNDEFINED_
NAMED_PARAMETER*/z: 3); | 1749 x = /*info:DYNAMIC_CAST*/bar(y: 1, x: 2, /*warning:UNDEFINED_NAMED_P
ARAMETER*/z: 3); |
| 1750 x = /*severe:STATIC_TYPE_ERROR*/bar(x: 1); | 1750 x = /*info:DYNAMIC_CAST*/bar(x: 1); |
| 1751 } | 1751 } |
| 1752 '''); | 1752 '''); |
| 1753 }); | 1753 }); |
| 1754 | 1754 |
| 1755 test('type promotion from dynamic', () { | 1755 test('type promotion from dynamic', () { |
| 1756 checkFile(r''' | 1756 checkFile(r''' |
| 1757 f() { | 1757 f() { |
| 1758 dynamic x; | 1758 dynamic x; |
| 1759 if (x is int) { | 1759 if (x is int) { |
| 1760 int y = x; | 1760 int y = x; |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 | 2873 |
| 2874 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2874 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2875 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2875 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2876 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} | 2876 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} |
| 2877 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2877 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
| 2878 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } | 2878 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } |
| 2879 '''); | 2879 '''); |
| 2880 }); | 2880 }); |
| 2881 }); | 2881 }); |
| 2882 } | 2882 } |
| OLD | NEW |