Skip to content

Commit 206456f

Browse files
committed
Fixed the "SUB issues" section
1 parent f2f0cda commit 206456f

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
@@ -23341,7 +23341,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2334123341
\FUNCTION}.
2334223342
\item
2334323343
Let $U_1$ and $U_2$ be, respectively,
23344-
23344+
2334523345
\noindent
2334623346
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2334723347
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23374,7 +23374,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2337423374
\noindent
2337523375
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2337623376
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23377-
23377+
2337823378
\noindent
2337923379
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2338023380
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23388,7 +23388,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2338823388
\item For each required entry named $n$ in $\metavar{Named}_2$,
2338923389
$\metavar{Named}_1$ contains an entry named $n$
2339023390
(\commentary{which may or may not be required}).
23391-
\end{itemize}
23391+
\end{itemize}
2339223392

2339323393
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2339423394
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
@@ -23433,7 +23433,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2343323433
\item
2343423434
\DefEqualsNewline{\UpperBoundType{$T_1$}{$S$ \FUNCTION<\ldots>(\ldots)}}{%
2343523435
\UpperBoundType{$T_1$}{Object}}.
23436-
\item
23436+
\item
2343723437
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{FutureOr<$T_2$>}}{%
2343823438
\code{FutureOr<$T_3$>}},
2343923439
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23449,7 +23449,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2344923449
\DefEquals{\UpperBoundType{$T_1$}{FutureOr<$T_2$>}}{%
2345023450
\code{FutureOr<$T_3$>}},
2345123451
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
23452-
\item
23452+
\item
2345323453
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{$T_2$}}{%
2345423454
\code{FutureOr<$T_3$>}},
2345523455
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23596,7 +23596,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2359623596
%%
2359723597
\item
2359823598
Let $U_1$ and $U_2$ be, respectively,
23599-
23599+
2360023600
\noindent
2360123601
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2360223602
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23611,7 +23611,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2361123611
let $T_3$ be \LowerBoundType{$T_1$}{$T_2$},
2361223612
let $B_{3i}$ be $B_{1i}$, and
2361323613
let $P_{3i}$ be determined as follows:
23614-
23614+
2361523615
\begin{itemize}
2361623616
\item $P_{3i}$ is \UpperBoundType{$P_{1i}$}{$P_{2i}$} for
2361723617
$i \leq \metavar{min}(k, l)$.
@@ -23620,7 +23620,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2362023620
\item $P_{3i}$ is optional if $P_{1i}$ or $P_{2i}$ is optional,
2362123621
or if $\metavar{min}(k, l) < i \leq q$.
2362223622
\end{itemize}
23623-
23623+
2362423624
Then \DefEqualsNewline{\LowerBoundType{$U_1$}{$U_2$}}{%
2362523625
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
2362623626
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
@@ -23638,7 +23638,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2363823638
\noindent
2363923639
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2364023640
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23641-
23641+
2364223642
\noindent
2364323643
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2364423644
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23745,7 +23745,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2374523745
\commentary{%
2374623746
For example, the algorithm yields \code{Object} as the standard upper bound of
2374723747
\code{List<Comparable<int>{}>} and \code{Iterable<int>},
23748-
but it is easy to see that a tighter upper bound exists, e.g.,
23748+
but it is easy to see that a tighter upper bound exists, e.g.,
2374923749
\code{Iterable<Comparable<num>{}>}.%
2375023750
}
2375123751

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

2379323793

23794-
\subsubsection{Standard Upper Bound Termination}
23795-
\LMLabel{standardUpperBoundTermination}
23794+
\subsubsection{Standard Upper Bound Issues}
23795+
\LMLabel{standardUpperBoundIssues}
2379623796

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

2380723805
\commentary{%
2380823806
The definition of the standard upper bound for type variables
@@ -23811,9 +23809,7 @@ \subsubsection{Standard Upper Bound Termination}
2381123809
}
2381223810

2381323811
\begin{dartCode}
23814-
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>() \{
23815-
T x;
23816-
S y;
23812+
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>(T x, S y) \{
2381723813
\VAR{} a = (x == y) ? x : y;
2381823814
\}
2381923815
\end{dartCode}
@@ -23830,6 +23826,43 @@ \subsubsection{Standard Upper Bound Termination}
2383023826
with the current algorithm.%
2383123827
}
2383223828

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

2383423867
\subsection{Least and Greatest Closure of Types}
2383523868
\LMLabel{leastAndGreatestClosureOfTypes}

0 commit comments

Comments
 (0)