Skip to content

Commit 430eaf5

Browse files
committed
Update command \flatten to \Flatten
1 parent 51aee29 commit 430eaf5

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
@@ -2053,7 +2053,7 @@ \section{Functions}
20532053
that the returned object will not be used
20542054
(\ref{return}).%
20552055
}
2056-
\item The function is asynchronous, \flatten{T} is not \VOID,
2056+
\item The function is asynchronous, \Flatten{T} is not \VOID,
20572057
and it would have been a compile-time error
20582058
to declare the function with the body
20592059
\code{\ASYNC{} \{ \RETURN{} $e$; \}}
@@ -11784,7 +11784,7 @@ \subsection{Function Expressions}
1178411784
\commentary{%
1178511785
There is no rule for the case where $T$ is of the form \code{$X$\,\&\,$S$}
1178611786
because this will never occur
11787-
(this concept is only used in \flattenName, which is defined below).%
11787+
(this concept is only used in \FlattenName, which is defined below).%
1178811788
}
1178911789
\end{itemize}
1179011790

@@ -11839,7 +11839,7 @@ \subsection{Function Expressions}
1183911839

1184011840
\LMHash{}%
1184111841
We define the auxiliary function
11842-
\IndexCustom{\flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
11842+
\IndexCustom{\Flatten{T}}{flatten(t)@\emph{flatten}$(T)$}
1184311843
as follows, using the first applicable case:
1184411844

1184511845
\begin{itemize}
@@ -11848,60 +11848,60 @@ \subsection{Function Expressions}
1184811848
for some type variable $X$ and type $S$ then
1184911849
\begin{itemize}
1185011850
\item if $S$ derives a future type $U$
11851-
then \DefEquals{\flatten{T}}{\code{\flatten{U}}}.
11851+
then \DefEquals{\Flatten{T}}{\code{\Flatten{U}}}.
1185211852
\item otherwise,
11853-
\DefEquals{\flatten{T}}{\code{\flatten{X}}}.
11853+
\DefEquals{\Flatten{T}}{\code{\Flatten{X}}}.
1185411854
\end{itemize}
1185511855

1185611856
\item If $T$ derives a future type \code{Future<$S$>}
1185711857
or \code{FutureOr<$S$>}
11858-
then \DefEquals{\flatten{T}}{S}.
11858+
then \DefEquals{\Flatten{T}}{S}.
1185911859

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

11863-
\item Otherwise, \DefEquals{\flatten{T}}{T}.
11863+
\item Otherwise, \DefEquals{\Flatten{T}}{T}.
1186411864
\end{itemize}
1186511865

1186611866
\rationale{%
1186711867
This definition guarantees that for any type $T$,
11868-
\code{$T <:$ FutureOr<$\flatten{T}$>}. The proof is by induction on the
11868+
\code{$T <:$ FutureOr<$\Flatten{T}$>}. The proof is by induction on the
1186911869
structure of $T$:
1187011870

1187111871
\begin{itemize}
1187211872
\item If $T$ is \code{$X$\,\&\,$S$} then
1187311873
\begin{itemize}
1187411874
\item if $S$ derives a future type $U$,
1187511875
then \code{$T <: S$} and \code{$S <: U$}, so \code{$T <: U$}.
11876-
By the induction hypothesis, \code{$U <:$ FutureOr<$\flatten{U}$>}.
11877-
Since \code{$\flatten{T} = \flatten{U}$} in this case, it follows that
11878-
\code{$U <:$ FutureOr<$\flatten{T}$>}, and so
11879-
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11876+
By the induction hypothesis, \code{$U <:$ FutureOr<$\Flatten{U}$>}.
11877+
Since \code{$\Flatten{T} = \Flatten{U}$} in this case, it follows that
11878+
\code{$U <:$ FutureOr<$\Flatten{T}$>}, and so
11879+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1188011880
\item otherwise, \code{$T <: X$}.
11881-
By the induction hypothesis, \code{$X <:$ FutureOr<$\flatten{X}$>}.
11882-
Since \code{$\flatten{T} = \flatten{X}$} 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{$X <:$ FutureOr<$\Flatten{X}$>}.
11882+
Since \code{$\Flatten{T} = \Flatten{X}$} in this case, it follows that
11883+
\code{$U <:$ FutureOr<$\Flatten{T}$>}, and so
11884+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1188511885
\end{itemize}
1188611886

1188711887
\item If $T$ derives a future type \code{Future<$S$>}
1188811888
or \code{FutureOr<$S$>}, then, since \code{Future<$S$> $<:$ FutureOr<$S$>},
11889-
it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\flatten{T} = S$}
11890-
in this case, it follows that \code{$T <:$ FutureOr<$\flatten{T}$>}.
11889+
it follows that \code{$T <:$ FutureOr<$S$>}. Since \code{$\Flatten{T} = S$}
11890+
in this case, it follows that \code{$T <:$ FutureOr<$\Flatten{T}$>}.
1189111891

1189211892
\item If $T$ derives a future type \code{Future<$S$>?} or
1189311893
\code{FutureOr<$S$>?}, then, since \code{Future<$S$>? $<:$ FutureOr<$S$>?},
1189411894
it follows that \code{$T <:$ FutureOr<$S$>?}.
1189511895
\code{FutureOr<$S$>? $<:$ FutureOr<$S$?>} for any type $S$ (this can be shown
1189611896
using the union type subtype rules and from
1189711897
\code{Future<$S$> $<:$ Future<$S$?>} by covariance), so by transivitity,
11898-
\code{$T <:$ FutureOr<$S$?>}. Since \code{$\flatten{T} = S$?} in this case,
11899-
it follows that \code{$T <:$ FutureOr<$\flatten{T}$>}.
11898+
\code{$T <:$ FutureOr<$S$?>}. Since \code{$\Flatten{T} = S$?} in this case,
11899+
it follows that \code{$T <:$ FutureOr<$\Flatten{T}$>}.
1190011900

11901-
\item Otherwise, \code{$\flatten{T} = T$}, so
11902-
\code{FutureOr<$\flatten{T}$> $=$ FutureOr<$T$>}. Since
11901+
\item Otherwise, \code{$\Flatten{T} = T$}, so
11902+
\code{FutureOr<$\Flatten{T}$> $=$ FutureOr<$T$>}. Since
1190311903
\code{$T <:$ FutureOr<$T$>}, it follows that
11904-
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11904+
\code{$T <:$ FutureOr<$\Flatten{T}$>}.
1190511905
\end{itemize}
1190611906
}
1190711907

