You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adjust function literal return type inference to avoid spurious null (#4210)
This PR changes one item in the list of actions taken during function literal return type inference: A `return;` statement only adds `Null` to the return type in cases where the given function literal is a non-generator.
Before this change, `Null` was added to the return type also in cases like `() sync* { yield 1; return; }` such that this function literal gets the inferred return type `Iterable<int?>`. This is an unnecessary loss of typing precision because null is never actually added to the returned iterable. With this update, the inferred return type is `Iterable<int>`.
See dart-lang/sdk#59669 for some background discussion.
0 commit comments