Chromium Code Reviews| 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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1486 Function2<int, String> l4 = /*warning:InferableClosure should be sever e:StaticTypeError*/(int x) {return 3}; | 1486 Function2<int, String> l4 = /*warning:InferableClosure should be sever e:StaticTypeError*/(int x) {return 3}; |
| 1487 } | 1487 } |
| 1488 { | 1488 { |
| 1489 Function2<int, String> l0 = /*info:InferredTypeClosure*/(x) => null; | 1489 Function2<int, String> l0 = /*info:InferredTypeClosure*/(x) => null; |
| 1490 Function2<int, String> l1 = /*info:InferredTypeClosure*/(x) => "hello" ; | 1490 Function2<int, String> l1 = /*info:InferredTypeClosure*/(x) => "hello" ; |
| 1491 Function2<int, String> l2 = /*severe:StaticTypeError*/(x) => 3; | 1491 Function2<int, String> l2 = /*severe:StaticTypeError*/(x) => 3; |
| 1492 Function2<int, String> l3 = /*warning:InferableClosure should be sever e:StaticTypeError*/(x) {return 3}; | 1492 Function2<int, String> l3 = /*warning:InferableClosure should be sever e:StaticTypeError*/(x) {return 3}; |
| 1493 } | 1493 } |
| 1494 { | 1494 { |
| 1495 Function2<int, List<String>> l0 = (int x) => null; | 1495 Function2<int, List<String>> l0 = (int x) => null; |
| 1496 Function2<int, List<String>> l1 = /*info:InferredTypeClosure*/(int x) => /*info:InferredTypeLiteral*/["hello"]; | 1496 Function2<int, List<String>> l1 = /*info:InferredTypeClosure*/(int x) => ["hello"]; |
| 1497 Function2<int, List<String>> l2 = /*severe:StaticTypeError*/(String x) => ["hello"]; | 1497 Function2<int, List<String>> l2 = /*severe:StaticTypeError*/(String x) => ["hello"]; |
| 1498 Function2<int, List<String>> l3 = /*warning:InferableClosure should be severe:StaticTypeError*/(int x) => [3]; | 1498 Function2<int, List<String>> l3 = /*warning:InferableClosure should be severe:StaticTypeError*/(int x) => [3]; |
| 1499 Function2<int, List<String>> l4 = /*warning:InferableClosure should be severe:StaticTypeError*/(int x) {return [3]}; | 1499 Function2<int, List<String>> l4 = /*warning:InferableClosure should be severe:StaticTypeError*/(int x) {return [3]}; |
| 1500 } | 1500 } |
| 1501 { | 1501 { |
| 1502 Function2<int, int> l0 = /*warning:InferableClosure should be info:Inf erredTypeClosure*/(x) => x; | 1502 Function2<int, int> l0 = /*info:InferredTypeClosure*/(x) => x; |
| 1503 Function2<int, int> l1 = /*warning:InferableClosure should be info:Inf erredTypeClosure*/(x) => x+1; | 1503 Function2<int, int> l1 = /*info:InferredTypeClosure*/(x) => x+1; |
|
Leaf
2015/04/03 22:23:23
This now succeeds, though arguably for the wrong r
| |
| 1504 Function2<int, String> l2 = /*warning:InferableClosure should be sever e:StaticTypeError*/(x) => x; | 1504 Function2<int, String> l2 = /*info:InferredTypeClosure should be sever e:StaticTypeError*/(x) => x; |
|
Leaf
2015/04/03 22:23:23
This is an example of a case where allowing casts
| |
| 1505 Function2<int, String> l3 = /*warning:InferableClosure should be sever e:StaticTypeError*/(x) => /*warning:DynamicInvoke should be pass*/x.substring(3) ; | 1505 Function2<int, String> l3 = /*info:InferredTypeClosure should be sever e:StaticTypeError*/(x) => /*warning:DynamicInvoke should be pass*/x.substring(3) ; |
| 1506 Function2<String, String> l4 = /*info:InferredTypeClosure*/(x) => /*wa rning:DynamicInvoke should be pass*/x.substring(3); | |
| 1506 } | 1507 } |
| 1507 } | 1508 } |
| 1508 ''' | 1509 ''' |
| 1509 }, inferDownwards: true, wrapClosures: false); | 1510 }, inferDownwards: true, wrapClosures: false); |
| 1510 }); | 1511 }); |
| 1511 } | 1512 } |
| OLD | NEW |