@@ -11936,7 +11936,7 @@ \subsection{Function Expressions}
1193611936

1193711937
\noindent
1193811938
is
11939-
\FunctionTypePositionalStdCr{\code{Future<\flatten{T_0}>}},
11939+
\FunctionTypePositionalStdCr{\code{Future<\Flatten{T_0}>}},
1194011940

1194111941
\noindent
1194211942
where $T_0$ is the static type of $e$.
@@ -11972,7 +11972,7 @@ \subsection{Function Expressions}
1197211972

1197311973
\noindent
1197411974
is
11975-
\FunctionTypeNamedStdCr{\code{Future<\flatten{T_0}>}},
11975+
\FunctionTypeNamedStdCr{\code{Future<\Flatten{T_0}>}},
1197611976

1197711977
\noindent
1197811978
where $T_0$ is the static type of $e$.
@@ -16760,13 +16760,13 @@ \subsection{Await Expressions}
1676016760
\BlindDefineSymbol{a, e, S}%
1676116761
Let $a$ be an expression of the form \code{\AWAIT\,\,$e$}.
1676216762
Let $S$ be the static type of $e$.
16763-
The static type of $a$ is then \flatten{S}
16763+
The static type of $a$ is then \Flatten{S}
1676416764
(\ref{functionExpressions}).
1676516765

1676616766
\LMHash{}%
1676716767
Evaluation of $a$ proceeds as follows:
1676816768
First, the expression $e$ is evaluated to an object $o$.
16769-
Let \DefineSymbol{T} be \flatten{S}.
16769+
Let \DefineSymbol{T} be \Flatten{S}.
1677016770
If the run-time type of $o$ is a subtype of \code{Future<$T$>},
1677116771
then let \DefineSymbol{f} be $o$;
1677216772
otherwise let $f$ be the result of creating
@@ -16787,7 +16787,7 @@ \subsection{Await Expressions}
1678716787
If $f$ completes with an object $v$, $a$ evaluates to $v$.
1678816788

1678916789
\rationale{%
16790-
The use of \flattenName{} to find $T$ and hence determine the dynamic type test
16790+
The use of \FlattenName{} to find $T$ and hence determine the dynamic type test
1679116791
implies that we await a future in every case where this choice is sound.%
1679216792
}
1679316793

