Skip to content

Commit df32654

Browse files
committed
Update command \flatten to \Flatten
1 parent 656622d commit df32654

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
@@ -2087,7 +2087,7 @@ \section{Functions}
20872087
that the returned object will not be used
20882088
(\ref{return}).%
20892089
}
2090-
\item The function is asynchronous, \flatten{T} is not \VOID,
2090+
\item The function is asynchronous, \Flatten{T} is not \VOID,
20912091
and it would have been a compile-time error
20922092
to declare the function with the body
20932093
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11872,7 +11872,7 @@ \subsection{Function Expressions}
1187211872
\commentary{%
1187311873
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
1187411874
because this will never occur
11875-
(this concept is only used in \flattenName, which is defined below).%
11875+
(this concept is only used in \FlattenName, which is defined below).%
1187611876
}
1187711877
\end{itemize}
1187811878

@@ -11929,7 +11929,7 @@ \subsection{Function Expressions}
1192911929

1193011930
\LMHash{}%
1193111931
We define the auxiliary function
11932-
\IndexCustom{\flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
11932+
\IndexCustom{\Flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
1193311933
as follows, using the first applicable case:
1193411934

1193511935
\begin{itemize}
@@ -11939,24 +11939,24 @@ \subsection{Function Expressions}
1193911939

1194011940
\begin{itemize}
1194111941
\item if $S$ derives a future type $U$
11942-
then \DefEquals{\flatten{T}}{\code{\flatten{U}}}.
11942+
then \DefEquals{\Flatten{T}}{\code{\Flatten{U}}}.
1194311943
\item otherwise,
11944-
\DefEquals{\flatten{T}}{\code{\flatten{X}}}.
11944+
\DefEquals{\Flatten{T}}{\code{\Flatten{X}}}.
1194511945
\end{itemize}
1194611946

1194711947
\item If $T$ derives a future type \code{Future<$S$>}
1194811948
or \code{FutureOr<$S$>}
11949-
then \DefEquals{\flatten{T}}{S}.
11949+
then \DefEquals{\Flatten{T}}{S}.
1195011950

1195111951
\item If $T$ derives a future type \code{Future<$S$>?}\ or
11952-
\code{FutureOr<$S$>?}\ then \DefEquals{\flatten{T}}{\code{$S$?}}.
11952+
\code{FutureOr<$S$>?}\ then \DefEquals{\Flatten{T}}{\code{$S$?}}.
1195311953

11954-
\item Otherwise, \DefEquals{\flatten{T}}{T}.
11954+
\item Otherwise, \DefEquals{\Flatten{T}}{T}.
1195511955
\end{itemize}
1195611956

1195711957
\rationale{%
1195811958
This definition guarantees that for any type $T$,
11959-
\code{$T <:$ FutureOr<$\flatten{T}$>}. The proof is by induction on the
11959+
\code{$T <:$ FutureOr<$\Flatten{T}$>}. The proof is by induction on the
1196011960
structure of $T$:
1196111961

1196211962
\begin{itemize}
@@ -11965,35 +11965,35 @@ \subsection{Function Expressions}
1196511965
\begin{itemize}
1196611966
\item if $S$ derives a future type $U$,
1196711967
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11968-
By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten{U}$>}.
11969-
Since \code{$\flatten{T} = \flatten{U}$} in this case, it follows that
11970-
\code{$U <:$ FutureOr<$\flatten{T}$>}, and so
11971-
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11968+
By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten{U}$>}.
11969+
Since \code{$\Flatten{T} = \Flatten{U}$} in this case, it follows that
11970+
\code{$U <:$ FutureOr<$\Flatten{T}$>}, and so
11971+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1197211972
\item otherwise, \code{$T <: X$}.
11973-
By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten{X}$>}.
11974-
Since \code{$\flatten{T} = \flatten{X}$} in this case, it follows that
11975-
\code{$U <:$ FutureOr<$\flatten{T}$>}, and so
11976-
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11973+
By the induction hypothesis, \code{$X <:$ FutureOr<$\Flatten{X}$>}.
11974+
Since \code{$\Flatten{T} = \Flatten{X}$} in this case, it follows that
11975+
\code{$U <:$ FutureOr<$\Flatten{T}$>}, and so
11976+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1197711977
\end{itemize}
1197811978

