@@ -2087,7 +2087,7 @@ \section{Functions}
2087
2087
that the returned object will not be used
2088
2088
(\ref{return}).%
2089
2089
}
2090
- \item The function is asynchronous, \flatten {T} is not \VOID,
2090
+ \item The function is asynchronous, \Flatten {T} is not \VOID,
2091
2091
and it would have been a compile-time error
2092
2092
to declare the function with the body
2093
2093
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11872,7 +11872,7 @@ \subsection{Function Expressions}
11872
11872
\commentary{%
11873
11873
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
11874
11874
because this will never occur
11875
- (this concept is only used in \flattenName , which is defined below).%
11875
+ (this concept is only used in \FlattenName , which is defined below).%
11876
11876
}
11877
11877
\end{itemize}
11878
11878
@@ -11929,7 +11929,7 @@ \subsection{Function Expressions}
11929
11929
11930
11930
\LMHash{}%
11931
11931
We define the auxiliary function
11932
- \IndexCustom{\flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11932
+ \IndexCustom{\Flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11933
11933
as follows, using the first applicable case:
11934
11934
11935
11935
\begin{itemize}
@@ -11939,24 +11939,24 @@ \subsection{Function Expressions}
11939
11939
11940
11940
\begin{itemize}
11941
11941
\item if $S$ derives a future type $U$
11942
- then \DefEquals{\flatten {T}}{\code{\flatten {U}}}.
11942
+ then \DefEquals{\Flatten {T}}{\code{\Flatten {U}}}.
11943
11943
\item otherwise,
11944
- \DefEquals{\flatten {T}}{\code{\flatten {X}}}.
11944
+ \DefEquals{\Flatten {T}}{\code{\Flatten {X}}}.
11945
11945
\end{itemize}
11946
11946
11947
11947
\item If $T$ derives a future type \code{Future<$S$>}
11948
11948
or \code{FutureOr<$S$>}
11949
- then \DefEquals{\flatten {T}}{S}.
11949
+ then \DefEquals{\Flatten {T}}{S}.
11950
11950
11951
11951
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11952
- \code{FutureOr<$S$>?}\ then \DefEquals{\flatten {T}}{\code{$S$?}}.
11952
+ \code{FutureOr<$S$>?}\ then \DefEquals{\Flatten {T}}{\code{$S$?}}.
11953
11953
11954
- \item Otherwise, \DefEquals{\flatten {T}}{T}.
11954
+ \item Otherwise, \DefEquals{\Flatten {T}}{T}.
11955
11955
\end{itemize}
11956
11956
11957
11957
\rationale{%
11958
11958
This definition guarantees that for any type $T$,
11959
- \code{$T <:$ FutureOr<$\flatten {T}$>}. The proof is by induction on the
11959
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}. The proof is by induction on the
11960
11960
structure of $T$:
11961
11961
11962
11962
\begin{itemize}
@@ -11965,35 +11965,35 @@ \subsection{Function Expressions}
11965
11965
\begin{itemize}
11966
11966
\item if $S$ derives a future type $U$,
11967
11967
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11968
- By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten {U}$>}.
11969
- Since \code{$\flatten {T} = \flatten {U}$} in this case, it follows that
11970
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11971
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11968
+ By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten {U}$>}.
11969
+ Since \code{$\Flatten {T} = \Flatten {U}$} in this case, it follows that
11970
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11971
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11972
11972
\item otherwise, \code{$T <: X$}.
11973
- By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten {X}$>}.
11974
- Since \code{$\flatten {T} = \flatten {X}$} in this case, it follows that
11975
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11976
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11973
+ By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten {X}$>}.
11974
+ Since \code{$\Flatten {T} = \Flatten {X}$} in this case, it follows that
11975
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11976
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11977
11977
\end{itemize}
11978
11978
11979
11979
\item If $T$ derives a future type \code{Future<$S$>}
11980
11980
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11981
- it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten {T} = S$}
11982
- in this case, it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11981
+ it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten {T} = S$}
11982
+ in this case, it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11983
11983
11984
11984
\item If $T$ derives a future type \code{Future<$S$>?} or
11985
11985
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
11986
11986
it follows that \code{$T <:$ FutureOr<$S$>?}.
11987
11987
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$
11988
11988
(this can be shown using the union type subtype rules and from
11989
11989
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11990
- \code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten {T} = S$?} in this case,
11991
- it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11990
+ \code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten {T} = S$?} in this case,
11991
+ it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11992
11992
11993
- \item Otherwise, \code{$\flatten {T} = T$}, so
11994
- \code{FutureOr<$\flatten {T}$> $=$ FutureOr<$T$>}. Since
11993
+ \item Otherwise, \code{$\Flatten {T} = T$}, so
11994
+ \code{FutureOr<$\Flatten {T}$> $=$ FutureOr<$T$>}. Since
11995
11995
\code{$T <:$ FutureOr<$T$>}, it follows that
11996
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11996
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11997
11997
\end{itemize}
11998
11998
}
11999
11999
@@ -12028,7 +12028,7 @@ \subsection{Function Expressions}
12028
12028
12029
12029
\noindent
12030
12030
is
12031
- \FunctionTypePositionalStdCr{\code{Future<\flatten {T_0}>}},
12031
+ \FunctionTypePositionalStdCr{\code{Future<\Flatten {T_0}>}},
12032
12032
12033
12033
\noindent
12034
12034
where $T_0$ is the static type of $e$.
@@ -12064,7 +12064,7 @@ \subsection{Function Expressions}
12064
12064
12065
12065
\noindent
12066
12066
is
12067
- \FunctionTypeNamedStdCr{\code{Future<\flatten {T_0}>}},
12067
+ \FunctionTypeNamedStdCr{\code{Future<\Flatten {T_0}>}},
12068
12068
12069
12069
\noindent
12070
12070
where $T_0$ is the static type of $e$.
@@ -16880,13 +16880,13 @@ \subsection{Await Expressions}
16880
16880
\BlindDefineSymbol{a, e, S}%
16881
16881
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
16882
16882
Let $S$ be the static type of $e$.
16883
- The static type of $a$ is then \flatten {S}
16883
+ The static type of $a$ is then \Flatten {S}
16884
16884
(\ref{functionExpressions}).
16885
16885
16886
16886
\LMHash{}%
16887
16887
Evaluation of $a$ proceeds as follows:
16888
16888
First, the expression $e$ is evaluated to an object $o$.
16889
- Let \DefineSymbol{T} be \flatten {S}.
16889
+ Let \DefineSymbol{T} be \Flatten {S}.
16890
16890
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
16891
16891
then let \DefineSymbol{f} be $o$;
16892
16892
otherwise let $f$ be the result of creating
@@ -16907,7 +16907,7 @@ \subsection{Await Expressions}
16907
16907
If $f$ completes with an object $v$, $a$ evaluates to $v$.
16908
16908
16909
16909
\rationale{%
16910
- The use of \flattenName {} to find $T$
16910
+ The use of \FlattenName {} to find $T$
16911
16911
and hence determine the dynamic type test
16912
16912
implies that we await a future in every case where this choice is sound.%
16913
16913
}
@@ -16924,7 +16924,7 @@ \subsection{Await Expressions}
16924
16924
However, the second kind could be a \code{Future<Object?>}.
16925
16925
This object isn't a \code{Future<Object>}, and it isn't \NULL,
16926
16926
so it \emph{must} be considered to be in the second group.
16927
- Nevertheless, \flatten {\code{FutureOr<Object>?}} is \code{Object?},
16927
+ Nevertheless, \Flatten {\code{FutureOr<Object>?}} is \code{Object?},
16928
16928
so we \emph{will} await a \code{Future<Object?>}.
16929
16929
We have chosen this semantics because it was the smallest breaking change
16930
16930
relative to the semantics in earlier versions of Dart,
@@ -19372,7 +19372,7 @@ \subsection{Return}
19372
19372
%
19373
19373
% Returning without an object is only ok for async-"voidy" return types.
19374
19374
It is a compile-time error if $s$ is \code{\RETURN;},
19375
- unless \flatten {T}
19375
+ unless \Flatten {T}
19376
19376
(\ref{functionExpressions})
19377
19377
is \VOID, \DYNAMIC, or \code{Null}.
19378
19378
%
@@ -19385,26 +19385,26 @@ \subsection{Return}
19385
19385
% Returning with an object in an void async function only ok
19386
19386
% when that value is async-"voidy".
19387
19387
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19388
- \flatten {T} is \VOID,
19389
- and \flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19388
+ \Flatten {T} is \VOID,
19389
+ and \Flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19390
19390
%
19391
19391
% Returning async-void in a "non-async-voidy" function is an error.
19392
19392
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19393
- \flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19394
- and \flatten {S} is \VOID.
19393
+ \Flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19394
+ and \Flatten {S} is \VOID.
19395
19395
%
19396
19396
% Otherwise, returning an un-deasync-assignable value is an error.
19397
19397
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19398
- \flatten {S} is not \VOID,
19399
- and \code{Future<\flatten {S}>} is not assignable to $T$.
19398
+ \Flatten {S} is not \VOID,
19399
+ and \code{Future<\Flatten {S}>} is not assignable to $T$.
19400
19400
19401
19401
\commentary{%
19402
- Note that \flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19402
+ Note that \Flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19403
19403
in the last case,
19404
19404
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
19405
19405
In particular, when $T$ is \code{FutureOr<Null>}
19406
19406
(which is equivalent to \code{Future<Null>}),
19407
- \code{Future<\flatten {S}>} is assignable to $T$ for all $S$.
19407
+ \code{Future<\Flatten {S}>} is assignable to $T$ for all $S$.
19408
19408
This means that no compile-time error is raised,
19409
19409
but \emph{only} the null object (\ref{null})
19410
19410
or an instance of \code{Future<Null>}
@@ -19416,7 +19416,7 @@ \subsection{Return}
19416
19416
19417
19417
An error will not be raised if $f$ has no declared return type,
19418
19418
since the return type would be \DYNAMIC,
19419
- and \code{Future<\flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19419
+ and \code{Future<\Flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19420
19420
However, an asynchronous non-generator function
19421
19421
that declares a return type which is not ``voidy''
19422
19422
must return an expression explicitly.%
@@ -19467,7 +19467,7 @@ \subsection{Return}
19467
19467
let $T$ be the actual return type of $f$
19468
19468
(\ref{actualTypes}).
19469
19469
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19470
- and $S$ is a subtype of \code{Future<\flatten {T}>}
19470
+ and $S$ is a subtype of \code{Future<\Flatten {T}>}
19471
19471
then let $r$ be the result of evaluating \code{await $v$}
19472
19472
where $v$ is a fresh variable bound to $o$.
19473
19473
Otherwise let $r$ be $o$.
0 commit comments