@@ -16803,7 +16803,7 @@ \subsection{Await Expressions}
1680316803
However, the second kind could be a \code{Future<Object?>}.
1680416804
This object isn't a \code{Future<Object>}, and it isn't \NULL,
1680516805
so it \emph{must} be considered to be in the second group.
16806-
Nevertheless, \flatten{\code{FutureOr<Object>?}} is \code{Object?},
16806+
Nevertheless, \Flatten{\code{FutureOr<Object>?}} is \code{Object?},
1680716807
so we \emph{will} await a \code{Future<Object?>}.
1680816808
We have chosen this semantics because it was the smallest breaking change
1680916809
relative to the semantics in earlier versions of Dart,
@@ -19235,7 +19235,7 @@ \subsection{Return}
1923519235
%
1923619236
% Returning without an object is only ok for async-"voidy" return types.
1923719237
It is a compile-time error if $s$ is \code{\RETURN;},
19238-
unless \flatten{T}
19238+
unless \Flatten{T}
1923919239
(\ref{functionExpressions})
1924019240
is \VOID, \DYNAMIC, or \code{Null}.
1924119241
%
@@ -19248,26 +19248,26 @@ \subsection{Return}
1924819248
% Returning with an object in an void async function only ok
1924919249
% when that value is async-"voidy".
1925019250
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19251-
\flatten{T} is \VOID,
19252-
and \flatten{S} is neither \VOID, \DYNAMIC, nor \code{Null}.
19251+
\Flatten{T} is \VOID,
19252+
and \Flatten{S} is neither \VOID, \DYNAMIC, nor \code{Null}.
1925319253
%
1925419254
% Returning async-void in a "non-async-voidy" function is an error.
1925519255
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19256-
\flatten{T} is neither \VOID, \DYNAMIC, nor \code{Null},
19257-
and \flatten{S} is \VOID.
19256+
\Flatten{T} is neither \VOID, \DYNAMIC, nor \code{Null},
19257+
and \Flatten{S} is \VOID.
1925819258
%
1925919259
% Otherwise, returning an un-deasync-assignable value is an error.
1926019260
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
19261-
\flatten{S} is not \VOID,
19262-
and \code{Future<\flatten{S}>} is not assignable to $T$.
19261+
\Flatten{S} is not \VOID,
19262+
and \code{Future<\Flatten{S}>} is not assignable to $T$.
1926319263

1926419264
\commentary{%
19265-
Note that \flatten{T} cannot be \VOID, \DYNAMIC, or \code{Null}
19265+
Note that \Flatten{T} cannot be \VOID, \DYNAMIC, or \code{Null}
1926619266
in the last case,
1926719267
because then \code{Future<$U$>} is assignable to $T$ for \emph{all} $U$.
1926819268
In particular, when $T$ is \code{FutureOr<Null>}
1926919269
(which is equivalent to \code{Future<Null>}),
19270-
\code{Future<\flatten{S}>} is assignable to $T$ for all $S$.
19270+
\code{Future<\Flatten{S}>} is assignable to $T$ for all $S$.
1927119271
This means that no compile-time error is raised,
1927219272
but \emph{only} the null object (\ref{null})
1927319273
or an instance of \code{Future<Null>} can successfully be returned at run time.
@@ -19278,7 +19278,7 @@ \subsection{Return}
1927819278

1927919279
An error will not be raised if $f$ has no declared return type,
1928019280
since the return type would be \DYNAMIC,
19281-
and \code{Future<\flatten{S}>} is assignable to \DYNAMIC{} for all $S$.
19281+
and \code{Future<\Flatten{S}>} is assignable to \DYNAMIC{} for all $S$.
1928219282
However, an asynchronous non-generator function
1928319283
that declares a return type which is not ``voidy''
1928419284
must return an expression explicitly.%
@@ -19329,7 +19329,7 @@ \subsection{Return}
1932919329
let $T$ be the actual return type of $f$
1933019330
(\ref{actualTypes}).
1933119331
If the body of $f$ is marked \ASYNC{} (\ref{functions})
19332-
and $S$ is a subtype of \code{Future<\flatten{T}>}
19332+
and $S$ is a subtype of \code{Future<\Flatten{T}>}
1933319333
then let $r$ be the result of evaluating \code{await $v$}
1933419334
where $v$ is a fresh variable bound to $o$.
1933519335
Otherwise let $r$ be $o$.

0 commit comments

Comments
 (0)