Skip to content

Commit 3beb856

Browse files
committed
Review response
1 parent d4d18db commit 3beb856

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

specification/dartLangSpec.tex

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23536,7 +23536,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2353623536
\DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
2353723537
if \SubtypeNE{T_1}{T_2}.
2353823538

23539-
\commentary{
23539+
\commentary{%
2354023540
In this and in the following cases, both types must be interface types.%
2354123541
}
2354223542
\item
@@ -23793,7 +23793,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2379323793
\DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
2379423794
\end{itemize}
2379523795

23796-
\rationale{
23796+
\rationale{%
2379723797
The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
2379823798
are somewhat redundant in that they explicitly specify
2379923799
a lot of pairs of symmetric cases.
@@ -25611,6 +25611,7 @@ \subsection{Type Promotion}
2561125611
}
2561225612

2561325613
\LMHash{}%
25614+
\BlindDefineSymbol{\ell, v}%
2561425615
Let $\ell$ be a location,
2561525616
and let $v$ be a local variable which is in scope at $\ell$.
2561625617
Assume that $\ell$ occurs after the declaration of $v$.
@@ -25634,34 +25635,33 @@ \subsection{Type Promotion}
2563425635

2563525636
\LMHash{}%
2563625637
In particular,
25637-
a check of the form \code{$v$\,\,==\,\,\NULL},
25638-
\code{\NULL\,\,==\,\,$v$},
25639-
or \code{$v$\,\,\IS\,\,Null}
25638+
an expression of the form \code{$v$\,\,==\,\,\NULL} or
25639+
\code{\NULL\,\,==\,\,$v$}
2564025640
where $v$ has type $T$ at $\ell$
2564125641
promotes the type of $v$
25642-
to \code{Null} in the \TRUE{} continuation,
25643-
and to \NonNullType{$T$} in the \FALSE{} continuation.
25644-
25645-
%% TODO(eernst), for review: The null safety spec says that `T?` is
25646-
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25647-
%% `X & int`. So we may be able to specify something which will yield
25648-
%% slightly more precise types, and which is more precisely the implemented
25649-
%% behavior.
25650-
\LMHash{}%
25651-
A check of the form \code{$v$\,\,!=\,\,\NULL},
25652-
\code{\NULL\,\,!=\,\,$v$},
25653-
or \code{$v$\,\,\IS\,\,$T$}
25654-
where $v$ has static type $T?$ at $\ell$
25642+
to \NonNullType{$T$} in the \FALSE{} continuation;
25643+
and an expression of the form \code{$v$\,\,!=\,\,\NULL} or
25644+
\code{\NULL\,\,!=\,\,$v$}
25645+
where $v$ has static type $T$ at $\ell$
25646+
promotes the type of $v$
25647+
to \NonNullType{$T$} in the \TRUE{} continuation.
25648+
25649+
\LMHash{}%
25650+
Similarly, a type test of the form \code{$v$\,\,\IS\,\,$T$}
2565525651
promotes the type of $v$
2565625652
to $T$ in the \TRUE{} continuation,
25657-
and to \code{Null} in the \FALSE{} continuation.
25653+
and a type check of the form \code{$v$\,\,\AS\,\,$T$}
25654+
promotes the type of $v$
25655+
to $T$ in the continuation where the expression evaluated to an object
25656+
(\commentary{that is, it did not throw}).
2565825657

2565925658
\commentary{%
2566025659
The resulting type of $v$ may be the obvious one, e.g.,
2566125660
\code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
2566225661
but it may also give rise to a demotion
25663-
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$),
25664-
and it may have no effect on the type of $v$
25662+
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$
25663+
and potentially promoting it to some other type of interest).
25664+
It may also have no effect on the type of $v$
2566525665
(e.g., when the static type of $e$ is not a type of interest).
2566625666
These details will be specified in a future version of this specification.
2566725667

@@ -25841,15 +25841,20 @@ \section*{Appendix: Algorithmic Subtyping}
2584125841
the one which is specified in Fig.~\ref{fig:subtypeRules}.
2584225842
It shows that Dart subtyping relationships can be decided
2584325843
with good performance.
25844+
This section is not normative.
2584425845

2584525846
\LMHash{}%
2584625847
In this algorithm, types are considered to be the same when they have
2584725848
the same canonical syntax
2584825849
(\ref{theCanonicalSyntaxOfTypes}).
25850+
\commentary{%
25851+
For example, \SubtypeStd{\code{C}}{\code{C}} does not hold if
25852+
the two occurrences of \code{C} refer to declarations in different libraries.%
25853+
}
2584925854
The algorithm must be performed such that the first case that matches
2585025855
is always the case which is performed.
2585125856
The algorithm produces results which are both positive and negative
25852-
(\commentary{
25857+
(\commentary{%
2585325858
that is, in some situations the subtype relation is determined to be false%
2585425859
}),
2585525860
which is important for performance because
@@ -25861,16 +25866,18 @@ \section*{Appendix: Algorithmic Subtyping}
2586125866
\begin{itemize}
2586225867
\item
2586325868
\textbf{Reflexivity:}
25864-
if $T_0$ and $T_1$ are the same type then \SubtypeNE{T_0}{T_1}
25869+
if $T_0$ and $T_1$ are the same atomic type then \SubtypeNE{T_0}{T_1}.
2586525870

2586625871
\commentary{%
25867-
Note that this check is necessary as the base case for primitive types,
25872+
This check is necessary as the base case for primitive types,
2586825873
and type variables, but not for composite types.
2586925874
In particular, a structural equality check is admissible,
2587025875
but not required here.
25871-
Pragmatically, non-constant time identity checks here are
25872-
counter-productive.
25873-
So this rule should only be used when $T$ is atomic.%
25876+
Non-constant time identity checks here are counter-productive
25877+
because the following rules will yield the same result anyway,
25878+
so we may just perform a full traversal of a large structure twice
25879+
for no reason.
25880+
Hence, this rule is only used when the given type is atomic.%
2587425881
}
2587525882
\item
2587625883
\textbf{Right Top:}
@@ -25880,7 +25887,7 @@ \section*{Appendix: Algorithmic Subtyping}
2588025887
if $T_0$ is \DYNAMIC{} or \VOID{}
2588125888
then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
2588225889
\item
25883-
\textbf{Left Bottom:}
25890+
\textbf{Bottom:}
2588425891
if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
2588525892
\item
2588625893
\textbf{Right Object:}
@@ -25933,7 +25940,7 @@ \section*{Appendix: Algorithmic Subtyping}
2593325940
or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
2593425941
then \SubtypeNE{T_0}{T_1}.
2593525942

25936-
\commentary{
25943+
\commentary{%
2593725944
Note that this rule is admissible, and can be safely elided if desired.%
2593825945
}
2593925946
\item
@@ -26016,7 +26023,7 @@ \section*{Appendix: Algorithmic Subtyping}
2601626023
for $i \in 0 .. q$.
2601726024
\item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2601826025
\item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
26019-
have the same canonical syntax, for $i \in 0 .. k$.
26026+
are subtypes of each other, for $i \in 0 .. k$.
2602026027
\end{itemize}
2602126028
\item
2602226029
\textbf{Named Function Types:}
@@ -26057,8 +26064,7 @@ \section*{Appendix: Algorithmic Subtyping}
2605726064
\SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2605826065
\item
2605926066
$B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
26060-
have the same canonical syntax,
26061-
for each $i \in 0 .. k$.
26067+
are subtypes of each other, for each $i \in 0 .. k$.
2606226068
\end{itemize}
2606326069

2606426070
\commentary{%

0 commit comments

Comments
 (0)