Chromium Code Reviews

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.dart

Issue 1724543002: fix #25487, infer block lambdas from return statements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: pkg/analyzer/test/src/task/strong/inferred_type_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 85a1085bef0fc6b253a86b6854b5c9315a60e496..f63285281e4ceb9e4a561b26a20c01de046f0d7d 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -1919,4 +1919,29 @@ test2() {
}
''');
});
+
+
+ test('block bodied lambdas', () {
+ // Regression test for https://github.com/dart-lang/sdk/issues/25487
+ checkFile(r'''
+import 'dart:math' show Random;
+test1() {
+ List<int> o;
+ var y = o.map(/*info:INFERRED_TYPE_CLOSURE,info:INFERRED_TYPE_CLOSURE*/(x) { return x + 1; });
+ Iterable<int> z = y;
+}
+test2() {
+ List<num> o;
+ var y = o.map(/*info:INFERRED_TYPE_CLOSURE,info:INFERRED_TYPE_CLOSURE*/(x) {
+ if (new Random().nextBool()) {
+ return x.toInt() + 1;
+ } else {
+ return x.toDouble();
+ }
+ });
+ Iterable<num> w = y;
+ Iterable<int> z = /*info:ASSIGNMENT_CAST*/y;
+}
Leaf 2016/02/23 02:17:47 I'd like to be sure we cover this pretty well. Ca
Jennifer Messerly 2016/02/23 17:41:46 Excellent list. Yeah I can do that.
Jennifer Messerly 2016/02/24 00:20:41 Done.
+ ''');
+ });
}

Powered by Google App Engine