Skip to content

Commit a2e55f1

Browse files
committed
Fixed the "SUB issues" section
1 parent 6ae3d46 commit a2e55f1

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
@@ -23339,7 +23339,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2333923339
\FUNCTION}.
2334023340
\item
2334123341
Let $U_1$ and $U_2$ be, respectively,
23342-
23342+
2334323343
\noindent
2334423344
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2334523345
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23372,7 +23372,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2337223372
\noindent
2337323373
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2337423374
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23375-
23375+
2337623376
\noindent
2337723377
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2337823378
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23386,7 +23386,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2338623386
\item For each required entry named $n$ in $\metavar{Named}_2$,
2338723387
$\metavar{Named}_1$ contains an entry named $n$
2338823388
(\commentary{which may or may not be required}).
23389-
\end{itemize}
23389+
\end{itemize}
2339023390

2339123391
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2339223392
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
@@ -23431,7 +23431,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2343123431
\item
2343223432
\DefEqualsNewline{\UpperBoundType{$T_1$}{$S$ \FUNCTION<\ldots>(\ldots)}}{%
2343323433
\UpperBoundType{$T_1$}{Object}}.
23434-
\item
23434+
\item
2343523435
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{FutureOr<$T_2$>}}{%
2343623436
\code{FutureOr<$T_3$>}},
2343723437
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23447,7 +23447,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2344723447
\DefEquals{\UpperBoundType{$T_1$}{FutureOr<$T_2$>}}{%
2344823448
\code{FutureOr<$T_3$>}},
2344923449
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
23450-
\item
23450+
\item
2345123451
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{$T_2$}}{%
2345223452
\code{FutureOr<$T_3$>}},
2345323453
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23594,7 +23594,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2359423594
%%
2359523595
\item
2359623596
Let $U_1$ and $U_2$ be, respectively,
23597-
23597+
2359823598
\noindent
2359923599
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2360023600
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23609,7 +23609,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2360923609
let $T_3$ be \LowerBoundType{$T_1$}{$T_2$},
2361023610
let $B_{3i}$ be $B_{1i}$, and
2361123611
let $P_{3i}$ be determined as follows:
23612-
23612+
2361323613
\begin{itemize}
2361423614
\item $P_{3i}$ is \UpperBoundType{$P_{1i}$}{$P_{2i}$} for
2361523615
$i \leq \metavar{min}(k, l)$.
@@ -23618,7 +23618,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2361823618
\item $P_{3i}$ is optional if $P_{1i}$ or $P_{2i}$ is optional,
2361923619
or if $\metavar{min}(k, l) < i \leq q$.
2362023620
\end{itemize}
23621-
23621+
2362223622
Then \DefEqualsNewline{\LowerBoundType{$U_1$}{$U_2$}}{%
2362323623
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
2362423624
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
@@ -23636,7 +23636,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2363623636
\noindent
2363723637
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2363823638
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23639-
23639+
2364023640
\noindent
2364123641
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2364223642
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23743,7 +23743,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2374323743
\commentary{%
2374423744
For example, the algorithm yields \code{Object} as the standard upper bound of
2374523745
\code{List<Comparable<int>{}>} and \code{Iterable<int>},
23746-
but it is easy to see that a tighter upper bound exists, e.g.,
23746+
but it is easy to see that a tighter upper bound exists, e.g.,
2374723747
\code{Iterable<Comparable<num>{}>}.%
2374823748
}
2374923749

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

2379123791

23792-
\subsubsection{Standard Upper Bound Termination}
23793-
\LMLabel{standardUpperBoundTermination}
23792+
\subsubsection{Standard Upper Bound Issues}
23793+
\LMLabel{standardUpperBoundIssues}
2379423794

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

2380523803
\commentary{%
2380623804
The definition of the standard upper bound for type variables
@@ -23809,9 +23807,7 @@ \subsubsection{Standard Upper Bound Termination}
2380923807
}
2381023808

2381123809
\begin{dartCode}
23812-
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>() \{
23813-
T x;
23814-
S y;
23810+
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>(T x, S y) \{
2381523811
\VAR{} a = (x == y) ? x : y;
2381623812
\}
2381723813
\end{dartCode}
@@ -23828,6 +23824,43 @@ \subsubsection{Standard Upper Bound Termination}
2382823824
with the current algorithm.%
2382923825
}
2383023826

23827+
\commentary{%
23828+
The current algorithm is asymmetric.
23829+
There is an equivalence class of top types,
23830+
and we correctly choose a canonical representative for bare top types
23831+
using the \IsMoreTopTypeName{} predicate.
23832+
However, when two different top types are embedded in two mutual subtypes,
23833+
we don't correctly choose a canonical representative.%
23834+
}
23835+
23836+
\begin{dartCode}
23837+
\IMPORT{} 'dart:async';
23838+
\\
23839+
\VOID{} main() \{
23840+
List<FutureOr<Object?>{}> x;
23841+
List<\DYNAMIC> y;
23842+
23843+
var a = (x == y) ? x : y; // List<\DYNAMIC>.
23844+
var b = (x == y) ? y : x; // List<FutureOr<Object?>{}>.
23845+
\}
23846+
\end{dartCode}
23847+
23848+
\commentary{%
23849+
The best solution for this is probably to normalize the types.
23850+
This is fairly straightforward:
23851+
We just normalize \code{FutureOr<$T$>} to the normal form of $T$
23852+
when $T$ is a top type.
23853+
We can then inductively apply this across the rest of the types.
23854+
Then, whenever we have mutual subtypes, we just return the normal form.
23855+
This would be breaking, albeit hopefully only in a minor way.
23856+
23857+
A similar treatment would need to be done for the bottom types as well,
23858+
since there are two equivalences there:
23859+
A type variable $X$ with bound $T$ is equivalent to \code{Never}
23860+
if $T$ is equivalent to \code{Never},
23861+
and \code{FutureOr<Never>} is equivalent to \code{Future<Never>}.%
23862+
}
23863+
2383123864

2383223865
\subsection{Least and Greatest Closure of Types}
2383323866
\LMLabel{leastAndGreatestClosureOfTypes}

0 commit comments

Comments
 (0)