Skip to content

Commit b68d1a5

Browse files
authored
Adjust definition of flatten (#2696)
Adjust definition of flatten to ensure that `flatten(X) == X` when `X` is a type variable which is unrelated to future types.
1 parent 90186a9 commit b68d1a5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

specification/dartLangSpec.tex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11268,16 +11268,12 @@ \subsection{Function Expressions}
1126811268
which is used below and in other sections, as follows:
1126911269

1127011270
\begin{itemize}
11271-
\item{} If $T$ is a type variable $X$ with bound $B$,
11272-
or $T$ is an intersection type
11273-
(\ref{intersectionTypes})
11274-
\code{$X$\,\,\&\,\,$B$},
11275-
then \DefEquals{\flatten{T}}{\flatten{B}}.
11276-
1127711271
\item{} If $T$ is \code{$S$?}\ for some $S$
1127811272
then \DefEquals{\flatten{T}}{\code{\flatten{S}?}}.
1127911273

11280-
\item{} If $T$ is \code{FutureOr<$S$>} then \DefEquals{\flatten{T}}{S}.
11274+
\item{} If $T$ is \code{FutureOr<$S$>} bounded
11275+
(\ref{bindingActualsToFormals})
11276+
then \DefEquals{\flatten{T}}{S}.
1128111277

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

1128911285
\commentary{%
1129011286
This definition guarantees that for any type $T$,
11291-
\code{$T <:$ FutureOr<$\flatten{T}$>}.%
11287+
\code{$T <:$ FutureOr<$\flatten{T}$>}.
11288+
Note that when $X$ is a type variable with bound $B$,
11289+
it is possible that \flatten{X} is different from $X$:
11290+
$B$ could, for some $S$, be \code{FutureOr<$S$>},
11291+
or a type variable $Y$ with bound \code{FutureOr<$S$>},
11292+
or a class $C$ that implements \code{Future<$S$>},
11293+
or a type variable $X$ with bound $C$.%
1129211294
}
1129311295

1129411296
\LMHash{}%

0 commit comments

Comments
 (0)