Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart

Issue 2875103002: Exclude function name from function type annotations in front end type inference tests. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 void main() { 8 void main() {
9 { 9 {
10 String f<S>(int x) => null; 10 String f<S>(int x) => null;
11 var /*@type=f(int) -> String*/ v = f; 11 var /*@type=(int) -> String*/ v = f;
12 v = /*@returnType=String*/ <T>(int x) => null; 12 v = /*@returnType=String*/ <T>(int x) => null;
13 v = /*@returnType=String*/ <T>(int x) => "hello"; 13 v = /*@returnType=String*/ <T>(int x) => "hello";
14 v = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ <T>(String x) => 14 v = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ <T>(String x) =>
15 "hello"; 15 "hello";
16 v = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ <T>(int x) => 3; 16 v = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ <T>(int x) => 3;
17 v = /*@returnType=String*/ <T>(int x) { 17 v = /*@returnType=String*/ <T>(int x) {
18 return /*error:RETURN_OF_INVALID_TYPE*/ 3; 18 return /*error:RETURN_OF_INVALID_TYPE*/ 3;
19 }; 19 };
20 } 20 }
21 { 21 {
22 String f<S>(int x) => null; 22 String f<S>(int x) => null;
23 var /*@type=f(int) -> String*/ v = f; 23 var /*@type=(int) -> String*/ v = f;
24 v = /*@returnType=String*/ <T>(/*@type=int*/ x) => null; 24 v = /*@returnType=String*/ <T>(/*@type=int*/ x) => null;
25 v = /*@returnType=String*/ <T>(/*@type=int*/ x) => "hello"; 25 v = /*@returnType=String*/ <T>(/*@type=int*/ x) => "hello";
26 v = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnType=i nt*/ < 26 v = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnType=i nt*/ <
27 T>(/*@type=int*/ x) => 27 T>(/*@type=int*/ x) =>
28 3; 28 3;
29 v = /*@returnType=String*/ <T>(/*@type=int*/ x) { 29 v = /*@returnType=String*/ <T>(/*@type=int*/ x) {
30 return /*error:RETURN_OF_INVALID_TYPE*/ 3; 30 return /*error:RETURN_OF_INVALID_TYPE*/ 3;
31 }; 31 };
32 v = /*@returnType=String*/ <T>(/*@type=int*/ x) { 32 v = /*@returnType=String*/ <T>(/*@type=int*/ x) {
33 return /*error:RETURN_OF_INVALID_TYPE*/ /*@promotedType=none*/ x; 33 return /*error:RETURN_OF_INVALID_TYPE*/ /*@promotedType=none*/ x;
34 }; 34 };
35 } 35 }
36 { 36 {
37 List<String> f<S>(int x) => null; 37 List<String> f<S>(int x) => null;
38 var /*@type=f(int) -> List<String>*/ v = f; 38 var /*@type=(int) -> List<String>*/ v = f;
39 v = /*@returnType=List<String>*/ <T>(int x) => null; 39 v = /*@returnType=List<String>*/ <T>(int x) => null;
40 v = /*@returnType=List<String>*/ <T>(int x) => /*@typeArgs=String*/ [ 40 v = /*@returnType=List<String>*/ <T>(int x) => /*@typeArgs=String*/ [
41 "hello" 41 "hello"
42 ]; 42 ];
43 v = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ < 43 v = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ <
44 T>(String x) => /*@typeArgs=String*/ ["hello"]; 44 T>(String x) => /*@typeArgs=String*/ ["hello"];
45 v = /*@returnType=List<String>*/ <T>(int x) => /*@typeArgs=String*/ [ 45 v = /*@returnType=List<String>*/ <T>(int x) => /*@typeArgs=String*/ [
46 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3 46 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
47 ]; 47 ];
48 v = /*@returnType=List<String>*/ <T>(int x) { 48 v = /*@returnType=List<String>*/ <T>(int x) {
49 return /*@typeArgs=String*/ [ 49 return /*@typeArgs=String*/ [
50 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3 50 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
51 ]; 51 ];
52 }; 52 };
53 } 53 }
54 { 54 {
55 int int2int<S>(int x) => null; 55 int int2int<S>(int x) => null;
56 String int2String<T>(int x) => null; 56 String int2String<T>(int x) => null;
57 String string2String<T>(String x) => null; 57 String string2String<T>(String x) => null;
58 var /*@type=int2int(int) -> int*/ x = int2int; 58 var /*@type=(int) -> int*/ x = int2int;
59 x = /*@returnType=int*/ <T>(/*@type=int*/ x) => /*@promotedType=none*/ x; 59 x = /*@returnType=int*/ <T>(/*@type=int*/ x) => /*@promotedType=none*/ x;
60 x = /*@returnType=int*/ < 60 x = /*@returnType=int*/ <
61 T>(/*@type=int*/ x) => /*@promotedType=none*/ x /*@target=num::+*/ + 1; 61 T>(/*@type=int*/ x) => /*@promotedType=none*/ x /*@target=num::+*/ + 1;
62 var /*@type=int2String(int) -> String*/ y = int2String; 62 var /*@type=(int) -> String*/ y = int2String;
63 y = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnType=i nt*/ < 63 y = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnType=i nt*/ <
64 T>(/*@type=int*/ x) => 64 T>(/*@type=int*/ x) =>
65 /*@promotedType=none*/ x; 65 /*@promotedType=none*/ x;
66 y = /*@returnType=String*/ < 66 y = /*@returnType=String*/ <
67 T>(/*@type=int*/ x) => /*info:DYNAMIC_INVOKE, info:DYNAMIC_CAST*/ /*@pro motedType=none*/ x.substring(3); 67 T>(/*@type=int*/ x) => /*info:DYNAMIC_INVOKE, info:DYNAMIC_CAST*/ /*@pro motedType=none*/ x.substring(3);
68 var /*@type=string2String(String) -> String*/ z = string2String; 68 var /*@type=(String) -> String*/ z = string2String;
69 z = /*@returnType=String*/ <T>(/*@type=String*/ x) => /*@promotedType=none*/ x 69 z = /*@returnType=String*/ <T>(/*@type=String*/ x) => /*@promotedType=none*/ x
70 . /*@target=String::substring*/ substring(3); 70 . /*@target=String::substring*/ substring(3);
71 } 71 }
72 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698