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

Unified Diff: pkg/front_end/testcases/inference/top_level_return_and_yield.dart

Issue 2899073004: Use declared return type for inference of return and yield statements. (Closed)
Patch Set: Simpler implementation 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/testcases/inference/top_level_return_and_yield.dart
diff --git a/pkg/front_end/testcases/inference/top_level_return_and_yield.dart b/pkg/front_end/testcases/inference/top_level_return_and_yield.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f285b6fb91144929df1d6dfa00edf93661b3e0cf
--- /dev/null
+++ b/pkg/front_end/testcases/inference/top_level_return_and_yield.dart
@@ -0,0 +1,40 @@
+// 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;
+
+import 'dart:async';
+
+typedef int IntToInt(int i);
+
+IntToInt a() {
+ return /*@returnType=int*/ (/*@type=int*/ x) => x;
+}
+
+Future<IntToInt> b() async {
+ // TODO(paulberry): this is broken due to bug 29689.
+ return /*@returnType=dynamic*/ (/*@type=dynamic*/ x) => x;
+}
+
+Iterable<IntToInt> c() sync* {
+ yield /*@returnType=int*/ (/*@type=int*/ x) => x;
+}
+
+Iterable<IntToInt> d() sync* {
+ yield* /*@typeArgs=(int) -> int*/ [
+ /*@returnType=int*/ (/*@type=int*/ x) => x
+ ];
+}
+
+Stream<IntToInt> e() async* {
+ yield /*@returnType=int*/ (/*@type=int*/ x) => x;
+}
+
+Stream<IntToInt> f() async* {
+ yield* new /*@typeArgs=(int) -> int*/ Stream.fromIterable(
+ /*@typeArgs=(int) -> int*/ [/*@returnType=int*/ (/*@type=int*/ x) => x]);
+}
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698