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

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

Issue 2209293002: fix #26414, infer return types of local functions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: mark failing ast inference Created 4 years, 4 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
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_ast_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e17448aaadf72e35cded2f56eb7584d5005ea35d..4dbcbfeba20c30dcb2d97385dd462a4b812bbbf9 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -2518,6 +2518,42 @@ main() {
''');
}
+ void test_inferLocalFunctionReturnType() {
+ // Regression test for https://github.com/dart-lang/sdk/issues/26414
+ var unit = checkFile(r'''
+main() {
+ f0() => 42;
+ f1() async => 42;
+
+ f2 /*info:INFERRED_TYPE_CLOSURE*/() { return 42; }
+ f3 /*info:INFERRED_TYPE_CLOSURE*/() async { return 42; }
+ f4 /*info:INFERRED_TYPE_CLOSURE*/() sync* { yield 42; }
+ f5 /*info:INFERRED_TYPE_CLOSURE*/() async* { yield 42; }
+
+ num f6() => 42;
+
+ f7() => f7();
+ f8() => /*error:REFERENCED_BEFORE_DECLARATION*/f9();
+ f9() => f5();
+}
+''');
+ var fns = unit.functions[0].functions;
+ expect(fns[0].type.toString(), '() → int');
+ expect(fns[1].type.toString(), '() → Future<int>');
+
+ expect(fns[2].type.toString(), '() → int');
+ expect(fns[3].type.toString(), '() → Future<int>');
+ expect(fns[4].type.toString(), '() → Iterable<int>');
+ expect(fns[5].type.toString(), '() → Stream<int>');
+
+ expect(fns[6].type.toString(), '() → num');
+
+ // Recursive cases: these infer in declaration order.
+ expect(fns[7].type.toString(), '() → dynamic');
+ expect(fns[8].type.toString(), '() → dynamic');
+ expect(fns[9].type.toString(), '() → Stream<int>');
+ }
+
void test_inferred_nonstatic_field_depends_on_static_field_complex() {
var mainUnit = checkFile('''
class C {
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_ast_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698