@@ -2075,7 +2075,7 @@ \section{Functions}
2075
2075
that the returned object will not be used
2076
2076
(\ref{return}).%
2077
2077
}
2078
- \item The function is asynchronous, \flatten {T} is not \VOID,
2078
+ \item The function is asynchronous, \Flatten {T} is not \VOID,
2079
2079
and it would have been a compile-time error
2080
2080
to declare the function with the body
2081
2081
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11842,7 +11842,7 @@ \subsection{Function Expressions}
11842
11842
\commentary{%
11843
11843
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
11844
11844
because this will never occur
11845
- (this concept is only used in \flattenName , which is defined below).%
11845
+ (this concept is only used in \FlattenName , which is defined below).%
11846
11846
}
11847
11847
\end{itemize}
11848
11848
@@ -11899,7 +11899,7 @@ \subsection{Function Expressions}
11899
11899
11900
11900
\LMHash{}%
11901
11901
We define the auxiliary function
11902
- \IndexCustom{\flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11902
+ \IndexCustom{\Flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11903
11903
as follows, using the first applicable case:
11904
11904
11905
11905
\begin{itemize}
@@ -11909,24 +11909,24 @@ \subsection{Function Expressions}
11909
11909
11910
11910
\begin{itemize}
11911
11911
\item if $S$ derives a future type $U$
11912
- then \DefEquals{\flatten {T}}{\code{\flatten {U}}}.
11912
+ then \DefEquals{\Flatten {T}}{\code{\Flatten {U}}}.
11913
11913
\item otherwise,
11914
- \DefEquals{\flatten {T}}{\code{\flatten {X}}}.
11914
+ \DefEquals{\Flatten {T}}{\code{\Flatten {X}}}.
11915
11915
\end{itemize}
11916
11916
11917
11917
\item If $T$ derives a future type \code{Future<$S$>}
11918
11918
or \code{FutureOr<$S$>}
11919
- then \DefEquals{\flatten {T}}{S}.
11919
+ then \DefEquals{\Flatten {T}}{S}.
11920
11920
11921
11921
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11922
- \code{FutureOr<$S$>?}\ then \DefEquals{\flatten {T}}{\code{$S$?}}.
11922
+ \code{FutureOr<$S$>?}\ then \DefEquals{\Flatten {T}}{\code{$S$?}}.
11923
11923
11924
- \item Otherwise, \DefEquals{\flatten {T}}{T}.
11924
+ \item Otherwise, \DefEquals{\Flatten {T}}{T}.
11925
11925
\end{itemize}
11926
11926
11927
11927
\rationale{%
11928
11928
This definition guarantees that for any type $T$,
11929
- \code{$T <:$ FutureOr<$\flatten {T}$>}. The proof is by induction on the
11929
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}. The proof is by induction on the
11930
11930
structure of $T$:
11931
11931
11932
11932
\begin{itemize}
@@ -11935,35 +11935,35 @@ \subsection{Function Expressions}
11935
11935
\begin{itemize}
11936
11936
\item if $S$ derives a future type $U$,
11937
11937
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11938
- By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten {U}$>}.
11939
- Since \code{$\flatten {T} = \flatten {U}$} in this case, it follows that
11940
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11941
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11938
+ By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten {U}$>}.
11939
+ Since \code{$\Flatten {T} = \Flatten {U}$} in this case, it follows that
11940
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11941
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11942
11942
\item otherwise, \code{$T <: X$}.
11943
- By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten {X}$>}.
11944
- Since \code{$\flatten {T} = \flatten {X}$} in this case, it follows that
11945
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11946
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11943
+ By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten {X}$>}.
11944
+ Since \code{$\Flatten {T} = \Flatten {X}$} in this case, it follows that
11945
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11946
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11947
11947
\end{itemize}
11948
11948
11949
11949
\item If $T$ derives a future type \code{Future<$S$>}
11950
11950
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11951
- it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten {T} = S$}
11952
- in this case, it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11951
+ it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten {T} = S$}
11952
+ in this case, it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11953
11953
11954
11954
\item If $T$ derives a future type \code{Future<$S$>?} or
11955
11955
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
11956
11956
it follows that \code{$T <:$ FutureOr<$S$>?}.
11957
11957
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$
11958
11958
(this can be shown using the union type subtype rules and from
11959
11959
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11960
- \code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten {T} = S$?} in this case,
11961
- it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11960
+ \code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten {T} = S$?} in this case,
11961
+ it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11962
11962
11963
- \item Otherwise, \code{$\flatten {T} = T$}, so
11964
- \code{FutureOr<$\flatten {T}$> $=$ FutureOr<$T$>}. Since
11963
+ \item Otherwise, \code{$\Flatten {T} = T$}, so
11964
+ \code{FutureOr<$\Flatten {T}$> $=$ FutureOr<$T$>}. Since
11965
11965
\code{$T <:$ FutureOr<$T$>}, it follows that
11966
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11966
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11967
11967
\end{itemize}
11968
11968
}
11969
11969
@@ -11998,7 +11998,7 @@ \subsection{Function Expressions}
11998
11998
11999
11999
\noindent
12000
12000
is
12001
- \FunctionTypePositionalStdCr{\code{Future<\flatten {T_0}>}},
12001
+ \FunctionTypePositionalStdCr{\code{Future<\Flatten {T_0}>}},
12002
12002
12003
12003
\noindent
12004
12004
where $T_0$ is the static type of $e$.
@@ -12034,7 +12034,7 @@ \subsection{Function Expressions}
12034
12034
12035
12035
\noindent
12036
12036
is
12037
- \FunctionTypeNamedStdCr{\code{Future<\flatten {T_0}>}},
12037
+ \FunctionTypeNamedStdCr{\code{Future<\Flatten {T_0}>}},
12038
12038
12039
12039
\noindent
12040
12040
where $T_0$ is the static type of $e$.
@@ -16850,13 +16850,13 @@ \subsection{Await Expressions}
16850
16850
\BlindDefineSymbol{a, e, S}%
16851
16851
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
16852
16852
Let $S$ be the static type of $e$.
16853
- The static type of $a$ is then \flatten {S}
16853
+ The static type of $a$ is then \Flatten {S}
16854
16854
(\ref{functionExpressions}).
16855
16855
16856
16856
\LMHash{}%
16857
16857
Evaluation of $a$ proceeds as follows:
16858
16858
First, the expression $e$ is evaluated to an object $o$.
16859
- Let \DefineSymbol{T} be \flatten {S}.
16859
+ Let \DefineSymbol{T} be \Flatten {S}.
16860
16860
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
16861
16861
then let \DefineSymbol{f} be $o$;
16862
16862
otherwise let $f$ be the result of creating
@@ -16877,7 +16877,7 @@ \subsection{Await Expressions}
16877
16877
If $f$ completes with an object $v$, $a$ evaluates to $v$.
16878
16878
16879
16879
\rationale{%
16880
- The use of \flattenName {} to find $T$
16880
+ The use of \FlattenName {} to find $T$
16881
16881
and hence determine the dynamic type test
16882
16882
implies that we await a future in every case where this choice is sound.%
16883
16883
}
@@ -16894,7 +16894,7 @@ \subsection{Await Expressions}
16894
16894
However, the second kind could be a \code{Future<Object?>}.
16895
16895
This object isn't a \code{Future<Object>}, and it isn't \NULL,
16896
16896
so it \emph{must} be considered to be in the second group.
16897
- Nevertheless, \flatten {\code{FutureOr<Object>?}} is \code{Object?},
16897
+ Nevertheless, \Flatten {\code{FutureOr<Object>?}} is \code{Object?},
16898
16898
so we \emph{will} await a \code{Future<Object?>}.
16899
16899
We have chosen this semantics because it was the smallest breaking change
16900
16900
relative to the semantics in earlier versions of Dart,
@@ -19342,7 +19342,7 @@ \subsection{Return}
19342
19342
%
19343
19343
% Returning without an object is only ok for async-"voidy" return types.
19344
19344
It is a compile-time error if $s$ is \code{\RETURN;},
19345
- unless \flatten {T}
19345
+ unless \Flatten {T}
19346
19346
(\ref{functionExpressions})
19347
19347
is \VOID, \DYNAMIC, or \code{Null}.
19348
19348
%
@@ -19355,26 +19355,26 @@ \subsection{Return}
19355
19355
% Returning with an object in an void async function only ok
19356
19356
% when that value is async-"voidy".
19357
19357
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19358
- \flatten {T} is \VOID,
19359
- and \flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19358
+ \Flatten {T} is \VOID,
19359
+ and \Flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19360
19360
%
19361
19361
% Returning async-void in a "non-async-voidy" function is an error.
19362
19362
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19363
- \flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19364
- and \flatten {S} is \VOID.
19363
+ \Flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19364
+ and \Flatten {S} is \VOID.
19365
19365
%
19366
19366
% Otherwise, returning an un-deasync-assignable value is an error.
19367
19367
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19368
- \flatten {S} is not \VOID,
19369
- and \code{Future<\flatten {S}>} is not assignable to $T$.
19368
+ \Flatten {S} is not \VOID,
19369
+ and \code{Future<\Flatten {S}>} is not assignable to $T$.
19370
19370
19371
19371
\commentary{%
19372
- Note that \flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19372
+ Note that \Flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19373
19373
in the last case,
19374
19374
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
19375
19375
In particular, when $T$ is \code{FutureOr<Null>}
19376
19376
(which is equivalent to \code{Future<Null>}),
19377
- \code{Future<\flatten {S}>} is assignable to $T$ for all $S$.
19377
+ \code{Future<\Flatten {S}>} is assignable to $T$ for all $S$.
19378
19378
This means that no compile-time error is raised,
19379
19379
but \emph{only} the null object (\ref{null})
19380
19380
or an instance of \code{Future<Null>}
@@ -19386,7 +19386,7 @@ \subsection{Return}
19386
19386
19387
19387
An error will not be raised if $f$ has no declared return type,
19388
19388
since the return type would be \DYNAMIC,
19389
- and \code{Future<\flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19389
+ and \code{Future<\Flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19390
19390
However, an asynchronous non-generator function
19391
19391
that declares a return type which is not ``voidy''
19392
19392
must return an expression explicitly.%
@@ -19437,7 +19437,7 @@ \subsection{Return}
19437
19437
let $T$ be the actual return type of $f$
19438
19438
(\ref{actualTypes}).
19439
19439
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19440
- and $S$ is a subtype of \code{Future<\flatten {T}>}
19440
+ and $S$ is a subtype of \code{Future<\Flatten {T}>}
19441
19441
then let $r$ be the result of evaluating \code{await $v$}
19442
19442
where $v$ is a fresh variable bound to $o$.
19443
19443
Otherwise let $r$ be $o$.
0 commit comments