Skip to content

Commit 04b35f7

Browse files
committed
Loosen return type guidelines for local functions
Local named functions do infer a return type in current Dart versions. In our recommendation to annotate the return type of functions change the set of functions the guideline applies to from "named" functions to "non-local" functions, anonymous function expressions are also local to a method body.
1 parent 49985b3 commit 04b35f7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/content/effective-dart/design.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1200,10 +1200,10 @@ makeGreeting(String who) {
12001200
}
12011201
```
12021202

1203-
Note that this guideline only applies to *named* function declarations:
1204-
top-level functions, methods, and local functions. Anonymous function
1205-
expressions infer a return type from their body. In fact, the syntax doesn't
1206-
even allow a return type annotation.
1203+
Note that this guideline only applies to *non-local* function declarations:
1204+
top-level functions, and methods. Local functions and anonymous function
1205+
expressions infer a return type from their body. In fact, the anonymous function
1206+
syntax doesn't even allow a return type annotation.
12071207

12081208

12091209
### DO annotate parameter types on function declarations

0 commit comments

Comments
 (0)