Implement the feature spec for checking returns against inferred
function return types:
https://github.com/dart-lang/sdk/blob/master/docs/language/informal/invalid_returns.md
with the change that an invalid return without a subexpression is
a warning, not an error. This is because it is a warning in the
analyzer and it would be a breaking change to turn it into an
error.
The check for valid returns is moved to exactly where we handle
returns, rather than in ensureAssignable which is used as a
helper in a lot of places. A bug in type inference was fixed: we
would use `void` for the type of return without a subexpression
instead of `null`. To accommodate that we would use a
non-standard subtyping relation for returns. This could lead to
us inferring a return type of `void` in cases where we should
not.
Change-Id: Iee9ece9c722f47efa305f49490d3022d0bbb9f44
Reviewed-on: https://dart-review.googlesource.com/72403
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
This CL fixes type inference of closures using '=>' syntax so that
they infer consistently with an equivalent closure defined using block
syntax ('{}').
Fixes#31436.
Change-Id: I5463dd0ba986e9953ebabbc24ce3ced9a7220007
Reviewed-on: https://dart-review.googlesource.com/27084
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>