@@ -2053,7 +2053,7 @@ \section{Functions}
2053
2053
that the returned object will not be used
2054
2054
(\ref{return}).%
2055
2055
}
2056
- \item The function is asynchronous, \flatten {T} is not \VOID,
2056
+ \item The function is asynchronous, \Flatten {T} is not \VOID,
2057
2057
and it would have been a compile-time error
2058
2058
to declare the function with the body
2059
2059
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11784,7 +11784,7 @@ \subsection{Function Expressions}
11784
11784
\commentary{%
11785
11785
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
11786
11786
because this will never occur
11787
- (this concept is only used in \flattenName , which is defined below).%
11787
+ (this concept is only used in \FlattenName , which is defined below).%
11788
11788
}
11789
11789
\end{itemize}
11790
11790
@@ -11839,7 +11839,7 @@ \subsection{Function Expressions}
11839
11839
11840
11840
\LMHash{}%
11841
11841
We define the auxiliary function
11842
- \IndexCustom{\flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11842
+ \IndexCustom{\Flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11843
11843
as follows, using the first applicable case:
11844
11844
11845
11845
\begin{itemize}
@@ -11848,60 +11848,60 @@ \subsection{Function Expressions}
11848
11848
for some type variable $X$ and type $S$ then
11849
11849
\begin{itemize}
11850
11850
\item if $S$ derives a future type $U$
11851
- then \DefEquals{\flatten {T}}{\code{\flatten {U}}}.
11851
+ then \DefEquals{\Flatten {T}}{\code{\Flatten {U}}}.
11852
11852
\item otherwise,
11853
- \DefEquals{\flatten {T}}{\code{\flatten {X}}}.
11853
+ \DefEquals{\Flatten {T}}{\code{\Flatten {X}}}.
11854
11854
\end{itemize}
11855
11855
11856
11856
\item If $T$ derives a future type \code{Future<$S$>}
11857
11857
or \code{FutureOr<$S$>}
11858
- then \DefEquals{\flatten {T}}{S}.
11858
+ then \DefEquals{\Flatten {T}}{S}.
11859
11859
11860
11860
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11861
- \code{FutureOr<$S$>?}\ then \DefEquals{\flatten {T}}{\code{$S$?}}.
11861
+ \code{FutureOr<$S$>?}\ then \DefEquals{\Flatten {T}}{\code{$S$?}}.
11862
11862
11863
- \item Otherwise, \DefEquals{\flatten {T}}{T}.
11863
+ \item Otherwise, \DefEquals{\Flatten {T}}{T}.
11864
11864
\end{itemize}
11865
11865
11866
11866
\rationale{%
11867
11867
This definition guarantees that for any type $T$,
11868
- \code{$T <:$ FutureOr<$\flatten {T}$>}. The proof is by induction on the
11868
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}. The proof is by induction on the
11869
11869
structure of $T$:
11870
11870
11871
11871
\begin{itemize}
11872
11872
\item If $T$ is \code{$X$\,\&\,$S$} then
11873
11873
\begin{itemize}
11874
11874
\item if $S$ derives a future type $U$,
11875
11875
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11876
- By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten {U}$>}.
11877
- Since \code{$\flatten {T} = \flatten {U}$} in this case, it follows that
11878
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11879
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11876
+ By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten {U}$>}.
11877
+ Since \code{$\Flatten {T} = \Flatten {U}$} in this case, it follows that
11878
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11879
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11880
11880
\item otherwise, \code{$T <: X$}.
11881
- By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten {X}$>}.
11882
- Since \code{$\flatten {T} = \flatten {X}$} in this case, it follows that
11883
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11884
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11881
+ By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten {X}$>}.
11882
+ Since \code{$\Flatten {T} = \Flatten {X}$} in this case, it follows that
11883
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11884
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11885
11885
\end{itemize}
11886
11886
11887
11887
\item If $T$ derives a future type \code{Future<$S$>}
11888
11888
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11889
- it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten {T} = S$}
11890
- in this case, it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11889
+ it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten {T} = S$}
11890
+ in this case, it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11891
11891
11892
11892
\item If $T$ derives a future type \code{Future<$S$>?} or
11893
11893
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
11894
11894
it follows that \code{$T <:$ FutureOr<$S$>?}.
11895
11895
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$ (this can be shown
11896
11896
using the union type subtype rules and from
11897
11897
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11898
- \code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten {T} = S$?} in this case,
11899
- it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11898
+ \code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten {T} = S$?} in this case,
11899
+ it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11900
11900
11901
- \item Otherwise, \code{$\flatten {T} = T$}, so
11902
- \code{FutureOr<$\flatten {T}$> $=$ FutureOr<$T$>}. Since
11901
+ \item Otherwise, \code{$\Flatten {T} = T$}, so
11902
+ \code{FutureOr<$\Flatten {T}$> $=$ FutureOr<$T$>}. Since
11903
11903
\code{$T <:$ FutureOr<$T$>}, it follows that
11904
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11904
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11905
11905
\end{itemize}
11906
11906
}
11907
11907
@@ -11936,7 +11936,7 @@ \subsection{Function Expressions}
11936
11936
11937
11937
\noindent
11938
11938
is
11939
- \FunctionTypePositionalStdCr{\code{Future<\flatten {T_0}>}},
11939
+ \FunctionTypePositionalStdCr{\code{Future<\Flatten {T_0}>}},
11940
11940
11941
11941
\noindent
11942
11942
where $T_0$ is the static type of $e$.
@@ -11972,7 +11972,7 @@ \subsection{Function Expressions}
11972
11972
11973
11973
\noindent
11974
11974
is
11975
- \FunctionTypeNamedStdCr{\code{Future<\flatten {T_0}>}},
11975
+ \FunctionTypeNamedStdCr{\code{Future<\Flatten {T_0}>}},
11976
11976
11977
11977
\noindent
11978
11978
where $T_0$ is the static type of $e$.
@@ -16760,13 +16760,13 @@ \subsection{Await Expressions}
16760
16760
\BlindDefineSymbol{a, e, S}%
16761
16761
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
16762
16762
Let $S$ be the static type of $e$.
16763
- The static type of $a$ is then \flatten {S}
16763
+ The static type of $a$ is then \Flatten {S}
16764
16764
(\ref{functionExpressions}).
16765
16765
16766
16766
\LMHash{}%
16767
16767
Evaluation of $a$ proceeds as follows:
16768
16768
First, the expression $e$ is evaluated to an object $o$.
16769
- Let \DefineSymbol{T} be \flatten {S}.
16769
+ Let \DefineSymbol{T} be \Flatten {S}.
16770
16770
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
16771
16771
then let \DefineSymbol{f} be $o$;
16772
16772
otherwise let $f$ be the result of creating
@@ -16787,7 +16787,7 @@ \subsection{Await Expressions}
16787
16787
If $f$ completes with an object $v$, $a$ evaluates to $v$.
16788
16788
16789
16789
\rationale{%
16790
- The use of \flattenName {} to find $T$ and hence determine the dynamic type test
16790
+ The use of \FlattenName {} to find $T$ and hence determine the dynamic type test
16791
16791
implies that we await a future in every case where this choice is sound.%
16792
16792
}
16793
16793
@@ -16803,7 +16803,7 @@ \subsection{Await Expressions}
16803
16803
However, the second kind could be a \code{Future<Object?>}.
16804
16804
This object isn't a \code{Future<Object>}, and it isn't \NULL,
16805
16805
so it \emph{must} be considered to be in the second group.
16806
- Nevertheless, \flatten {\code{FutureOr<Object>?}} is \code{Object?},
16806
+ Nevertheless, \Flatten {\code{FutureOr<Object>?}} is \code{Object?},
16807
16807
so we \emph{will} await a \code{Future<Object?>}.
16808
16808
We have chosen this semantics because it was the smallest breaking change
16809
16809
relative to the semantics in earlier versions of Dart,
@@ -19235,7 +19235,7 @@ \subsection{Return}
19235
19235
%
19236
19236
% Returning without an object is only ok for async-"voidy" return types.
19237
19237
It is a compile-time error if $s$ is \code{\RETURN;},
19238
- unless \flatten {T}
19238
+ unless \Flatten {T}
19239
19239
(\ref{functionExpressions})
19240
19240
is \VOID, \DYNAMIC, or \code{Null}.
19241
19241
%
@@ -19248,26 +19248,26 @@ \subsection{Return}
19248
19248
% Returning with an object in an void async function only ok
19249
19249
% when that value is async-"voidy".
19250
19250
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19251
- \flatten {T} is \VOID,
19252
- and \flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19251
+ \Flatten {T} is \VOID,
19252
+ and \Flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19253
19253
%
19254
19254
% Returning async-void in a "non-async-voidy" function is an error.
19255
19255
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19256
- \flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19257
- and \flatten {S} is \VOID.
19256
+ \Flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19257
+ and \Flatten {S} is \VOID.
19258
19258
%
19259
19259
% Otherwise, returning an un-deasync-assignable value is an error.
19260
19260
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19261
- \flatten {S} is not \VOID,
19262
- and \code{Future<\flatten {S}>} is not assignable to $T$.
19261
+ \Flatten {S} is not \VOID,
19262
+ and \code{Future<\Flatten {S}>} is not assignable to $T$.
19263
19263
19264
19264
\commentary{%
19265
- Note that \flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19265
+ Note that \Flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19266
19266
in the last case,
19267
19267
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
19268
19268
In particular, when $T$ is \code{FutureOr<Null>}
19269
19269
(which is equivalent to \code{Future<Null>}),
19270
- \code{Future<\flatten {S}>} is assignable to $T$ for all $S$.
19270
+ \code{Future<\Flatten {S}>} is assignable to $T$ for all $S$.
19271
19271
This means that no compile-time error is raised,
19272
19272
but \emph{only} the null object (\ref{null})
19273
19273
or an instance of \code{Future<Null>} can successfully be returned at run time.
@@ -19278,7 +19278,7 @@ \subsection{Return}
19278
19278
19279
19279
An error will not be raised if $f$ has no declared return type,
19280
19280
since the return type would be \DYNAMIC,
19281
- and \code{Future<\flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19281
+ and \code{Future<\Flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19282
19282
However, an asynchronous non-generator function
19283
19283
that declares a return type which is not ``voidy''
19284
19284
must return an expression explicitly.%
@@ -19329,7 +19329,7 @@ \subsection{Return}
19329
19329
let $T$ be the actual return type of $f$
19330
19330
(\ref{actualTypes}).
19331
19331
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19332
- and $S$ is a subtype of \code{Future<\flatten {T}>}
19332
+ and $S$ is a subtype of \code{Future<\Flatten {T}>}
19333
19333
then let $r$ be the result of evaluating \code{await $v$}
19334
19334
where $v$ is a fresh variable bound to $o$.
19335
19335
Otherwise let $r$ be $o$.
0 commit comments