mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
Specify that a void return type doesn't cause errors in checked mode.
R=eernst@google.com Review-Url: https://codereview.chromium.org/2875643002 .
This commit is contained in:
parent
cdfe67f95d
commit
122345e356
1 changed files with 11 additions and 2 deletions
|
@ -6453,8 +6453,17 @@ It is a static type warning if the body of $f$ is marked \ASYNC{} and the type \
|
|||
\LMHash{}
|
||||
Let $S$ be the runtime type of $o$. In checked mode:
|
||||
\begin{itemize}
|
||||
\item If the body of $f$ is marked \ASYNC{} (\ref{functions}) it is a dynamic type error if $o$ is not \NULL{} (\ref{null}) and \code{Future<flatten(S)>} is not a subtype of the actual return type (\ref{actualTypeOfADeclaration}) of $f$.
|
||||
\item Otherwise, it is a dynamic type error if $o$ is not \NULL{} and the runtime type of $o$ is not a subtype of the actual return type of $f$.
|
||||
\item If the body of $f$ is marked \ASYNC{} (\ref{functions})
|
||||
it is a dynamic type error if $o$ is not \NULL{} (\ref{null}),
|
||||
the actual return type (\ref{actualTypeOfADeclaration}) of $f$ is not \VOID,
|
||||
and \code{Future<flatten(S)>} is not a subtype of the actual return type of $f$.
|
||||
% TODO(lrn): The "void foo() async { return e }" case is somewhat speculative.
|
||||
% When we disallow "return e" in a void function, we might also want to revisit
|
||||
% this rule. Currently it also covers the "void foo() async => e;" case, which
|
||||
% we might want to allow.
|
||||
\item Otherwise, it is a dynamic type error if $o$ is not \NULL{},
|
||||
the actual return type of $f$ is not \VOID{},
|
||||
and the runtime type of $o$ is not a subtype of the actual return type of $f$.
|
||||
\end{itemize}
|
||||
|
||||
\LMHash{}
|
||||
|
|
Loading…
Reference in a new issue