Skip to content

Commit 66420dd

Browse files
committed
Review response
1 parent 27ed4a3 commit 66420dd

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
@@ -23095,7 +23095,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2309523095
\DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
2309623096
if \SubtypeNE{T_1}{T_2}.
2309723097

23098-
\commentary{
23098+
\commentary{%
2309923099
In this and in the following cases, both types must be interface types.%
2310023100
}
2310123101
\item
@@ -23352,7 +23352,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2335223352
\DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
2335323353
\end{itemize}
2335423354

23355-
\rationale{
23355+
\rationale{%
2335623356
The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
2335723357
are somewhat redundant in that they explicitly specify
2335823358
a lot of pairs of symmetric cases.
@@ -25144,6 +25144,7 @@ \subsection{Type Promotion}
2514425144
}
2514525145

2514625146
\LMHash{}%
25147+
\BlindDefineSymbol{\ell, v}%
2514725148
Let $\ell$ be a location,
2514825149
and let $v$ be a local variable which is in scope at $\ell$.
2514925150
Assume that $\ell$ occurs after the declaration of $v$.
@@ -25167,34 +25168,33 @@ \subsection{Type Promotion}
2516725168

2516825169
\LMHash{}%
2516925170
In particular,
25170-
a check of the form \code{$v$\,\,==\,\,\NULL},
25171-
\code{\NULL\,\,==\,\,$v$},
25172-
or \code{$v$\,\,\IS\,\,Null}
25171+
an expression of the form \code{$v$\,\,==\,\,\NULL} or
25172+
\code{\NULL\,\,==\,\,$v$}
2517325173
where $v$ has type $T$ at $\ell$
2517425174
promotes the type of $v$
25175-
to \code{Null} in the \TRUE{} continuation,
25176-
and to \NonNullType{$T$} in the \FALSE{} continuation.
25177-
25178-
%% TODO(eernst), for review: The null safety spec says that `T?` is
25179-
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25180-
%% `X & int`. So we may be able to specify something which will yield
25181-
%% slightly more precise types, and which is more precisely the implemented
25182-
%% behavior.
25183-
\LMHash{}%
25184-
A check of the form \code{$v$\,\,!=\,\,\NULL},
25185-
\code{\NULL\,\,!=\,\,$v$},
25186-
or \code{$v$\,\,\IS\,\,$T$}
25187-
where $v$ has static type $T?$ at $\ell$
25175+
to \NonNullType{$T$} in the \FALSE{} continuation;
25176+
and an expression of the form \code{$v$\,\,!=\,\,\NULL} or
25177+
\code{\NULL\,\,!=\,\,$v$}
25178+
where $v$ has static type $T$ at $\ell$
25179+
promotes the type of $v$
25180+
to \NonNullType{$T$} in the \TRUE{} continuation.
25181+
25182+
\LMHash{}%
25183+
Similarly, a type test of the form \code{$v$\,\,\IS\,\,$T$}
2518825184
promotes the type of $v$
2518925185
to $T$ in the \TRUE{} continuation,
25190-
and to \code{Null} in the \FALSE{} continuation.
25186+
and a type check of the form \code{$v$\,\,\AS\,\,$T$}
25187+
promotes the type of $v$
25188+
to $T$ in the continuation where the expression evaluated to an object
25189+
(\commentary{that is, it did not throw}).
2519125190

2519225191
\commentary{%
2519325192
The resulting type of $v$ may be the obvious one, e.g.,
2519425193
\code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
2519525194
but it may also give rise to a demotion
25196-
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$),
25197-
and it may have no effect on the type of $v$
25195+
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$
25196+
and potentially promoting it to some other type of interest).
25197+
It may also have no effect on the type of $v$
2519825198
(e.g., when the static type of $e$ is not a type of interest).
2519925199
These details will be specified in a future version of this specification.
2520025200

@@ -25367,15 +25367,20 @@ \section*{Appendix: Algorithmic Subtyping}
2536725367
the one which is specified in Fig.~\ref{fig:subtypeRules}.
2536825368
It shows that Dart subtyping relationships can be decided
2536925369
with good performance.
25370+
This section is not normative.
2537025371

2537125372
\LMHash{}%
2537225373
In this algorithm, types are considered to be the same when they have
2537325374
the same canonical syntax
2537425375
(\ref{theCanonicalSyntaxOfTypes}).
25376+
\commentary{%
25377+
For example, \SubtypeStd{\code{C}}{\code{C}} does not hold if
25378+
the two occurrences of \code{C} refer to declarations in different libraries.%
25379+
}
2537525380
The algorithm must be performed such that the first case that matches
2537625381
is always the case which is performed.
2537725382
The algorithm produces results which are both positive and negative
25378-
(\commentary{
25383+
(\commentary{%
2537925384
that is, in some situations the subtype relation is determined to be false%
2538025385
}),
2538125386
which is important for performance because
@@ -25387,16 +25392,18 @@ \section*{Appendix: Algorithmic Subtyping}
2538725392
\begin{itemize}
2538825393
\item
2538925394
\textbf{Reflexivity:}
25390-
if $T_0$ and $T_1$ are the same type then \SubtypeNE{T_0}{T_1}
25395+
if $T_0$ and $T_1$ are the same atomic type then \SubtypeNE{T_0}{T_1}.
2539125396

2539225397
\commentary{%
25393-
Note that this check is necessary as the base case for primitive types,
25398+
This check is necessary as the base case for primitive types,
2539425399
and type variables, but not for composite types.
2539525400
In particular, a structural equality check is admissible,
2539625401
but not required here.
25397-
Pragmatically, non-constant time identity checks here are
25398-
counter-productive.
25399-
So this rule should only be used when $T$ is atomic.%
25402+
Non-constant time identity checks here are counter-productive
25403+
because the following rules will yield the same result anyway,
25404+
so we may just perform a full traversal of a large structure twice
25405+
for no reason.
25406+
Hence, this rule is only used when the given type is atomic.%
2540025407
}
2540125408
\item
2540225409
\textbf{Right Top:}
@@ -25406,7 +25413,7 @@ \section*{Appendix: Algorithmic Subtyping}
2540625413
if $T_0$ is \DYNAMIC{} or \VOID{}
2540725414
then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
2540825415
\item
25409-
\textbf{Left Bottom:}
25416+
\textbf{Bottom:}
2541025417
if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
2541125418
\item
2541225419
\textbf{Right Object:}
@@ -25459,7 +25466,7 @@ \section*{Appendix: Algorithmic Subtyping}
2545925466
or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
2546025467
then \SubtypeNE{T_0}{T_1}.
2546125468

25462-
\commentary{
25469+
\commentary{%
2546325470
Note that this rule is admissible, and can be safely elided if desired.%
2546425471
}
2546525472
\item
@@ -25542,7 +25549,7 @@ \section*{Appendix: Algorithmic Subtyping}
2554225549
for $i \in 0 .. q$.
2554325550
\item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2554425551
\item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
25545-
have the same canonical syntax, for $i \in 0 .. k$.
25552+
are subtypes of each other, for $i \in 0 .. k$.
2554625553
\end{itemize}
2554725554
\item
2554825555
\textbf{Named Function Types:}
@@ -25583,8 +25590,7 @@ \section*{Appendix: Algorithmic Subtyping}
2558325590
\SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2558425591
\item
2558525592
$B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
25586-
have the same canonical syntax,
25587-
for each $i \in 0 .. k$.
25593+
are subtypes of each other, for each $i \in 0 .. k$.
2558825594
\end{itemize}
2558925595

2559025596
\commentary{%

0 commit comments

Comments
 (0)