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

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

Issue 2846103002: Generated front_end/testcases/inference test files from Analyzer 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /*@testedFeatures=inference*/
6 library test;
7
8 typedef T Function2<S, T>(S x);
9
10 void main() {
11 {
12 Function2<int, String> l0 = /*@returnType=String*/ (int x) => null;
13 Function2<int, String> l1 = /*@returnType=String*/ (int x) => "hello";
14 Function2<int, String>
15 l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ (String x) =>
16 "hello";
17 Function2<int, String>
18 l3 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ (int x) => 3;
19 Function2<int, String> l4 = /*@returnType=String*/ (int x) {
20 return /*error:RETURN_OF_INVALID_TYPE*/ 3;
21 };
22 }
23 {
24 Function2<int, String> l0 = /*@returnType=String*/ (/*@type=int*/ x) =>
25 null;
26 Function2<int, String> l1 = /*@returnType=String*/ (/*@type=int*/ x) =>
27 "hello";
28 Function2<int, String>
29 l2 = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnT ype=int*/ (/*@type=int*/ x) =>
30 3;
31 Function2<int, String> l3 = /*@returnType=String*/ (/*@type=int*/ x) {
32 return /*error:RETURN_OF_INVALID_TYPE*/ 3;
33 };
34 Function2<int, String> l4 = /*@returnType=String*/ (/*@type=int*/ x) {
35 return /*error:RETURN_OF_INVALID_TYPE*/ x;
36 };
37 }
38 {
39 Function2<int, List<String>> l0 = /*@returnType=List<String>*/ (int x) =>
40 null;
41 Function2<int, List<String>> l1 = /*@returnType=List<String>*/ (int
42 x) => /*@typeArgs=String*/ ["hello"];
43 Function2<int, List<String>>
44 l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ (String
45 x) => /*@typeArgs=String*/ ["hello"];
46 Function2<int, List<String>>
47 l3 = /*@returnType=List<String>*/ (int x) => /*@typeArgs=String*/ [
48 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
49 ];
50 Function2<int, List<String>> l4 = /*@returnType=List<String>*/ (int x) {
51 return /*@typeArgs=String*/ [
52 /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
53 ];
54 };
55 }
56 {
57 Function2<int, int> l0 = /*@returnType=int*/ (/*@type=int*/ x) => x;
58 Function2<int, int> l1 = /*@returnType=int*/ (/*@type=int*/ x) => x + 1;
59 Function2<int, String>
60 l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ (/*@type=int*/ x) =>
61 x;
62 Function2<int, String>
63 l3 = /*@returnType=String*/ (/*@type=int*/ x) => /*info:DYNAMIC_CAST, in fo:DYNAMIC_INVOKE*/ x
64 .substring(3);
65 Function2<String, String>
66 l4 = /*@returnType=String*/ (/*@type=String*/ x) => x.substring(3);
67 }
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698