Skip to content

Commit 0a40cc6

Browse files
committed
Fixed the "SUB issues" section
1 parent 39d49d6 commit 0a40cc6

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
@@ -24225,7 +24225,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2422524225
\FUNCTION}.
2422624226
\item
2422724227
Let $U_1$ and $U_2$ be, respectively,
24228-
24228+
2422924229
\noindent
2423024230
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2423124231
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -24258,7 +24258,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2425824258
\noindent
2425924259
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2426024260
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
24261-
24261+
2426224262
\noindent
2426324263
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2426424264
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -24272,7 +24272,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2427224272
\item For each required entry named $n$ in $\metavar{Named}_2$,
2427324273
$\metavar{Named}_1$ contains an entry named $n$
2427424274
(\commentary{which may or may not be required}).
24275-
\end{itemize}
24275+
\end{itemize}
2427624276

2427724277
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2427824278
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
@@ -24317,7 +24317,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2431724317
\item
2431824318
\DefEqualsNewline{\UpperBoundType{$T_1$}{$S$ \FUNCTION<\ldots>(\ldots)}}{%
2431924319
\UpperBoundType{$T_1$}{Object}}.
24320-
\item
24320+
\item
2432124321
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{FutureOr<$T_2$>}}{%
2432224322
\code{FutureOr<$T_3$>}},
2432324323
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -24333,7 +24333,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2433324333
\DefEquals{\UpperBoundType{$T_1$}{FutureOr<$T_2$>}}{%
2433424334
\code{FutureOr<$T_3$>}},
2433524335
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
24336-
\item
24336+
\item
2433724337
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{$T_2$}}{%
2433824338
\code{FutureOr<$T_3$>}},
2433924339
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -24480,7 +24480,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2448024480
%%
2448124481
\item
2448224482
Let $U_1$ and $U_2$ be, respectively,
24483-
24483+
2448424484
\noindent
2448524485
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2448624486
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -24495,7 +24495,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2449524495
let $T_3$ be \LowerBoundType{$T_1$}{$T_2$},
2449624496
let $B_{3i}$ be $B_{1i}$, and
2449724497
let $P_{3i}$ be determined as follows:
24498-
24498+
2449924499
\begin{itemize}
2450024500
\item $P_{3i}$ is \UpperBoundType{$P_{1i}$}{$P_{2i}$} for
2450124501
$i \leq \metavar{min}(k, l)$.
@@ -24504,7 +24504,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2450424504
\item $P_{3i}$ is optional if $P_{1i}$ or $P_{2i}$ is optional,
2450524505
or if $\metavar{min}(k, l) < i \leq q$.
2450624506
\end{itemize}
24507-
24507+
2450824508
Then \DefEqualsNewline{\LowerBoundType{$U_1$}{$U_2$}}{%
2450924509
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
2451024510
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
@@ -24522,7 +24522,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2452224522
\noindent
2452324523
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2452424524
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
24525-
24525+
2452624526
\noindent
2452724527
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2452824528
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -24629,7 +24629,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2462924629
\commentary{%
2463024630
For example, the algorithm yields \code{Object} as the standard upper bound of
2463124631
\code{List<Comparable<int>{}>} and \code{Iterable<int>},
24632-
but it is easy to see that a tighter upper bound exists, e.g.,
24632+
but it is easy to see that a tighter upper bound exists, e.g.,
2463324633
\code{Iterable<Comparable<num>{}>}.%
2463424634
}
2463524635

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

2467724677

24678-
\subsubsection{Standard Upper Bound Termination}
24679-
\LMLabel{standardUpperBoundTermination}
24678+
\subsubsection{Standard Upper Bound Issues}
24679+
\LMLabel{standardUpperBoundIssues}
2468024680

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

2469124689
\commentary{%
2469224690
The definition of the standard upper bound for type variables
@@ -24695,9 +24693,7 @@ \subsubsection{Standard Upper Bound Termination}
2469524693
}
2469624694

2469724695
\begin{dartCode}
24698-
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>() \{
24699-
T x;
24700-
S y;
24696+
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>(T x, S y) \{
2470124697
\VAR{} a = (x == y) ? x : y;
2470224698
\}
2470324699
\end{dartCode}
@@ -24714,6 +24710,43 @@ \subsubsection{Standard Upper Bound Termination}
2471424710
with the current algorithm.%
2471524711
}
2471624712

24713+
\commentary{%
24714+
The current algorithm is asymmetric.
24715+
There is an equivalence class of top types,
24716+
and we correctly choose a canonical representative for bare top types
24717+
using the \IsMoreTopTypeName{} predicate.
24718+
However, when two different top types are embedded in two mutual subtypes,
24719+
we don't correctly choose a canonical representative.%
24720+
}
24721+
24722+
\begin{dartCode}
24723+
\IMPORT{} 'dart:async';
24724+
\\
24725+
\VOID{} main() \{
24726+
List<FutureOr<Object?>{}> x;
24727+
List<\DYNAMIC> y;
24728+
24729+
var a = (x == y) ? x : y; // List<\DYNAMIC>.
24730+
var b = (x == y) ? y : x; // List<FutureOr<Object?>{}>.
24731+
\}
24732+
\end{dartCode}
24733+
24734+
\commentary{%
24735+
The best solution for this is probably to normalize the types.
24736+
This is fairly straightforward:
24737+
We just normalize \code{FutureOr<$T$>} to the normal form of $T$
24738+
when $T$ is a top type.
24739+
We can then inductively apply this across the rest of the types.
24740+
Then, whenever we have mutual subtypes, we just return the normal form.
24741+
This would be breaking, albeit hopefully only in a minor way.
24742+
24743+
A similar treatment would need to be done for the bottom types as well,
24744+
since there are two equivalences there:
24745+
A type variable $X$ with bound $T$ is equivalent to \code{Never}
24746+
if $T$ is equivalent to \code{Never},
24747+
and \code{FutureOr<Never>} is equivalent to \code{Future<Never>}.%
24748+
}
24749+
2471724750

2471824751
\subsection{Least and Greatest Closure of Types}
2471924752
\LMLabel{leastAndGreatestClosureOfTypes}

0 commit comments

Comments
 (0)