1197911979
\item If $T$ derives a future type \code{Future<$S$>}
1198011980
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11981-
it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten{T} = S$}
11982-
in this case, it follows that \code{$T <:$ FutureOr<$\flatten{T}$>}.
11981+
it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten{T} = S$}
11982+
in this case, it follows that \code{$T <:$ FutureOr<$\Flatten{T}$>}.
1198311983

1198411984
\item If $T$ derives a future type \code{Future<$S$>?} or
1198511985
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
1198611986
it follows that \code{$T <:$ FutureOr<$S$>?}.
1198711987
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$
1198811988
(this can be shown using the union type subtype rules and from
1198911989
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11990-
\code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten{T} = S$?} in this case,
11991-
it follows that \code{$T <:$ FutureOr<$\flatten{T}$>}.
11990+
\code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten{T} = S$?} in this case,
11991+
it follows that \code{$T <:$ FutureOr<$\Flatten{T}$>}.
1199211992

11993-
\item Otherwise, \code{$\flatten{T} = T$}, so
11994-
\code{FutureOr<$\flatten{T}$> $=$ FutureOr<$T$>}. Since
11993+
\item Otherwise, \code{$\Flatten{T} = T$}, so
11994+
\code{FutureOr<$\Flatten{T}$> $=$ FutureOr<$T$>}. Since
1199511995
\code{$T <:$ FutureOr<$T$>}, it follows that
11996-
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11996+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1199711997
\end{itemize}
1199811998
}
1199911999

@@ -12028,7 +12028,7 @@ \subsection{Function Expressions}
1202812028

1202912029
\noindent
1203012030
is
12031-
\FunctionTypePositionalStdCr{\code{Future<\flatten{T_0}>}},
12031+
\FunctionTypePositionalStdCr{\code{Future<\Flatten{T_0}>}},
1203212032

1203312033
\noindent
1203412034
where $T_0$ is the static type of $e$.
@@ -12064,7 +12064,7 @@ \subsection{Function Expressions}
1206412064

1206512065
\noindent
1206612066
is
12067-
\FunctionTypeNamedStdCr{\code{Future<\flatten{T_0}>}},
12067+
\FunctionTypeNamedStdCr{\code{Future<\Flatten{T_0}>}},
1206812068

1206912069
\noindent
1207012070
where $T_0$ is the static type of $e$.
@@ -16880,13 +16880,13 @@ \subsection{Await Expressions}
1688016880
\BlindDefineSymbol{a, e, S}%
1688116881
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
1688216882
Let $S$ be the static type of $e$.
16883-
The static type of $a$ is then \flatten{S}
16883+
The static type of $a$ is then \Flatten{S}
1688416884
(\ref{functionExpressions}).
1688516885

1688616886
\LMHash{}%
1688716887
Evaluation of $a$ proceeds as follows:
1688816888
First, the expression $e$ is evaluated to an object $o$.
16889-
Let \DefineSymbol{T} be \flatten{S}.
16889+
Let \DefineSymbol{T} be \Flatten{S}.
1689016890
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
1689116891
then let \DefineSymbol{f} be $o$;
1689216892
otherwise let $f$ be the result of creating
@@ -16907,7 +16907,7 @@ \subsection{Await Expressions}
1690716907
If $f$ completes with an object $v$, $a$ evaluates to $v$.
1690816908

