Skip to content

Commit cd3bb4f

Browse files
committed
Update command \flatten to \Flatten
1 parent 2e6a891 commit cd3bb4f

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

specification/dartLangSpec.tex

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,7 @@ \section{Functions}
20752075
that the returned object will not be used
20762076
(\ref{return}).%
20772077
}
2078-
\item The function is asynchronous, \flatten{T} is not \VOID,
2078+
\item The function is asynchronous, \Flatten{T} is not \VOID,
20792079
and it would have been a compile-time error
20802080
to declare the function with the body
20812081
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11842,7 +11842,7 @@ \subsection{Function Expressions}
1184211842
\commentary{%
1184311843
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
1184411844
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).%
1184611846
}
1184711847
\end{itemize}
1184811848

@@ -11899,7 +11899,7 @@ \subsection{Function Expressions}
1189911899

1190011900
\LMHash{}%
1190111901
We define the auxiliary function
11902-
\IndexCustom{\flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
11902+
\IndexCustom{\Flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
1190311903
as follows, using the first applicable case:
1190411904

1190511905
\begin{itemize}
@@ -11909,24 +11909,24 @@ \subsection{Function Expressions}
1190911909

1191011910
\begin{itemize}
1191111911
\item if $S$ derives a future type $U$
11912-
then \DefEquals{\flatten{T}}{\code{\flatten{U}}}.
11912+
then \DefEquals{\Flatten{T}}{\code{\Flatten{U}}}.
1191311913
\item otherwise,
11914-
\DefEquals{\flatten{T}}{\code{\flatten{X}}}.
11914+
\DefEquals{\Flatten{T}}{\code{\Flatten{X}}}.
1191511915
\end{itemize}
1191611916

1191711917
\item If $T$ derives a future type \code{Future<$S$>}
1191811918
or \code{FutureOr<$S$>}
11919-
then \DefEquals{\flatten{T}}{S}.
11919+
then \DefEquals{\Flatten{T}}{S}.
1192011920

1192111921
\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$?}}.
1192311923

11924-
\item Otherwise, \DefEquals{\flatten{T}}{T}.
11924+
\item Otherwise, \DefEquals{\Flatten{T}}{T}.
1192511925
\end{itemize}
1192611926

1192711927
\rationale{%
1192811928
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
1193011930
structure of $T$:
1193111931

1193211932
\begin{itemize}
@@ -11935,35 +11935,35 @@ \subsection{Function Expressions}
1193511935
\begin{itemize}
1193611936
\item if $S$ derives a future type $U$,
1193711937
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}$>}.
1194211942
\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}$>}.
1194711947
\end{itemize}
1194811948

1194911949
\item If $T$ derives a future type \code{Future<$S$>}
1195011950
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}$>}.
1195311953

1195411954
\item If $T$ derives a future type \code{Future<$S$>?} or
1195511955
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
1195611956
it follows that \code{$T <:$ FutureOr<$S$>?}.
1195711957
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$
1195811958
(this can be shown using the union type subtype rules and from
1195911959
\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}$>}.
1196211962

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
1196511965
\code{$T <:$ FutureOr<$T$>}, it follows that
11966-
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11966+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1196711967
\end{itemize}
1196811968
}
1196911969

@@ -11998,7 +11998,7 @@ \subsection{Function Expressions}
1199811998

1199911999
\noindent
1200012000
is
12001-
\FunctionTypePositionalStdCr{\code{Future<\flatten{T_0}>}},
12001+
\FunctionTypePositionalStdCr{\code{Future<\Flatten{T_0}>}},
1200212002

1200312003
\noindent
1200412004
where $T_0$ is the static type of $e$.
@@ -12034,7 +12034,7 @@ \subsection{Function Expressions}
1203412034

1203512035
\noindent
1203612036
is
12037-
\FunctionTypeNamedStdCr{\code{Future<\flatten{T_0}>}},
12037+
\FunctionTypeNamedStdCr{\code{Future<\Flatten{T_0}>}},
1203812038

1203912039
\noindent
1204012040
where $T_0$ is the static type of $e$.
@@ -16850,13 +16850,13 @@ \subsection{Await Expressions}
1685016850
\BlindDefineSymbol{a, e, S}%
1685116851
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
1685216852
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}
1685416854
(\ref{functionExpressions}).
1685516855

1685616856
\LMHash{}%
1685716857
Evaluation of $a$ proceeds as follows:
1685816858
First, the expression $e$ is evaluated to an object $o$.
16859-
Let \DefineSymbol{T} be \flatten{S}.
16859+
Let \DefineSymbol{T} be \Flatten{S}.
1686016860
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
1686116861
then let \DefineSymbol{f} be $o$;
1686216862
otherwise let $f$ be the result of creating
@@ -16877,7 +16877,7 @@ \subsection{Await Expressions}
1687716877
If $f$ completes with an object $v$, $a$ evaluates to $v$.
1687816878

1687916879
\rationale{%
16880-
The use of \flattenName{} to find $T$
16880+
The use of \FlattenName{} to find $T$
1688116881
and hence determine the dynamic type test
1688216882
implies that we await a future in every case where this choice is sound.%
1688316883
}
@@ -16894,7 +16894,7 @@ \subsection{Await Expressions}
1689416894
However, the second kind could be a \code{Future<Object?>}.
1689516895
This object isn't a \code{Future<Object>}, and it isn't \NULL,
1689616896
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?},
1689816898
so we \emph{will} await a \code{Future<Object?>}.
1689916899
We have chosen this semantics because it was the smallest breaking change
1690016900
relative to the semantics in earlier versions of Dart,
@@ -19342,7 +19342,7 @@ \subsection{Return}
1934219342
%
1934319343
% Returning without an object is only ok for async-"voidy" return types.
1934419344
It is a compile-time error if $s$ is \code{\RETURN;},
19345-
unless \flatten{T}
19345+
unless \Flatten{T}
1934619346
(\ref{functionExpressions})
1934719347
is \VOID, \DYNAMIC, or \code{Null}.
1934819348
%
@@ -19355,26 +19355,26 @@ \subsection{Return}
1935519355
% Returning with an object in an void async function only ok
1935619356
% when that value is async-"voidy".
1935719357
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}.
1936019360
%
1936119361
% Returning async-void in a "non-async-voidy" function is an error.
1936219362
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.
1936519365
%
1936619366
% Otherwise, returning an un-deasync-assignable value is an error.
1936719367
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$.
1937019370

1937119371
\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}
1937319373
in the last case,
1937419374
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
1937519375
In particular, when $T$ is \code{FutureOr<Null>}
1937619376
(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$.
1937819378
This means that no compile-time error is raised,
1937919379
but \emph{only} the null object (\ref{null})
1938019380
or an instance of \code{Future<Null>}
@@ -19386,7 +19386,7 @@ \subsection{Return}
1938619386

1938719387
An error will not be raised if $f$ has no declared return type,
1938819388
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$.
1939019390
However, an asynchronous non-generator function
1939119391
that declares a return type which is not ``voidy''
1939219392
must return an expression explicitly.%
@@ -19437,7 +19437,7 @@ \subsection{Return}
1943719437
let $T$ be the actual return type of $f$
1943819438
(\ref{actualTypes}).
1943919439
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}>}
1944119441
then let $r$ be the result of evaluating \code{await $v$}
1944219442
where $v$ is a fresh variable bound to $o$.
1944319443
Otherwise let $r$ be $o$.

0 commit comments

Comments
 (0)