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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart
diff --git a/pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart b/pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart
new file mode 100644
index 0000000000000000000000000000000000000000..04a20f2afd3aaabf164212510254394d8100251d
--- /dev/null
+++ b/pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/*@testedFeatures=inference*/
+library test;
+
+typedef T Function2<S, T>(S x);
+
+void main() {
+ {
+ Function2<int, String> l0 = /*@returnType=String*/ (int x) => null;
+ Function2<int, String> l1 = /*@returnType=String*/ (int x) => "hello";
+ Function2<int, String>
+ l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ (String x) =>
+ "hello";
+ Function2<int, String>
+ l3 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ (int x) => 3;
+ Function2<int, String> l4 = /*@returnType=String*/ (int x) {
+ return /*error:RETURN_OF_INVALID_TYPE*/ 3;
+ };
+ }
+ {
+ Function2<int, String> l0 = /*@returnType=String*/ (/*@type=int*/ x) =>
+ null;
+ Function2<int, String> l1 = /*@returnType=String*/ (/*@type=int*/ x) =>
+ "hello";
+ Function2<int, String>
+ l2 = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ (/*@type=int*/ x) =>
+ 3;
+ Function2<int, String> l3 = /*@returnType=String*/ (/*@type=int*/ x) {
+ return /*error:RETURN_OF_INVALID_TYPE*/ 3;
+ };
+ Function2<int, String> l4 = /*@returnType=String*/ (/*@type=int*/ x) {
+ return /*error:RETURN_OF_INVALID_TYPE*/ x;
+ };
+ }
+ {
+ Function2<int, List<String>> l0 = /*@returnType=List<String>*/ (int x) =>
+ null;
+ Function2<int, List<String>> l1 = /*@returnType=List<String>*/ (int
+ x) => /*@typeArgs=String*/ ["hello"];
+ Function2<int, List<String>>
+ l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ (String
+ x) => /*@typeArgs=String*/ ["hello"];
+ Function2<int, List<String>>
+ l3 = /*@returnType=List<String>*/ (int x) => /*@typeArgs=String*/ [
+ /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
+ ];
+ Function2<int, List<String>> l4 = /*@returnType=List<String>*/ (int x) {
+ return /*@typeArgs=String*/ [
+ /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
+ ];
+ };
+ }
+ {
+ Function2<int, int> l0 = /*@returnType=int*/ (/*@type=int*/ x) => x;
+ Function2<int, int> l1 = /*@returnType=int*/ (/*@type=int*/ x) => x + 1;
+ Function2<int, String>
+ l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=int*/ (/*@type=int*/ x) =>
+ x;
+ Function2<int, String>
+ l3 = /*@returnType=String*/ (/*@type=int*/ x) => /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/ x
+ .substring(3);
+ Function2<String, String>
+ l4 = /*@returnType=String*/ (/*@type=String*/ x) => x.substring(3);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698