1690916909
\rationale{%
16910-
The use of \flattenName{} to find $T$
16910+
The use of \FlattenName{} to find $T$
1691116911
and hence determine the dynamic type test
1691216912
implies that we await a future in every case where this choice is sound.%
1691316913
}
@@ -16924,7 +16924,7 @@ \subsection{Await Expressions}
1692416924
However, the second kind could be a \code{Future<Object?>}.
1692516925
This object isn't a \code{Future<Object>}, and it isn't \NULL,
1692616926
so it \emph{must} be considered to be in the second group.
16927-
Nevertheless, \flatten{\code{FutureOr<Object>?}} is \code{Object?},
16927+
Nevertheless, \Flatten{\code{FutureOr<Object>?}} is \code{Object?},
1692816928
so we \emph{will} await a \code{Future<Object?>}.
1692916929
We have chosen this semantics because it was the smallest breaking change
1693016930
relative to the semantics in earlier versions of Dart,
@@ -19372,7 +19372,7 @@ \subsection{Return}
1937219372
%
1937319373
% Returning without an object is only ok for async-"voidy" return types.
1937419374
It is a compile-time error if $s$ is \code{\RETURN;},
19375-
unless \flatten{T}
19375+
unless \Flatten{T}
1937619376
(\ref{functionExpressions})
1937719377
is \VOID, \DYNAMIC, or \code{Null}.
1937819378
%
@@ -19385,26 +19385,26 @@ \subsection{Return}
1938519385
% Returning with an object in an void async function only ok
1938619386
% when that value is async-"voidy".
1938719387
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19388-
\flatten{T} is \VOID,
19389-
and \flatten{S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19388+
\Flatten{T} is \VOID,
19389+
and \Flatten{S} is neither \VOID, \DYNAMIC, nor \code{Null}.
1939019390
%
1939119391
% Returning async-void in a "non-async-voidy" function is an error.
1939219392
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19393-
\flatten{T} is neither \VOID, \DYNAMIC, nor \code{Null},
19394-
and \flatten{S} is \VOID.
19393+
\Flatten{T} is neither \VOID, \DYNAMIC, nor \code{Null},
19394+
and \Flatten{S} is \VOID.
1939519395
%
1939619396
% Otherwise, returning an un-deasync-assignable value is an error.
1939719397
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19398-
\flatten{S} is not \VOID,
19399-
and \code{Future<\flatten{S}>} is not assignable to $T$.
19398+
\Flatten{S} is not \VOID,
19399+
and \code{Future<\Flatten{S}>} is not assignable to $T$.
1940019400

1940119401
\commentary{%
19402-
Note that \flatten{T} cannot be \VOID, \DYNAMIC, or \code{Null}
19402+
Note that \Flatten{T} cannot be \VOID, \DYNAMIC, or \code{Null}
1940319403
in the last case,
1940419404
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
1940519405
In particular, when $T$ is \code{FutureOr<Null>}
1940619406
(which is equivalent to \code{Future<Null>}),
19407-
\code{Future<\flatten{S}>} is assignable to $T$ for all $S$.
19407+
\code{Future<\Flatten{S}>} is assignable to $T$ for all $S$.
1940819408
This means that no compile-time error is raised,
1940919409
but \emph{only} the null object (\ref{null})
1941019410
or an instance of \code{Future<Null>}
@@ -19416,7 +19416,7 @@ \subsection{Return}
1941619416

1941719417
An error will not be raised if $f$ has no declared return type,
1941819418
since the return type would be \DYNAMIC,
19419-
and \code{Future<\flatten{S}>} is assignable to \DYNAMIC{} for all $S$.
19419+
and \code{Future<\Flatten{S}>} is assignable to \DYNAMIC{} for all $S$.
1942019420
However, an asynchronous non-generator function
1942119421
that declares a return type which is not ``voidy''
1942219422
must return an expression explicitly.%
@@ -19467,7 +19467,7 @@ \subsection{Return}
1946719467
let $T$ be the actual return type of $f$
1946819468
(\ref{actualTypes}).
1946919469
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19470-
and $S$ is a subtype of \code{Future<\flatten{T}>}
19470+
and $S$ is a subtype of \code{Future<\Flatten{T}>}
1947119471
then let $r$ be the result of evaluating \code{await $v$}
1947219472
where $v$ is a fresh variable bound to $o$.
1947319473
Otherwise let $r$ be $o$.

0 commit comments

Comments
 (0)