Skip to content

Commit

Permalink
Adjust definition of flatten (#2696)
Browse files Browse the repository at this point in the history
Adjust definition of flatten to ensure that `flatten(X) == X` when `X` is a type variable which is unrelated to future types.
  • Loading branch information
eernstg committed Dec 8, 2022
1 parent 90186a9 commit b68d1a5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions specification/dartLangSpec.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11268,16 +11268,12 @@ \subsection{Function Expressions}
which is used below and in other sections, as follows:

\begin{itemize}
\item{} If $T$ is a type variable $X$ with bound $B$,
or $T$ is an intersection type
(\ref{intersectionTypes})
\code{$X$\,\,\&\,\,$B$},
then \DefEquals{\flatten{T}}{\flatten{B}}.

\item{} If $T$ is \code{$S$?}\ for some $S$
then \DefEquals{\flatten{T}}{\code{\flatten{S}?}}.

\item{} If $T$ is \code{FutureOr<$S$>} then \DefEquals{\flatten{T}}{S}.
\item{} If $T$ is \code{FutureOr<$S$>} bounded
(\ref{bindingActualsToFormals})
then \DefEquals{\flatten{T}}{S}.

\item{} If $T$ implements \code{Future<$S$>}
(\ref{interfaceSuperinterfaces})
Expand All @@ -11288,7 +11284,13 @@ \subsection{Function Expressions}

\commentary{%
This definition guarantees that for any type $T$,
\code{$T <:$ FutureOr<$\flatten{T}$>}.%
\code{$T <:$ FutureOr<$\flatten{T}$>}.
Note that when $X$ is a type variable with bound $B$,
it is possible that \flatten{X} is different from $X$:
$B$ could, for some $S$, be \code{FutureOr<$S$>},
or a type variable $Y$ with bound \code{FutureOr<$S$>},
or a class $C$ that implements \code{Future<$S$>},
or a type variable $X$ with bound $C$.%
}

\LMHash{}%
Expand Down

0 comments on commit b68d1a5

Please sign in to comment.