Skip to content

Commit 906c4b1

Browse files
committed
Fixed the "SUB issues" section
1 parent 38b541d commit 906c4b1

File tree

1 file changed

+57
-24
lines changed

1 file changed

+57
-24
lines changed

specification/dartLangSpec.tex

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23791,7 +23791,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2379123791
\FUNCTION}.
2379223792
\item
2379323793
Let $U_1$ and $U_2$ be, respectively,
23794-
23794+
2379523795
\noindent
2379623796
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2379723797
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23824,7 +23824,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2382423824
\noindent
2382523825
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2382623826
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23827-
23827+
2382823828
\noindent
2382923829
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2383023830
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23838,7 +23838,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2383823838
\item For each required entry named $n$ in $\metavar{Named}_2$,
2383923839
$\metavar{Named}_1$ contains an entry named $n$
2384023840
(\commentary{which may or may not be required}).
23841-
\end{itemize}
23841+
\end{itemize}
2384223842

2384323843
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2384423844
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
@@ -23883,7 +23883,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2388323883
\item
2388423884
\DefEqualsNewline{\UpperBoundType{$T_1$}{$S$ \FUNCTION<\ldots>(\ldots)}}{%
2388523885
\UpperBoundType{$T_1$}{Object}}.
23886-
\item
23886+
\item
2388723887
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{FutureOr<$T_2$>}}{%
2388823888
\code{FutureOr<$T_3$>}},
2388923889
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23899,7 +23899,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2389923899
\DefEquals{\UpperBoundType{$T_1$}{FutureOr<$T_2$>}}{%
2390023900
\code{FutureOr<$T_3$>}},
2390123901
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
23902-
\item
23902+
\item
2390323903
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{$T_2$}}{%
2390423904
\code{FutureOr<$T_3$>}},
2390523905
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -24046,7 +24046,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2404624046
%%
2404724047
\item
2404824048
Let $U_1$ and $U_2$ be, respectively,
24049-
24049+
2405024050
\noindent
2405124051
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2405224052
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -24061,7 +24061,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2406124061
let $T_3$ be \LowerBoundType{$T_1$}{$T_2$},
2406224062
let $B_{3i}$ be $B_{1i}$, and
2406324063
let $P_{3i}$ be determined as follows:
24064-
24064+
2406524065
\begin{itemize}
2406624066
\item $P_{3i}$ is \UpperBoundType{$P_{1i}$}{$P_{2i}$} for
2406724067
$i \leq \metavar{min}(k, l)$.
@@ -24070,7 +24070,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2407024070
\item $P_{3i}$ is optional if $P_{1i}$ or $P_{2i}$ is optional,
2407124071
or if $\metavar{min}(k, l) < i \leq q$.
2407224072
\end{itemize}
24073-
24073+
2407424074
Then \DefEqualsNewline{\LowerBoundType{$U_1$}{$U_2$}}{%
2407524075
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
2407624076
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
@@ -24088,7 +24088,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2408824088
\noindent
2408924089
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2409024090
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
24091-
24091+
2409224092
\noindent
2409324093
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2409424094
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -24195,7 +24195,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2419524195
\commentary{%
2419624196
For example, the algorithm yields \code{Object} as the standard upper bound of
2419724197
\code{List<Comparable<int>{}>} and \code{Iterable<int>},
24198-
but it is easy to see that a tighter upper bound exists, e.g.,
24198+
but it is easy to see that a tighter upper bound exists, e.g.,
2419924199
\code{Iterable<Comparable<num>{}>}.%
2420024200
}
2420124201

@@ -24241,18 +24241,16 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2424124241
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
2424224242

2424324243

24244-
\subsubsection{Standard Upper Bound Termination}
24245-
\LMLabel{standardUpperBoundTermination}
24244+
\subsubsection{Standard Upper Bound Issues}
24245+
\LMLabel{standardUpperBoundIssues}
2424624246

24247-
%% TODO(eernst), for review: This section could be turned into a few github
24248-
%% issues, but it seems reasonable to let the user of Dart know about it.
24249-
%% So do we include it, or do we delete the whole section (and create those
24250-
%% github issues)?
24251-
%%
24252-
%% Note that I omitted the symmetry issue: The given example does not
24253-
%% demonstrate any asymmetry (both results have type `List<dynamic>`).
24254-
%% So we should study the symmetry properties a bit more if we keep this
24255-
%% section.
24247+
%% TODO(eernst), for review: I kept this here (and updated some parts of it)
24248+
%% in order to ensure that this information is preserved. However, it should
24249+
%% perhaps not be in the specification. Should it actually be turned into
24250+
%% a couple of github issues? In any case, it makes sense to communicate
24251+
%% these properties of the algoritm to anyone who needs to know the language
24252+
%% in full detail, which could justify keeping it here, or including a
24253+
%% reference to some other location where the information is available.
2425624254

2425724255
\commentary{%
2425824256
The definition of the standard upper bound for type variables
@@ -24261,9 +24259,7 @@ \subsubsection{Standard Upper Bound Termination}
2426124259
}
2426224260

2426324261
\begin{dartCode}
24264-
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>() \{
24265-
T x;
24266-
S y;
24262+
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>(T x, S y) \{
2426724263
\VAR{} a = (x == y) ? x : y;
2426824264
\}
2426924265
\end{dartCode}
@@ -24280,6 +24276,43 @@ \subsubsection{Standard Upper Bound Termination}
2428024276
with the current algorithm.%
2428124277
}
2428224278

24279+
\commentary{%
24280+
The current algorithm is asymmetric.
24281+
There is an equivalence class of top types,
24282+
and we correctly choose a canonical representative for bare top types
24283+
using the \IsMoreTopTypeName{} predicate.
24284+
However, when two different top types are embedded in two mutual subtypes,
24285+
we don't correctly choose a canonical representative.%
24286+
}
24287+
24288+
\begin{dartCode}
24289+
\IMPORT{} 'dart:async';
24290+
\\
24291+
\VOID{} main() \{
24292+
List<FutureOr<Object?>{}> x;
24293+
List<\DYNAMIC> y;
24294+
24295+
var a = (x == y) ? x : y; // List<\DYNAMIC>.
24296+
var b = (x == y) ? y : x; // List<FutureOr<Object?>{}>.
24297+
\}
24298+
\end{dartCode}
24299+
24300+
\commentary{%
24301+
The best solution for this is probably to normalize the types.
24302+
This is fairly straightforward:
24303+
We just normalize \code{FutureOr<$T$>} to the normal form of $T$
24304+
when $T$ is a top type.
24305+
We can then inductively apply this across the rest of the types.
24306+
Then, whenever we have mutual subtypes, we just return the normal form.
24307+
This would be breaking, albeit hopefully only in a minor way.
24308+
24309+
A similar treatment would need to be done for the bottom types as well,
24310+
since there are two equivalences there:
24311+
A type variable $X$ with bound $T$ is equivalent to \code{Never}
24312+
if $T$ is equivalent to \code{Never},
24313+
and \code{FutureOr<Never>} is equivalent to \code{Future<Never>}.%
24314+
}
24315+
2428324316

2428424317
\subsection{Least and Greatest Closure of Types}
2428524318
\LMLabel{leastAndGreatestClosureOfTypes}

0 commit comments

Comments
 (0)