Skip to content

Commit 5263fa2

Browse files
committed
Update command \flatten to \Flatten
1 parent bdad5d4 commit 5263fa2

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

specification/dartLangSpec.tex

+41-41
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ \section{Functions}
20582058
that the returned object will not be used
20592059
(\ref{return}).%
20602060
}
2061-
\item The function is asynchronous, \flatten{T} is not \VOID,
2061+
\item The function is asynchronous, \Flatten{T} is not \VOID,
20622062
and it would have been a compile-time error
20632063
to declare the function with the body
20642064
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11789,7 +11789,7 @@ \subsection{Function Expressions}
1178911789
\commentary{%
1179011790
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
1179111791
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).%
1179311793
}
1179411794
\end{itemize}
1179511795

@@ -11844,7 +11844,7 @@ \subsection{Function Expressions}
1184411844

1184511845
\LMHash{}%
1184611846
We define the auxiliary function
11847-
\IndexCustom{\flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
11847+
\IndexCustom{\Flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
1184811848
as follows, using the first applicable case:
1184911849

1185011850
\begin{itemize}
@@ -11853,60 +11853,60 @@ \subsection{Function Expressions}
1185311853
for some type variable $X$ and type $S$ then
1185411854
\begin{itemize}
1185511855
\item if $S$ derives a future type $U$
11856-
then \DefEquals{\flatten{T}}{\code{\flatten{U}}}.
11856+
then \DefEquals{\Flatten{T}}{\code{\Flatten{U}}}.
1185711857
\item otherwise,
11858-
\DefEquals{\flatten{T}}{\code{\flatten{X}}}.
11858+
\DefEquals{\Flatten{T}}{\code{\Flatten{X}}}.
1185911859
\end{itemize}
1186011860

1186111861
\item If $T$ derives a future type \code{Future<$S$>}
1186211862
or \code{FutureOr<$S$>}
11863-
then \DefEquals{\flatten{T}}{S}.
11863+
then \DefEquals{\Flatten{T}}{S}.
1186411864

1186511865
\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$?}}.
1186711867

11868-
\item Otherwise, \DefEquals{\flatten{T}}{T}.
11868+
\item Otherwise, \DefEquals{\Flatten{T}}{T}.
1186911869
\end{itemize}
1187011870

1187111871
\rationale{%
1187211872
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
1187411874
structure of $T$:
1187511875

1187611876
\begin{itemize}
1187711877
\item If $T$ is \code{$X$\,\&\,$S$} then
1187811878
\begin{itemize}
1187911879
\item if $S$ derives a future type $U$,
1188011880
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}$>}.
1188511885
\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}$>}.
1189011890
\end{itemize}
1189111891

1189211892
\item If $T$ derives a future type \code{Future<$S$>}
1189311893
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}$>}.
1189611896

1189711897
\item If $T$ derives a future type \code{Future<$S$>?} or
1189811898
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
1189911899
it follows that \code{$T <:$ FutureOr<$S$>?}.
1190011900
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$ (this can be shown
1190111901
using the union type subtype rules and from
1190211902
\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}$>}.
1190511905

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
1190811908
\code{$T <:$ FutureOr<$T$>}, it follows that
11909-
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11909+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1191011910
\end{itemize}
1191111911
}
1191211912

@@ -11941,7 +11941,7 @@ \subsection{Function Expressions}
1194111941

1194211942
\noindent
1194311943
is
11944-
\FunctionTypePositionalStdCr{\code{Future<\flatten{T_0}>}},
11944+
\FunctionTypePositionalStdCr{\code{Future<\Flatten{T_0}>}},
1194511945

1194611946
\noindent
1194711947
where $T_0$ is the static type of $e$.
@@ -11977,7 +11977,7 @@ \subsection{Function Expressions}
1197711977

1197811978
\noindent
1197911979
is
11980-
\FunctionTypeNamedStdCr{\code{Future<\flatten{T_0}>}},
11980+
\FunctionTypeNamedStdCr{\code{Future<\Flatten{T_0}>}},
1198111981

1198211982
\noindent
1198311983
where $T_0$ is the static type of $e$.
@@ -16765,13 +16765,13 @@ \subsection{Await Expressions}
1676516765
\BlindDefineSymbol{a, e, S}%
1676616766
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
1676716767
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}
1676916769
(\ref{functionExpressions}).
1677016770

1677116771
\LMHash{}%
1677216772
Evaluation of $a$ proceeds as follows:
1677316773
First, the expression $e$ is evaluated to an object $o$.
16774-
Let \DefineSymbol{T} be \flatten{S}.
16774+
Let \DefineSymbol{T} be \Flatten{S}.
1677516775
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
1677616776
then let \DefineSymbol{f} be $o$;
1677716777
otherwise let $f$ be the result of creating
@@ -16792,7 +16792,7 @@ \subsection{Await Expressions}
1679216792
If $f$ completes with an object $v$, $a$ evaluates to $v$.
1679316793

1679416794
\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
1679616796
implies that we await a future in every case where this choice is sound.%
1679716797
}
1679816798

@@ -16808,7 +16808,7 @@ \subsection{Await Expressions}
1680816808
However, the second kind could be a \code{Future<Object?>}.
1680916809
This object isn't a \code{Future<Object>}, and it isn't \NULL,
1681016810
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?},
1681216812
so we \emph{will} await a \code{Future<Object?>}.
1681316813
We have chosen this semantics because it was the smallest breaking change
1681416814
relative to the semantics in earlier versions of Dart,
@@ -19240,7 +19240,7 @@ \subsection{Return}
1924019240
%
1924119241
% Returning without an object is only ok for async-"voidy" return types.
1924219242
It is a compile-time error if $s$ is \code{\RETURN;},
19243-
unless \flatten{T}
19243+
unless \Flatten{T}
1924419244
(\ref{functionExpressions})
1924519245
is \VOID, \DYNAMIC, or \code{Null}.
1924619246
%
@@ -19253,26 +19253,26 @@ \subsection{Return}
1925319253
% Returning with an object in an void async function only ok
1925419254
% when that value is async-"voidy".
1925519255
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}.
1925819258
%
1925919259
% Returning async-void in a "non-async-voidy" function is an error.
1926019260
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.
1926319263
%
1926419264
% Otherwise, returning an un-deasync-assignable value is an error.
1926519265
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$.
1926819268

1926919269
\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}
1927119271
in the last case,
1927219272
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
1927319273
In particular, when $T$ is \code{FutureOr<Null>}
1927419274
(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$.
1927619276
This means that no compile-time error is raised,
1927719277
but \emph{only} the null object (\ref{null})
1927819278
or an instance of \code{Future<Null>} can successfully be returned at run time.
@@ -19283,7 +19283,7 @@ \subsection{Return}
1928319283

1928419284
An error will not be raised if $f$ has no declared return type,
1928519285
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$.
1928719287
However, an asynchronous non-generator function
1928819288
that declares a return type which is not ``voidy''
1928919289
must return an expression explicitly.%
@@ -19334,7 +19334,7 @@ \subsection{Return}
1933419334
let $T$ be the actual return type of $f$
1933519335
(\ref{actualTypes}).
1933619336
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}>}
1933819338
then let $r$ be the result of evaluating \code{await $v$}
1933919339
where $v$ is a fresh variable bound to $o$.
1934019340
Otherwise let $r$ be $o$.

0 commit comments

Comments
 (0)