@@ -2083,7 +2083,7 @@ \section{Functions}
2083
2083
that the returned object will not be used
2084
2084
(\ref{return}).%
2085
2085
}
2086
- \item The function is asynchronous, \flatten {T} is not \VOID,
2086
+ \item The function is asynchronous, \Flatten {T} is not \VOID,
2087
2087
and it would have been a compile-time error
2088
2088
to declare the function with the body
2089
2089
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11856,7 +11856,7 @@ \subsection{Function Expressions}
11856
11856
\commentary{%
11857
11857
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
11858
11858
because this will never occur
11859
- (this concept is only used in \flattenName , which is defined below).%
11859
+ (this concept is only used in \FlattenName , which is defined below).%
11860
11860
}
11861
11861
\end{itemize}
11862
11862
@@ -11913,7 +11913,7 @@ \subsection{Function Expressions}
11913
11913
11914
11914
\LMHash{}%
11915
11915
We define the auxiliary function
11916
- \IndexCustom{\flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11916
+ \IndexCustom{\Flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11917
11917
as follows, using the first applicable case:
11918
11918
11919
11919
\begin{itemize}
@@ -11923,24 +11923,24 @@ \subsection{Function Expressions}
11923
11923
11924
11924
\begin{itemize}
11925
11925
\item if $S$ derives a future type $U$
11926
- then \DefEquals{\flatten {T}}{\code{\flatten {U}}}.
11926
+ then \DefEquals{\Flatten {T}}{\code{\Flatten {U}}}.
11927
11927
\item otherwise,
11928
- \DefEquals{\flatten {T}}{\code{\flatten {X}}}.
11928
+ \DefEquals{\Flatten {T}}{\code{\Flatten {X}}}.
11929
11929
\end{itemize}
11930
11930
11931
11931
\item If $T$ derives a future type \code{Future<$S$>}
11932
11932
or \code{FutureOr<$S$>}
11933
- then \DefEquals{\flatten {T}}{S}.
11933
+ then \DefEquals{\Flatten {T}}{S}.
11934
11934
11935
11935
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11936
- \code{FutureOr<$S$>?}\ then \DefEquals{\flatten {T}}{\code{$S$?}}.
11936
+ \code{FutureOr<$S$>?}\ then \DefEquals{\Flatten {T}}{\code{$S$?}}.
11937
11937
11938
- \item Otherwise, \DefEquals{\flatten {T}}{T}.
11938
+ \item Otherwise, \DefEquals{\Flatten {T}}{T}.
11939
11939
\end{itemize}
11940
11940
11941
11941
\rationale{%
11942
11942
This definition guarantees that for any type $T$,
11943
- \code{$T <:$ FutureOr<$\flatten {T}$>}. The proof is by induction on the
11943
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}. The proof is by induction on the
11944
11944
structure of $T$:
11945
11945
11946
11946
\begin{itemize}
@@ -11949,35 +11949,35 @@ \subsection{Function Expressions}
11949
11949
\begin{itemize}
11950
11950
\item if $S$ derives a future type $U$,
11951
11951
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11952
- By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten {U}$>}.
11953
- Since \code{$\flatten {T} = \flatten {U}$} in this case, it follows that
11954
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11955
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11952
+ By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten {U}$>}.
11953
+ Since \code{$\Flatten {T} = \Flatten {U}$} in this case, it follows that
11954
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11955
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11956
11956
\item otherwise, \code{$T <: X$}.
11957
- By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten {X}$>}.
11958
- Since \code{$\flatten {T} = \flatten {X}$} in this case, it follows that
11959
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11960
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11957
+ By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten {X}$>}.
11958
+ Since \code{$\Flatten {T} = \Flatten {X}$} in this case, it follows that
11959
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11960
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11961
11961
\end{itemize}
11962
11962
11963
11963
\item If $T$ derives a future type \code{Future<$S$>}
11964
11964
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11965
- it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten {T} = S$}
11966
- in this case, it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11965
+ it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten {T} = S$}
11966
+ in this case, it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11967
11967
11968
11968
\item If $T$ derives a future type \code{Future<$S$>?} or
11969
11969
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
11970
11970
it follows that \code{$T <:$ FutureOr<$S$>?}.
11971
11971
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$
11972
11972
(this can be shown using the union type subtype rules and from
11973
11973
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11974
- \code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten {T} = S$?} in this case,
11975
- it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11974
+ \code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten {T} = S$?} in this case,
11975
+ it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11976
11976
11977
- \item Otherwise, \code{$\flatten {T} = T$}, so
11978
- \code{FutureOr<$\flatten {T}$> $=$ FutureOr<$T$>}. Since
11977
+ \item Otherwise, \code{$\Flatten {T} = T$}, so
11978
+ \code{FutureOr<$\Flatten {T}$> $=$ FutureOr<$T$>}. Since
11979
11979
\code{$T <:$ FutureOr<$T$>}, it follows that
11980
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11980
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11981
11981
\end{itemize}
11982
11982
}
11983
11983
@@ -12012,7 +12012,7 @@ \subsection{Function Expressions}
12012
12012
12013
12013
\noindent
12014
12014
is
12015
- \FunctionTypePositionalStdCr{\code{Future<\flatten {T_0}>}},
12015
+ \FunctionTypePositionalStdCr{\code{Future<\Flatten {T_0}>}},
12016
12016
12017
12017
\noindent
12018
12018
where $T_0$ is the static type of $e$.
@@ -12048,7 +12048,7 @@ \subsection{Function Expressions}
12048
12048
12049
12049
\noindent
12050
12050
is
12051
- \FunctionTypeNamedStdCr{\code{Future<\flatten {T_0}>}},
12051
+ \FunctionTypeNamedStdCr{\code{Future<\Flatten {T_0}>}},
12052
12052
12053
12053
\noindent
12054
12054
where $T_0$ is the static type of $e$.
@@ -16864,13 +16864,13 @@ \subsection{Await Expressions}
16864
16864
\BlindDefineSymbol{a, e, S}%
16865
16865
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
16866
16866
Let $S$ be the static type of $e$.
16867
- The static type of $a$ is then \flatten {S}
16867
+ The static type of $a$ is then \Flatten {S}
16868
16868
(\ref{functionExpressions}).
16869
16869
16870
16870
\LMHash{}%
16871
16871
Evaluation of $a$ proceeds as follows:
16872
16872
First, the expression $e$ is evaluated to an object $o$.
16873
- Let \DefineSymbol{T} be \flatten {S}.
16873
+ Let \DefineSymbol{T} be \Flatten {S}.
16874
16874
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
16875
16875
then let \DefineSymbol{f} be $o$;
16876
16876
otherwise let $f$ be the result of creating
@@ -16891,7 +16891,7 @@ \subsection{Await Expressions}
16891
16891
If $f$ completes with an object $v$, $a$ evaluates to $v$.
16892
16892
16893
16893
\rationale{%
16894
- The use of \flattenName {} to find $T$
16894
+ The use of \FlattenName {} to find $T$
16895
16895
and hence determine the dynamic type test
16896
16896
implies that we await a future in every case where this choice is sound.%
16897
16897
}
@@ -16908,7 +16908,7 @@ \subsection{Await Expressions}
16908
16908
However, the second kind could be a \code{Future<Object?>}.
16909
16909
This object isn't a \code{Future<Object>}, and it isn't \NULL,
16910
16910
so it \emph{must} be considered to be in the second group.
16911
- Nevertheless, \flatten {\code{FutureOr<Object>?}} is \code{Object?},
16911
+ Nevertheless, \Flatten {\code{FutureOr<Object>?}} is \code{Object?},
16912
16912
so we \emph{will} await a \code{Future<Object?>}.
16913
16913
We have chosen this semantics because it was the smallest breaking change
16914
16914
relative to the semantics in earlier versions of Dart,
@@ -19356,7 +19356,7 @@ \subsection{Return}
19356
19356
%
19357
19357
% Returning without an object is only ok for async-"voidy" return types.
19358
19358
It is a compile-time error if $s$ is \code{\RETURN;},
19359
- unless \flatten {T}
19359
+ unless \Flatten {T}
19360
19360
(\ref{functionExpressions})
19361
19361
is \VOID, \DYNAMIC, or \code{Null}.
19362
19362
%
@@ -19369,26 +19369,26 @@ \subsection{Return}
19369
19369
% Returning with an object in an void async function only ok
19370
19370
% when that value is async-"voidy".
19371
19371
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19372
- \flatten {T} is \VOID,
19373
- and \flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19372
+ \Flatten {T} is \VOID,
19373
+ and \Flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19374
19374
%
19375
19375
% Returning async-void in a "non-async-voidy" function is an error.
19376
19376
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19377
- \flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19378
- and \flatten {S} is \VOID.
19377
+ \Flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19378
+ and \Flatten {S} is \VOID.
19379
19379
%
19380
19380
% Otherwise, returning an un-deasync-assignable value is an error.
19381
19381
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19382
- \flatten {S} is not \VOID,
19383
- and \code{Future<\flatten {S}>} is not assignable to $T$.
19382
+ \Flatten {S} is not \VOID,
19383
+ and \code{Future<\Flatten {S}>} is not assignable to $T$.
19384
19384
19385
19385
\commentary{%
19386
- Note that \flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19386
+ Note that \Flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19387
19387
in the last case,
19388
19388
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
19389
19389
In particular, when $T$ is \code{FutureOr<Null>}
19390
19390
(which is equivalent to \code{Future<Null>}),
19391
- \code{Future<\flatten {S}>} is assignable to $T$ for all $S$.
19391
+ \code{Future<\Flatten {S}>} is assignable to $T$ for all $S$.
19392
19392
This means that no compile-time error is raised,
19393
19393
but \emph{only} the null object (\ref{null})
19394
19394
or an instance of \code{Future<Null>}
@@ -19400,7 +19400,7 @@ \subsection{Return}
19400
19400
19401
19401
An error will not be raised if $f$ has no declared return type,
19402
19402
since the return type would be \DYNAMIC,
19403
- and \code{Future<\flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19403
+ and \code{Future<\Flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19404
19404
However, an asynchronous non-generator function
19405
19405
that declares a return type which is not ``voidy''
19406
19406
must return an expression explicitly.%
@@ -19451,7 +19451,7 @@ \subsection{Return}
19451
19451
let $T$ be the actual return type of $f$
19452
19452
(\ref{actualTypes}).
19453
19453
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19454
- and $S$ is a subtype of \code{Future<\flatten {T}>}
19454
+ and $S$ is a subtype of \code{Future<\Flatten {T}>}
19455
19455
then let $r$ be the result of evaluating \code{await $v$}
19456
19456
where $v$ is a fresh variable bound to $o$.
19457
19457
Otherwise let $r$ be $o$.
0 commit comments