@@ -2092,7 +2092,7 @@ \section{Functions}
2092
2092
that the returned object will not be used
2093
2093
(\ref{return}).%
2094
2094
}
2095
- \item The function is asynchronous, \flatten {T} is not \VOID,
2095
+ \item The function is asynchronous, \Flatten {T} is not \VOID,
2096
2096
and it would have been a compile-time error
2097
2097
to declare the function with the body
2098
2098
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11879,7 +11879,7 @@ \subsection{Function Expressions}
11879
11879
\commentary{%
11880
11880
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
11881
11881
because this will never occur
11882
- (this concept is only used in \flattenName , which is defined below).%
11882
+ (this concept is only used in \FlattenName , which is defined below).%
11883
11883
}
11884
11884
\end{itemize}
11885
11885
@@ -11936,7 +11936,7 @@ \subsection{Function Expressions}
11936
11936
11937
11937
\LMHash{}%
11938
11938
We define the auxiliary function
11939
- \IndexCustom{\flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11939
+ \IndexCustom{\Flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11940
11940
as follows, using the first applicable case:
11941
11941
11942
11942
\begin{itemize}
@@ -11946,24 +11946,24 @@ \subsection{Function Expressions}
11946
11946
11947
11947
\begin{itemize}
11948
11948
\item if $S$ derives a future type $U$
11949
- then \DefEquals{\flatten {T}}{\code{\flatten {U}}}.
11949
+ then \DefEquals{\Flatten {T}}{\code{\Flatten {U}}}.
11950
11950
\item otherwise,
11951
- \DefEquals{\flatten {T}}{\code{\flatten {X}}}.
11951
+ \DefEquals{\Flatten {T}}{\code{\Flatten {X}}}.
11952
11952
\end{itemize}
11953
11953
11954
11954
\item If $T$ derives a future type \code{Future<$S$>}
11955
11955
or \code{FutureOr<$S$>}
11956
- then \DefEquals{\flatten {T}}{S}.
11956
+ then \DefEquals{\Flatten {T}}{S}.
11957
11957
11958
11958
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11959
- \code{FutureOr<$S$>?}\ then \DefEquals{\flatten {T}}{\code{$S$?}}.
11959
+ \code{FutureOr<$S$>?}\ then \DefEquals{\Flatten {T}}{\code{$S$?}}.
11960
11960
11961
- \item Otherwise, \DefEquals{\flatten {T}}{T}.
11961
+ \item Otherwise, \DefEquals{\Flatten {T}}{T}.
11962
11962
\end{itemize}
11963
11963
11964
11964
\rationale{%
11965
11965
This definition guarantees that for any type $T$,
11966
- \code{$T <:$ FutureOr<$\flatten {T}$>}. The proof is by induction on the
11966
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}. The proof is by induction on the
11967
11967
structure of $T$:
11968
11968
11969
11969
\begin{itemize}
@@ -11972,35 +11972,35 @@ \subsection{Function Expressions}
11972
11972
\begin{itemize}
11973
11973
\item if $S$ derives a future type $U$,
11974
11974
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11975
- By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten {U}$>}.
11976
- Since \code{$\flatten {T} = \flatten {U}$} in this case, it follows that
11977
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11978
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11975
+ By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten {U}$>}.
11976
+ Since \code{$\Flatten {T} = \Flatten {U}$} in this case, it follows that
11977
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11978
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11979
11979
\item otherwise, \code{$T <: X$}.
11980
- By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten {X}$>}.
11981
- Since \code{$\flatten {T} = \flatten {X}$} in this case, it follows that
11982
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11983
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11980
+ By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten {X}$>}.
11981
+ Since \code{$\Flatten {T} = \Flatten {X}$} in this case, it follows that
11982
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11983
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11984
11984
\end{itemize}
11985
11985
11986
11986
\item If $T$ derives a future type \code{Future<$S$>}
11987
11987
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11988
- it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten {T} = S$}
11989
- in this case, it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11988
+ it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten {T} = S$}
11989
+ in this case, it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11990
11990
11991
11991
\item If $T$ derives a future type \code{Future<$S$>?} or
11992
11992
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
11993
11993
it follows that \code{$T <:$ FutureOr<$S$>?}.
11994
11994
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$
11995
11995
(this can be shown using the union type subtype rules and from
11996
11996
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11997
- \code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten {T} = S$?} in this case,
11998
- it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11997
+ \code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten {T} = S$?} in this case,
11998
+ it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11999
11999
12000
- \item Otherwise, \code{$\flatten {T} = T$}, so
12001
- \code{FutureOr<$\flatten {T}$> $=$ FutureOr<$T$>}. Since
12000
+ \item Otherwise, \code{$\Flatten {T} = T$}, so
12001
+ \code{FutureOr<$\Flatten {T}$> $=$ FutureOr<$T$>}. Since
12002
12002
\code{$T <:$ FutureOr<$T$>}, it follows that
12003
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
12003
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
12004
12004
\end{itemize}
12005
12005
}
12006
12006
@@ -12035,7 +12035,7 @@ \subsection{Function Expressions}
12035
12035
12036
12036
\noindent
12037
12037
is
12038
- \FunctionTypePositionalStdCr{\code{Future<\flatten {T_0}>}},
12038
+ \FunctionTypePositionalStdCr{\code{Future<\Flatten {T_0}>}},
12039
12039
12040
12040
\noindent
12041
12041
where $T_0$ is the static type of $e$.
@@ -12071,7 +12071,7 @@ \subsection{Function Expressions}
12071
12071
12072
12072
\noindent
12073
12073
is
12074
- \FunctionTypeNamedStdCr{\code{Future<\flatten {T_0}>}},
12074
+ \FunctionTypeNamedStdCr{\code{Future<\Flatten {T_0}>}},
12075
12075
12076
12076
\noindent
12077
12077
where $T_0$ is the static type of $e$.
@@ -16887,13 +16887,13 @@ \subsection{Await Expressions}
16887
16887
\BlindDefineSymbol{a, e, S}%
16888
16888
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
16889
16889
Let $S$ be the static type of $e$.
16890
- The static type of $a$ is then \flatten {S}
16890
+ The static type of $a$ is then \Flatten {S}
16891
16891
(\ref{functionExpressions}).
16892
16892
16893
16893
\LMHash{}%
16894
16894
Evaluation of $a$ proceeds as follows:
16895
16895
First, the expression $e$ is evaluated to an object $o$.
16896
- Let \DefineSymbol{T} be \flatten {S}.
16896
+ Let \DefineSymbol{T} be \Flatten {S}.
16897
16897
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
16898
16898
then let \DefineSymbol{f} be $o$;
16899
16899
otherwise let $f$ be the result of creating
@@ -16914,7 +16914,7 @@ \subsection{Await Expressions}
16914
16914
If $f$ completes with an object $v$, $a$ evaluates to $v$.
16915
16915
16916
16916
\rationale{%
16917
- The use of \flattenName {} to find $T$
16917
+ The use of \FlattenName {} to find $T$
16918
16918
and hence determine the dynamic type test
16919
16919
implies that we await a future in every case where this choice is sound.%
16920
16920
}
@@ -16931,7 +16931,7 @@ \subsection{Await Expressions}
16931
16931
However, the second kind could be a \code{Future<Object?>}.
16932
16932
This object isn't a \code{Future<Object>}, and it isn't \NULL,
16933
16933
so it \emph{must} be considered to be in the second group.
16934
- Nevertheless, \flatten {\code{FutureOr<Object>?}} is \code{Object?},
16934
+ Nevertheless, \Flatten {\code{FutureOr<Object>?}} is \code{Object?},
16935
16935
so we \emph{will} await a \code{Future<Object?>}.
16936
16936
We have chosen this semantics because it was the smallest breaking change
16937
16937
relative to the semantics in earlier versions of Dart,
@@ -19379,7 +19379,7 @@ \subsection{Return}
19379
19379
%
19380
19380
% Returning without an object is only ok for async-"voidy" return types.
19381
19381
It is a compile-time error if $s$ is \code{\RETURN;},
19382
- unless \flatten {T}
19382
+ unless \Flatten {T}
19383
19383
(\ref{functionExpressions})
19384
19384
is \VOID, \DYNAMIC, or \code{Null}.
19385
19385
%
@@ -19392,26 +19392,26 @@ \subsection{Return}
19392
19392
% Returning with an object in an void async function only ok
19393
19393
% when that value is async-"voidy".
19394
19394
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19395
- \flatten {T} is \VOID,
19396
- and \flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19395
+ \Flatten {T} is \VOID,
19396
+ and \Flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19397
19397
%
19398
19398
% Returning async-void in a "non-async-voidy" function is an error.
19399
19399
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19400
- \flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19401
- and \flatten {S} is \VOID.
19400
+ \Flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19401
+ and \Flatten {S} is \VOID.
19402
19402
%
19403
19403
% Otherwise, returning an un-deasync-assignable value is an error.
19404
19404
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19405
- \flatten {S} is not \VOID,
19406
- and \code{Future<\flatten {S}>} is not assignable to $T$.
19405
+ \Flatten {S} is not \VOID,
19406
+ and \code{Future<\Flatten {S}>} is not assignable to $T$.
19407
19407
19408
19408
\commentary{%
19409
- Note that \flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19409
+ Note that \Flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19410
19410
in the last case,
19411
19411
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
19412
19412
In particular, when $T$ is \code{FutureOr<Null>}
19413
19413
(which is equivalent to \code{Future<Null>}),
19414
- \code{Future<\flatten {S}>} is assignable to $T$ for all $S$.
19414
+ \code{Future<\Flatten {S}>} is assignable to $T$ for all $S$.
19415
19415
This means that no compile-time error is raised,
19416
19416
but \emph{only} the null object (\ref{null})
19417
19417
or an instance of \code{Future<Null>}
@@ -19423,7 +19423,7 @@ \subsection{Return}
19423
19423
19424
19424
An error will not be raised if $f$ has no declared return type,
19425
19425
since the return type would be \DYNAMIC,
19426
- and \code{Future<\flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19426
+ and \code{Future<\Flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19427
19427
However, an asynchronous non-generator function
19428
19428
that declares a return type which is not ``voidy''
19429
19429
must return an expression explicitly.%
@@ -19474,7 +19474,7 @@ \subsection{Return}
19474
19474
let $T$ be the actual return type of $f$
19475
19475
(\ref{actualTypes}).
19476
19476
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19477
- and $S$ is a subtype of \code{Future<\flatten {T}>}
19477
+ and $S$ is a subtype of \code{Future<\Flatten {T}>}
19478
19478
then let $r$ be the result of evaluating \code{await $v$}
19479
19479
where $v$ is a fresh variable bound to $o$.
19480
19480
Otherwise let $r$ be $o$.
0 commit comments