| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /*@testedFeatures=inference*/ | 5 /*@testedFeatures=inference*/ |
| 6 library test; | 6 library test; |
| 7 | 7 |
| 8 typedef T Function2<S, T>(S x); | 8 typedef T Function2<S, T>(S x); |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 null; | 25 null; |
| 26 Function2<int, String> l1 = /*@returnType=String*/ (/*@type=int*/ x) => | 26 Function2<int, String> l1 = /*@returnType=String*/ (/*@type=int*/ x) => |
| 27 "hello"; | 27 "hello"; |
| 28 Function2<int, String> | 28 Function2<int, String> |
| 29 l2 = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnT
ype=int*/ (/*@type=int*/ x) => | 29 l2 = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnT
ype=int*/ (/*@type=int*/ x) => |
| 30 3; | 30 3; |
| 31 Function2<int, String> l3 = /*@returnType=String*/ (/*@type=int*/ x) { | 31 Function2<int, String> l3 = /*@returnType=String*/ (/*@type=int*/ x) { |
| 32 return /*error:RETURN_OF_INVALID_TYPE*/ 3; | 32 return /*error:RETURN_OF_INVALID_TYPE*/ 3; |
| 33 }; | 33 }; |
| 34 Function2<int, String> l4 = /*@returnType=String*/ (/*@type=int*/ x) { | 34 Function2<int, String> l4 = /*@returnType=String*/ (/*@type=int*/ x) { |
| 35 return /*error:RETURN_OF_INVALID_TYPE*/ x; | 35 return /*error:RETURN_OF_INVALID_TYPE*/ /*@promotedType=none*/ x; |
| 36 }; | 36 }; |
| 37 } | 37 } |
| 38 { | 38 { |
| 39 Function2<int, List<String>> l0 = /*@returnType=List<String>*/ (int x) => | 39 Function2<int, List<String>> l0 = /*@returnType=List<String>*/ (int x) => |
| 40 null; | 40 null; |
| 41 Function2<int, List<String>> l1 = /*@returnType=List<String>*/ (int | 41 Function2<int, List<String>> l1 = /*@returnType=List<String>*/ (int |
| 42 x) => /*@typeArgs=String*/ ["hello"]; | 42 x) => /*@typeArgs=String*/ ["hello"]; |
| 43 Function2<int, List<String>> | 43 Function2<int, List<String>> |
| 44 l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ (String | 44 l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ (String |
| 45 x) => /*@typeArgs=String*/ ["hello"]; | 45 x) => /*@typeArgs=String*/ ["hello"]; |
| 46 Function2<int, List<String>> | 46 Function2<int, List<String>> |
| 47 l3 = /*@returnType=List<String>*/ (int x) => /*@typeArgs=String*/ [ | 47 l3 = /*@returnType=List<String>*/ (int x) => /*@typeArgs=String*/ [ |
| 48 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3 | 48 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3 |
| 49 ]; | 49 ]; |
| 50 Function2<int, List<String>> l4 = /*@returnType=List<String>*/ (int x) { | 50 Function2<int, List<String>> l4 = /*@returnType=List<String>*/ (int x) { |
| 51 return /*@typeArgs=String*/ [ | 51 return /*@typeArgs=String*/ [ |
| 52 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3 | 52 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3 |
| 53 ]; | 53 ]; |
| 54 }; | 54 }; |
| 55 } | 55 } |
| 56 { | 56 { |
| 57 Function2<int, int> l0 = /*@returnType=int*/ (/*@type=int*/ x) => x; | 57 Function2<int, int> |
| 58 Function2<int, int> l1 = /*@returnType=int*/ (/*@type=int*/ x) => x + 1; | 58 l0 = /*@returnType=int*/ (/*@type=int*/ x) => /*@promotedType=none*/ x; |
| 59 Function2<int, int> |
| 60 l1 = /*@returnType=int*/ (/*@type=int*/ x) => /*@promotedType=none*/ x + |
| 61 1; |
| 59 Function2<int, String> | 62 Function2<int, String> |
| 60 l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ (/*@type=int*/ x)
=> | 63 l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ (/*@type=int*/ x)
=> |
| 61 x; | 64 /*@promotedType=none*/ x; |
| 62 Function2<int, String> | 65 Function2<int, String> |
| 63 l3 = /*@returnType=String*/ (/*@type=int*/ x) => /*info:DYNAMIC_CAST, in
fo:DYNAMIC_INVOKE*/ x | 66 l3 = /*@returnType=String*/ (/*@type=int*/ x) => /*info:DYNAMIC_CAST, in
fo:DYNAMIC_INVOKE*/ /*@promotedType=none*/ x |
| 64 .substring(3); | 67 .substring(3); |
| 65 Function2<String, String> | 68 Function2<String, String> |
| 66 l4 = /*@returnType=String*/ (/*@type=String*/ x) => x.substring(3); | 69 l4 = /*@returnType=String*/ (/*@type=String*/ x) => /*@promotedType=none
*/ x |
| 70 .substring(3); |
| 67 } | 71 } |
| 68 } | 72 } |
| OLD | NEW |