| 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 /// Tests for type inference. | 5 /// Tests for type inference. |
| 6 library dev_compiler.test.inferred_type_test; | 6 library dev_compiler.test.inferred_type_test; |
| 7 | 7 |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import 'package:dev_compiler/src/testing.dart'; | 10 import 'package:dev_compiler/src/testing.dart'; |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 } | 616 } |
| 617 | 617 |
| 618 var map = <String, Foo>{}; | 618 var map = <String, Foo>{}; |
| 619 // Error: map must be an Iterable. | 619 // Error: map must be an Iterable. |
| 620 for (var x in /*severe:StaticTypeError*/map) { | 620 for (var x in /*severe:StaticTypeError*/map) { |
| 621 String y = /*info:DynamicCast*/x; | 621 String y = /*info:DynamicCast*/x; |
| 622 } | 622 } |
| 623 | 623 |
| 624 // We're not properly inferring that map.keys is an Iterable<String> | 624 // We're not properly inferring that map.keys is an Iterable<String> |
| 625 // and that x is a String. | 625 // and that x is a String. |
| 626 for (var x in /*info:DynamicCast should be pass*/map.keys) { | 626 for (var x in map.keys) { |
| 627 String y = /*info:DynamicCast should be pass*/x; | 627 String y = x; |
| 628 } | 628 } |
| 629 } | 629 } |
| 630 ''' | 630 ''' |
| 631 }); | 631 }); |
| 632 | 632 |
| 633 // for loop, with inference | 633 // for loop, with inference |
| 634 testChecker({ | 634 testChecker({ |
| 635 '/main.dart': ''' | 635 '/main.dart': ''' |
| 636 test() { | 636 test() { |
| 637 for (var i = 0; i < 10; i++) { | 637 for (var i = 0; i < 10; i++) { |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 static final T foo = m1(m2(m3('', ''))); | 1208 static final T foo = m1(m2(m3('', ''))); |
| 1209 static T m1(String m) { return null; } | 1209 static T m1(String m) { return null; } |
| 1210 static String m2(e) { return ''; } | 1210 static String m2(e) { return ''; } |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 | 1213 |
| 1214 ''' | 1214 ''' |
| 1215 }, inferFromOverrides: true, inferTransitively: true); | 1215 }, inferFromOverrides: true, inferTransitively: true); |
| 1216 }); | 1216 }); |
| 1217 } | 1217 } |
| OLD | NEW |