@@ -2058,7 +2058,7 @@ \section{Functions}
2058
2058
that the returned object will not be used
2059
2059
(\ref{return}).%
2060
2060
}
2061
- \item The function is asynchronous, \flatten {T} is not \VOID,
2061
+ \item The function is asynchronous, \Flatten {T} is not \VOID,
2062
2062
and it would have been a compile-time error
2063
2063
to declare the function with the body
2064
2064
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11789,7 +11789,7 @@ \subsection{Function Expressions}
11789
11789
\commentary{%
11790
11790
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
11791
11791
because this will never occur
11792
- (this concept is only used in \flattenName , which is defined below).%
11792
+ (this concept is only used in \FlattenName , which is defined below).%
11793
11793
}
11794
11794
\end{itemize}
11795
11795
@@ -11844,7 +11844,7 @@ \subsection{Function Expressions}
11844
11844
11845
11845
\LMHash{}%
11846
11846
We define the auxiliary function
11847
- \IndexCustom{\flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11847
+ \IndexCustom{\Flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11848
11848
as follows, using the first applicable case:
11849
11849
11850
11850
\begin{itemize}
@@ -11853,60 +11853,60 @@ \subsection{Function Expressions}
11853
11853
for some type variable $X$ and type $S$ then
11854
11854
\begin{itemize}
11855
11855
\item if $S$ derives a future type $U$
11856
- then \DefEquals{\flatten {T}}{\code{\flatten {U}}}.
11856
+ then \DefEquals{\Flatten {T}}{\code{\Flatten {U}}}.
11857
11857
\item otherwise,
11858
- \DefEquals{\flatten {T}}{\code{\flatten {X}}}.
11858
+ \DefEquals{\Flatten {T}}{\code{\Flatten {X}}}.
11859
11859
\end{itemize}
11860
11860
11861
11861
\item If $T$ derives a future type \code{Future<$S$>}
11862
11862
or \code{FutureOr<$S$>}
11863
- then \DefEquals{\flatten {T}}{S}.
11863
+ then \DefEquals{\Flatten {T}}{S}.
11864
11864
11865
11865
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11866
- \code{FutureOr<$S$>?}\ then \DefEquals{\flatten {T}}{\code{$S$?}}.
11866
+ \code{FutureOr<$S$>?}\ then \DefEquals{\Flatten {T}}{\code{$S$?}}.
11867
11867
11868
- \item Otherwise, \DefEquals{\flatten {T}}{T}.
11868
+ \item Otherwise, \DefEquals{\Flatten {T}}{T}.
11869
11869
\end{itemize}
11870
11870
11871
11871
\rationale{%
11872
11872
This definition guarantees that for any type $T$,
11873
- \code{$T <:$ FutureOr<$\flatten {T}$>}. The proof is by induction on the
11873
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}. The proof is by induction on the
11874
11874
structure of $T$:
11875
11875
11876
11876
\begin{itemize}
11877
11877
\item If $T$ is \code{$X$\,\&\,$S$} then
11878
11878
\begin{itemize}
11879
11879
\item if $S$ derives a future type $U$,
11880
11880
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11881
- By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten {U}$>}.
11882
- Since \code{$\flatten {T} = \flatten {U}$} 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{$U <:$ FutureOr<$\Flatten {U}$>}.
11882
+ Since \code{$\Flatten {T} = \Flatten {U}$} in this case, it follows that
11883
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11884
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11885
11885
\item otherwise, \code{$T <: X$}.
11886
- By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten {X}$>}.
11887
- Since \code{$\flatten {T} = \flatten {X}$} in this case, it follows that
11888
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11889
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11886
+ By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten {X}$>}.
11887
+ Since \code{$\Flatten {T} = \Flatten {X}$} in this case, it follows that
11888
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11889
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11890
11890
\end{itemize}
11891
11891
11892
11892
\item If $T$ derives a future type \code{Future<$S$>}
11893
11893
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11894
- it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten {T} = S$}
11895
- in this case, it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11894
+ it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten {T} = S$}
11895
+ in this case, it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11896
11896
11897
11897
\item If $T$ derives a future type \code{Future<$S$>?} or
11898
11898
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
11899
11899
it follows that \code{$T <:$ FutureOr<$S$>?}.
11900
11900
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$ (this can be shown
11901
11901
using the union type subtype rules and from
11902
11902
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11903
- \code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten {T} = S$?} in this case,
11904
- it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11903
+ \code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten {T} = S$?} in this case,
11904
+ it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11905
11905
11906
- \item Otherwise, \code{$\flatten {T} = T$}, so
11907
- \code{FutureOr<$\flatten {T}$> $=$ FutureOr<$T$>}. Since
11906
+ \item Otherwise, \code{$\Flatten {T} = T$}, so
11907
+ \code{FutureOr<$\Flatten {T}$> $=$ FutureOr<$T$>}. Since
11908
11908
\code{$T <:$ FutureOr<$T$>}, it follows that
11909
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11909
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11910
11910
\end{itemize}
11911
11911
}
11912
11912
@@ -11941,7 +11941,7 @@ \subsection{Function Expressions}
11941
11941
11942
11942
\noindent
11943
11943
is
11944
- \FunctionTypePositionalStdCr{\code{Future<\flatten {T_0}>}},
11944
+ \FunctionTypePositionalStdCr{\code{Future<\Flatten {T_0}>}},
11945
11945
11946
11946
\noindent
11947
11947
where $T_0$ is the static type of $e$.
@@ -11977,7 +11977,7 @@ \subsection{Function Expressions}
11977
11977
11978
11978
\noindent
11979
11979
is
11980
- \FunctionTypeNamedStdCr{\code{Future<\flatten {T_0}>}},
11980
+ \FunctionTypeNamedStdCr{\code{Future<\Flatten {T_0}>}},
11981
11981
11982
11982
\noindent
11983
11983
where $T_0$ is the static type of $e$.
@@ -16765,13 +16765,13 @@ \subsection{Await Expressions}
16765
16765
\BlindDefineSymbol{a, e, S}%
16766
16766
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
16767
16767
Let $S$ be the static type of $e$.
16768
- The static type of $a$ is then \flatten {S}
16768
+ The static type of $a$ is then \Flatten {S}
16769
16769
(\ref{functionExpressions}).
16770
16770
16771
16771
\LMHash{}%
16772
16772
Evaluation of $a$ proceeds as follows:
16773
16773
First, the expression $e$ is evaluated to an object $o$.
16774
- Let \DefineSymbol{T} be \flatten {S}.
16774
+ Let \DefineSymbol{T} be \Flatten {S}.
16775
16775
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
16776
16776
then let \DefineSymbol{f} be $o$;
16777
16777
otherwise let $f$ be the result of creating
@@ -16792,7 +16792,7 @@ \subsection{Await Expressions}
16792
16792
If $f$ completes with an object $v$, $a$ evaluates to $v$.
16793
16793
16794
16794
\rationale{%
16795
- The use of \flattenName {} to find $T$ and hence determine the dynamic type test
16795
+ The use of \FlattenName {} to find $T$ and hence determine the dynamic type test
16796
16796
implies that we await a future in every case where this choice is sound.%
16797
16797
}
16798
16798
@@ -16808,7 +16808,7 @@ \subsection{Await Expressions}
16808
16808
However, the second kind could be a \code{Future<Object?>}.
16809
16809
This object isn't a \code{Future<Object>}, and it isn't \NULL,
16810
16810
so it \emph{must} be considered to be in the second group.
16811
- Nevertheless, \flatten {\code{FutureOr<Object>?}} is \code{Object?},
16811
+ Nevertheless, \Flatten {\code{FutureOr<Object>?}} is \code{Object?},
16812
16812
so we \emph{will} await a \code{Future<Object?>}.
16813
16813
We have chosen this semantics because it was the smallest breaking change
16814
16814
relative to the semantics in earlier versions of Dart,
@@ -19240,7 +19240,7 @@ \subsection{Return}
19240
19240
%
19241
19241
% Returning without an object is only ok for async-"voidy" return types.
19242
19242
It is a compile-time error if $s$ is \code{\RETURN;},
19243
- unless \flatten {T}
19243
+ unless \Flatten {T}
19244
19244
(\ref{functionExpressions})
19245
19245
is \VOID, \DYNAMIC, or \code{Null}.
19246
19246
%
@@ -19253,26 +19253,26 @@ \subsection{Return}
19253
19253
% Returning with an object in an void async function only ok
19254
19254
% when that value is async-"voidy".
19255
19255
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19256
- \flatten {T} is \VOID,
19257
- and \flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19256
+ \Flatten {T} is \VOID,
19257
+ and \Flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19258
19258
%
19259
19259
% Returning async-void in a "non-async-voidy" function is an error.
19260
19260
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19261
- \flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19262
- and \flatten {S} is \VOID.
19261
+ \Flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19262
+ and \Flatten {S} is \VOID.
19263
19263
%
19264
19264
% Otherwise, returning an un-deasync-assignable value is an error.
19265
19265
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19266
- \flatten {S} is not \VOID,
19267
- and \code{Future<\flatten {S}>} is not assignable to $T$.
19266
+ \Flatten {S} is not \VOID,
19267
+ and \code{Future<\Flatten {S}>} is not assignable to $T$.
19268
19268
19269
19269
\commentary{%
19270
- Note that \flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19270
+ Note that \Flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19271
19271
in the last case,
19272
19272
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
19273
19273
In particular, when $T$ is \code{FutureOr<Null>}
19274
19274
(which is equivalent to \code{Future<Null>}),
19275
- \code{Future<\flatten {S}>} is assignable to $T$ for all $S$.
19275
+ \code{Future<\Flatten {S}>} is assignable to $T$ for all $S$.
19276
19276
This means that no compile-time error is raised,
19277
19277
but \emph{only} the null object (\ref{null})
19278
19278
or an instance of \code{Future<Null>} can successfully be returned at run time.
@@ -19283,7 +19283,7 @@ \subsection{Return}
19283
19283
19284
19284
An error will not be raised if $f$ has no declared return type,
19285
19285
since the return type would be \DYNAMIC,
19286
- and \code{Future<\flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19286
+ and \code{Future<\Flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19287
19287
However, an asynchronous non-generator function
19288
19288
that declares a return type which is not ``voidy''
19289
19289
must return an expression explicitly.%
@@ -19334,7 +19334,7 @@ \subsection{Return}
19334
19334
let $T$ be the actual return type of $f$
19335
19335
(\ref{actualTypes}).
19336
19336
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19337
- and $S$ is a subtype of \code{Future<\flatten {T}>}
19337
+ and $S$ is a subtype of \code{Future<\Flatten {T}>}
19338
19338
then let $r$ be the result of evaluating \code{await $v$}
19339
19339
where $v$ is a fresh variable bound to $o$.
19340
19340
Otherwise let $r$ be $o$.
0 commit comments