Skip to content

Commit 5540f65

Browse files
committed
Review response
1 parent 11edb4d commit 5540f65

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

specification/dartLangSpec.tex

+38-32
Original file line numberDiff line numberDiff line change
@@ -23328,7 +23328,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2332823328
\DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
2332923329
if \SubtypeNE{T_1}{T_2}.
2333023330

23331-
\commentary{
23331+
\commentary{%
2333223332
In this and in the following cases, both types must be interface types.%
2333323333
}
2333423334
\item
@@ -23585,7 +23585,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2358523585
\DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
2358623586
\end{itemize}
2358723587

23588-
\rationale{
23588+
\rationale{%
2358923589
The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
2359023590
are somewhat redundant in that they explicitly specify
2359123591
a lot of pairs of symmetric cases.
@@ -25377,6 +25377,7 @@ \subsection{Type Promotion}
2537725377
}
2537825378

2537925379
\LMHash{}%
25380+
\BlindDefineSymbol{\ell, v}%
2538025381
Let $\ell$ be a location,
2538125382
and let $v$ be a local variable which is in scope at $\ell$.
2538225383
Assume that $\ell$ occurs after the declaration of $v$.
@@ -25400,34 +25401,33 @@ \subsection{Type Promotion}
2540025401

2540125402
\LMHash{}%
2540225403
In particular,
25403-
a check of the form \code{$v$\,\,==\,\,\NULL},
25404-
\code{\NULL\,\,==\,\,$v$},
25405-
or \code{$v$\,\,\IS\,\,Null}
25404+
an expression of the form \code{$v$\,\,==\,\,\NULL} or
25405+
\code{\NULL\,\,==\,\,$v$}
2540625406
where $v$ has type $T$ at $\ell$
2540725407
promotes the type of $v$
25408-
to \code{Null} in the \TRUE{} continuation,
25409-
and to \NonNullType{$T$} in the \FALSE{} continuation.
25410-
25411-
%% TODO(eernst), for review: The null safety spec says that `T?` is
25412-
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25413-
%% `X & int`. So we may be able to specify something which will yield
25414-
%% slightly more precise types, and which is more precisely the implemented
25415-
%% behavior.
25416-
\LMHash{}%
25417-
A check of the form \code{$v$\,\,!=\,\,\NULL},
25418-
\code{\NULL\,\,!=\,\,$v$},
25419-
or \code{$v$\,\,\IS\,\,$T$}
25420-
where $v$ has static type $T?$ at $\ell$
25408+
to \NonNullType{$T$} in the \FALSE{} continuation;
25409+
and an expression of the form \code{$v$\,\,!=\,\,\NULL} or
25410+
\code{\NULL\,\,!=\,\,$v$}
25411+
where $v$ has static type $T$ at $\ell$
25412+
promotes the type of $v$
25413+
to \NonNullType{$T$} in the \TRUE{} continuation.
25414+
25415+
\LMHash{}%
25416+
Similarly, a type test of the form \code{$v$\,\,\IS\,\,$T$}
2542125417
promotes the type of $v$
2542225418
to $T$ in the \TRUE{} continuation,
25423-
and to \code{Null} in the \FALSE{} continuation.
25419+
and a type check of the form \code{$v$\,\,\AS\,\,$T$}
25420+
promotes the type of $v$
25421+
to $T$ in the continuation where the expression evaluated to an object
25422+
(\commentary{that is, it did not throw}).
2542425423

2542525424
\commentary{%
2542625425
The resulting type of $v$ may be the obvious one, e.g.,
2542725426
\code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
2542825427
but it may also give rise to a demotion
25429-
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$),
25430-
and it may have no effect on the type of $v$
25428+
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$
25429+
and potentially promoting it to some other type of interest).
25430+
It may also have no effect on the type of $v$
2543125431
(e.g., when the static type of $e$ is not a type of interest).
2543225432
These details will be specified in a future version of this specification.
2543325433

@@ -25607,15 +25607,20 @@ \section*{Appendix: Algorithmic Subtyping}
2560725607
the one which is specified in Fig.~\ref{fig:subtypeRules}.
2560825608
It shows that Dart subtyping relationships can be decided
2560925609
with good performance.
25610+
This section is not normative.
2561025611

2561125612
\LMHash{}%
2561225613
In this algorithm, types are considered to be the same when they have
2561325614
the same canonical syntax
2561425615
(\ref{theCanonicalSyntaxOfTypes}).
25616+
\commentary{%
25617+
For example, \SubtypeStd{\code{C}}{\code{C}} does not hold if
25618+
the two occurrences of \code{C} refer to declarations in different libraries.%
25619+
}
2561525620
The algorithm must be performed such that the first case that matches
2561625621
is always the case which is performed.
2561725622
The algorithm produces results which are both positive and negative
25618-
(\commentary{
25623+
(\commentary{%
2561925624
that is, in some situations the subtype relation is determined to be false%
2562025625
}),
2562125626
which is important for performance because
@@ -25627,16 +25632,18 @@ \section*{Appendix: Algorithmic Subtyping}
2562725632
\begin{itemize}
2562825633
\item
2562925634
\textbf{Reflexivity:}
25630-
if $T_0$ and $T_1$ are the same type then \SubtypeNE{T_0}{T_1}
25635+
if $T_0$ and $T_1$ are the same atomic type then \SubtypeNE{T_0}{T_1}.
2563125636

2563225637
\commentary{%
25633-
Note that this check is necessary as the base case for primitive types,
25638+
This check is necessary as the base case for primitive types,
2563425639
and type variables, but not for composite types.
2563525640
In particular, a structural equality check is admissible,
2563625641
but not required here.
25637-
Pragmatically, non-constant time identity checks here are
25638-
counter-productive.
25639-
So this rule should only be used when $T$ is atomic.%
25642+
Non-constant time identity checks here are counter-productive
25643+
because the following rules will yield the same result anyway,
25644+
so we may just perform a full traversal of a large structure twice
25645+
for no reason.
25646+
Hence, this rule is only used when the given type is atomic.%
2564025647
}
2564125648
\item
2564225649
\textbf{Right Top:}
@@ -25646,7 +25653,7 @@ \section*{Appendix: Algorithmic Subtyping}
2564625653
if $T_0$ is \DYNAMIC{} or \VOID{}
2564725654
then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
2564825655
\item
25649-
\textbf{Left Bottom:}
25656+
\textbf{Bottom:}
2565025657
if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
2565125658
\item
2565225659
\textbf{Right Object:}
@@ -25699,7 +25706,7 @@ \section*{Appendix: Algorithmic Subtyping}
2569925706
or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
2570025707
then \SubtypeNE{T_0}{T_1}.
2570125708

25702-
\commentary{
25709+
\commentary{%
2570325710
Note that this rule is admissible, and can be safely elided if desired.%
2570425711
}
2570525712
\item
@@ -25782,7 +25789,7 @@ \section*{Appendix: Algorithmic Subtyping}
2578225789
for $i \in 0 .. q$.
2578325790
\item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2578425791
\item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
25785-
have the same canonical syntax, for $i \in 0 .. k$.
25792+
are subtypes of each other, for $i \in 0 .. k$.
2578625793
\end{itemize}
2578725794
\item
2578825795
\textbf{Named Function Types:}
@@ -25823,8 +25830,7 @@ \section*{Appendix: Algorithmic Subtyping}
2582325830
\SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2582425831
\item
2582525832
$B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
25826-
have the same canonical syntax,
25827-
for each $i \in 0 .. k$.
25833+
are subtypes of each other, for each $i \in 0 .. k$.
2582825834
\end{itemize}
2582925835

2583025836
\commentary{%

0 commit comments

Comments
 (0)