@@ -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$; \}}
@@ -11868,7 +11868,7 @@ \subsection{Function Expressions}
11868
11868
\commentary{%
11869
11869
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
11870
11870
because this will never occur
11871
- (this concept is only used in \flattenName , which is defined below).%
11871
+ (this concept is only used in \FlattenName , which is defined below).%
11872
11872
}
11873
11873
\end{itemize}
11874
11874
@@ -11925,7 +11925,7 @@ \subsection{Function Expressions}
11925
11925
11926
11926
\LMHash{}%
11927
11927
We define the auxiliary function
11928
- \IndexCustom{\flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11928
+ \IndexCustom{\Flatten {T}}{flatten(t)@\emph{flatten}$(T)$}
11929
11929
as follows, using the first applicable case:
11930
11930
11931
11931
\begin{itemize}
@@ -11935,24 +11935,24 @@ \subsection{Function Expressions}
11935
11935
11936
11936
\begin{itemize}
11937
11937
\item if $S$ derives a future type $U$
11938
- then \DefEquals{\flatten {T}}{\code{\flatten {U}}}.
11938
+ then \DefEquals{\Flatten {T}}{\code{\Flatten {U}}}.
11939
11939
\item otherwise,
11940
- \DefEquals{\flatten {T}}{\code{\flatten {X}}}.
11940
+ \DefEquals{\Flatten {T}}{\code{\Flatten {X}}}.
11941
11941
\end{itemize}
11942
11942
11943
11943
\item If $T$ derives a future type \code{Future<$S$>}
11944
11944
or \code{FutureOr<$S$>}
11945
- then \DefEquals{\flatten {T}}{S}.
11945
+ then \DefEquals{\Flatten {T}}{S}.
11946
11946
11947
11947
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11948
- \code{FutureOr<$S$>?}\ then \DefEquals{\flatten {T}}{\code{$S$?}}.
11948
+ \code{FutureOr<$S$>?}\ then \DefEquals{\Flatten {T}}{\code{$S$?}}.
11949
11949
11950
- \item Otherwise, \DefEquals{\flatten {T}}{T}.
11950
+ \item Otherwise, \DefEquals{\Flatten {T}}{T}.
11951
11951
\end{itemize}
11952
11952
11953
11953
\rationale{%
11954
11954
This definition guarantees that for any type $T$,
11955
- \code{$T <:$ FutureOr<$\flatten {T}$>}. The proof is by induction on the
11955
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}. The proof is by induction on the
11956
11956
structure of $T$:
11957
11957
11958
11958
\begin{itemize}
@@ -11961,35 +11961,35 @@ \subsection{Function Expressions}
11961
11961
\begin{itemize}
11962
11962
\item if $S$ derives a future type $U$,
11963
11963
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11964
- By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten {U}$>}.
11965
- Since \code{$\flatten {T} = \flatten {U}$} in this case, it follows that
11966
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11967
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11964
+ By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten {U}$>}.
11965
+ Since \code{$\Flatten {T} = \Flatten {U}$} in this case, it follows that
11966
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11967
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11968
11968
\item otherwise, \code{$T <: X$}.
11969
- By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten {X}$>}.
11970
- Since \code{$\flatten {T} = \flatten {X}$} in this case, it follows that
11971
- \code{$U <:$ FutureOr<$\flatten {T}$>}, and so
11972
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11969
+ By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten {X}$>}.
11970
+ Since \code{$\Flatten {T} = \Flatten {X}$} in this case, it follows that
11971
+ \code{$U <:$ FutureOr<$\Flatten {T}$>}, and so
11972
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11973
11973
\end{itemize}
11974
11974
11975
11975
\item If $T$ derives a future type \code{Future<$S$>}
11976
11976
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11977
- it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten {T} = S$}
11978
- in this case, it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11977
+ it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten {T} = S$}
11978
+ in this case, it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11979
11979
11980
11980
\item If $T$ derives a future type \code{Future<$S$>?} or
11981
11981
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
11982
11982
it follows that \code{$T <:$ FutureOr<$S$>?}.
11983
11983
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$
11984
11984
(this can be shown using the union type subtype rules and from
11985
11985
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11986
- \code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten {T} = S$?} in this case,
11987
- it follows that \code{$T <:$ FutureOr<$\flatten {T}$>}.
11986
+ \code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten {T} = S$?} in this case,
11987
+ it follows that \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11988
11988
11989
- \item Otherwise, \code{$\flatten {T} = T$}, so
11990
- \code{FutureOr<$\flatten {T}$> $=$ FutureOr<$T$>}. Since
11989
+ \item Otherwise, \code{$\Flatten {T} = T$}, so
11990
+ \code{FutureOr<$\Flatten {T}$> $=$ FutureOr<$T$>}. Since
11991
11991
\code{$T <:$ FutureOr<$T$>}, it follows that
11992
- \code{$T <:$ FutureOr<$\flatten {T}$>}.
11992
+ \code{$T <:$ FutureOr<$\Flatten {T}$>}.
11993
11993
\end{itemize}
11994
11994
}
11995
11995
@@ -12024,7 +12024,7 @@ \subsection{Function Expressions}
12024
12024
12025
12025
\noindent
12026
12026
is
12027
- \FunctionTypePositionalStdCr{\code{Future<\flatten {T_0}>}},
12027
+ \FunctionTypePositionalStdCr{\code{Future<\Flatten {T_0}>}},
12028
12028
12029
12029
\noindent
12030
12030
where $T_0$ is the static type of $e$.
@@ -12060,7 +12060,7 @@ \subsection{Function Expressions}
12060
12060
12061
12061
\noindent
12062
12062
is
12063
- \FunctionTypeNamedStdCr{\code{Future<\flatten {T_0}>}},
12063
+ \FunctionTypeNamedStdCr{\code{Future<\Flatten {T_0}>}},
12064
12064
12065
12065
\noindent
12066
12066
where $T_0$ is the static type of $e$.
@@ -16876,13 +16876,13 @@ \subsection{Await Expressions}
16876
16876
\BlindDefineSymbol{a, e, S}%
16877
16877
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
16878
16878
Let $S$ be the static type of $e$.
16879
- The static type of $a$ is then \flatten {S}
16879
+ The static type of $a$ is then \Flatten {S}
16880
16880
(\ref{functionExpressions}).
16881
16881
16882
16882
\LMHash{}%
16883
16883
Evaluation of $a$ proceeds as follows:
16884
16884
First, the expression $e$ is evaluated to an object $o$.
16885
- Let \DefineSymbol{T} be \flatten {S}.
16885
+ Let \DefineSymbol{T} be \Flatten {S}.
16886
16886
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
16887
16887
then let \DefineSymbol{f} be $o$;
16888
16888
otherwise let $f$ be the result of creating
@@ -16903,7 +16903,7 @@ \subsection{Await Expressions}
16903
16903
If $f$ completes with an object $v$, $a$ evaluates to $v$.
16904
16904
16905
16905
\rationale{%
16906
- The use of \flattenName {} to find $T$
16906
+ The use of \FlattenName {} to find $T$
16907
16907
and hence determine the dynamic type test
16908
16908
implies that we await a future in every case where this choice is sound.%
16909
16909
}
@@ -16920,7 +16920,7 @@ \subsection{Await Expressions}
16920
16920
However, the second kind could be a \code{Future<Object?>}.
16921
16921
This object isn't a \code{Future<Object>}, and it isn't \NULL,
16922
16922
so it \emph{must} be considered to be in the second group.
16923
- Nevertheless, \flatten {\code{FutureOr<Object>?}} is \code{Object?},
16923
+ Nevertheless, \Flatten {\code{FutureOr<Object>?}} is \code{Object?},
16924
16924
so we \emph{will} await a \code{Future<Object?>}.
16925
16925
We have chosen this semantics because it was the smallest breaking change
16926
16926
relative to the semantics in earlier versions of Dart,
@@ -19368,7 +19368,7 @@ \subsection{Return}
19368
19368
%
19369
19369
% Returning without an object is only ok for async-"voidy" return types.
19370
19370
It is a compile-time error if $s$ is \code{\RETURN;},
19371
- unless \flatten {T}
19371
+ unless \Flatten {T}
19372
19372
(\ref{functionExpressions})
19373
19373
is \VOID, \DYNAMIC, or \code{Null}.
19374
19374
%
@@ -19381,26 +19381,26 @@ \subsection{Return}
19381
19381
% Returning with an object in an void async function only ok
19382
19382
% when that value is async-"voidy".
19383
19383
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19384
- \flatten {T} is \VOID,
19385
- and \flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19384
+ \Flatten {T} is \VOID,
19385
+ and \Flatten {S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19386
19386
%
19387
19387
% Returning async-void in a "non-async-voidy" function is an error.
19388
19388
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19389
- \flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19390
- and \flatten {S} is \VOID.
19389
+ \Flatten {T} is neither \VOID, \DYNAMIC, nor \code{Null},
19390
+ and \Flatten {S} is \VOID.
19391
19391
%
19392
19392
% Otherwise, returning an un-deasync-assignable value is an error.
19393
19393
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19394
- \flatten {S} is not \VOID,
19395
- and \code{Future<\flatten {S}>} is not assignable to $T$.
19394
+ \Flatten {S} is not \VOID,
19395
+ and \code{Future<\Flatten {S}>} is not assignable to $T$.
19396
19396
19397
19397
\commentary{%
19398
- Note that \flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19398
+ Note that \Flatten {T} cannot be \VOID, \DYNAMIC, or \code{Null}
19399
19399
in the last case,
19400
19400
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
19401
19401
In particular, when $T$ is \code{FutureOr<Null>}
19402
19402
(which is equivalent to \code{Future<Null>}),
19403
- \code{Future<\flatten {S}>} is assignable to $T$ for all $S$.
19403
+ \code{Future<\Flatten {S}>} is assignable to $T$ for all $S$.
19404
19404
This means that no compile-time error is raised,
19405
19405
but \emph{only} the null object (\ref{null})
19406
19406
or an instance of \code{Future<Null>}
@@ -19412,7 +19412,7 @@ \subsection{Return}
19412
19412
19413
19413
An error will not be raised if $f$ has no declared return type,
19414
19414
since the return type would be \DYNAMIC,
19415
- and \code{Future<\flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19415
+ and \code{Future<\Flatten {S}>} is assignable to \DYNAMIC{} for all $S$.
19416
19416
However, an asynchronous non-generator function
19417
19417
that declares a return type which is not ``voidy''
19418
19418
must return an expression explicitly.%
@@ -19463,7 +19463,7 @@ \subsection{Return}
19463
19463
let $T$ be the actual return type of $f$
19464
19464
(\ref{actualTypes}).
19465
19465
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19466
- and $S$ is a subtype of \code{Future<\flatten {T}>}
19466
+ and $S$ is a subtype of \code{Future<\Flatten {T}>}
19467
19467
then let $r$ be the result of evaluating \code{await $v$}
19468
19468
where $v$ is a fresh variable bound to $o$.
19469
19469
Otherwise let $r$ be $o$.
0 commit comments