Skip to content

Commit 7dc0604

Browse files
committed
Review response
1 parent acd3824 commit 7dc0604

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
@@ -23140,7 +23140,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2314023140
\DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
2314123141
if \SubtypeNE{T_1}{T_2}.
2314223142

23143-
\commentary{
23143+
\commentary{%
2314423144
In this and in the following cases, both types must be interface types.%
2314523145
}
2314623146
\item
@@ -23397,7 +23397,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2339723397
\DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
2339823398
\end{itemize}
2339923399

23400-
\rationale{
23400+
\rationale{%
2340123401
The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
2340223402
are somewhat redundant in that they explicitly specify
2340323403
a lot of pairs of symmetric cases.
@@ -25189,6 +25189,7 @@ \subsection{Type Promotion}
2518925189
}
2519025190

2519125191
\LMHash{}%
25192+
\BlindDefineSymbol{\ell, v}%
2519225193
Let $\ell$ be a location,
2519325194
and let $v$ be a local variable which is in scope at $\ell$.
2519425195
Assume that $\ell$ occurs after the declaration of $v$.
@@ -25212,34 +25213,33 @@ \subsection{Type Promotion}
2521225213

2521325214
\LMHash{}%
2521425215
In particular,
25215-
a check of the form \code{$v$\,\,==\,\,\NULL},
25216-
\code{\NULL\,\,==\,\,$v$},
25217-
or \code{$v$\,\,\IS\,\,Null}
25216+
an expression of the form \code{$v$\,\,==\,\,\NULL} or
25217+
\code{\NULL\,\,==\,\,$v$}
2521825218
where $v$ has type $T$ at $\ell$
2521925219
promotes the type of $v$
25220-
to \code{Null} in the \TRUE{} continuation,
25221-
and to \NonNullType{$T$} in the \FALSE{} continuation.
25222-
25223-
%% TODO(eernst), for review: The null safety spec says that `T?` is
25224-
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25225-
%% `X & int`. So we may be able to specify something which will yield
25226-
%% slightly more precise types, and which is more precisely the implemented
25227-
%% behavior.
25228-
\LMHash{}%
25229-
A check of the form \code{$v$\,\,!=\,\,\NULL},
25230-
\code{\NULL\,\,!=\,\,$v$},
25231-
or \code{$v$\,\,\IS\,\,$T$}
25232-
where $v$ has static type $T?$ at $\ell$
25220+
to \NonNullType{$T$} in the \FALSE{} continuation;
25221+
and an expression of the form \code{$v$\,\,!=\,\,\NULL} or
25222+
\code{\NULL\,\,!=\,\,$v$}
25223+
where $v$ has static type $T$ at $\ell$
25224+
promotes the type of $v$
25225+
to \NonNullType{$T$} in the \TRUE{} continuation.
25226+
25227+
\LMHash{}%
25228+
Similarly, a type test of the form \code{$v$\,\,\IS\,\,$T$}
2523325229
promotes the type of $v$
2523425230
to $T$ in the \TRUE{} continuation,
25235-
and to \code{Null} in the \FALSE{} continuation.
25231+
and a type check of the form \code{$v$\,\,\AS\,\,$T$}
25232+
promotes the type of $v$
25233+
to $T$ in the continuation where the expression evaluated to an object
25234+
(\commentary{that is, it did not throw}).
2523625235

2523725236
\commentary{%
2523825237
The resulting type of $v$ may be the obvious one, e.g.,
2523925238
\code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
2524025239
but it may also give rise to a demotion
25241-
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$),
25242-
and it may have no effect on the type of $v$
25240+
(changing the type of $v$ to a supertype of the type of $v$ at $\ell$
25241+
and potentially promoting it to some other type of interest).
25242+
It may also have no effect on the type of $v$
2524325243
(e.g., when the static type of $e$ is not a type of interest).
2524425244
These details will be specified in a future version of this specification.
2524525245

@@ -25412,15 +25412,20 @@ \section*{Appendix: Algorithmic Subtyping}
2541225412
the one which is specified in Fig.~\ref{fig:subtypeRules}.
2541325413
It shows that Dart subtyping relationships can be decided
2541425414
with good performance.
25415+
This section is not normative.
2541525416

2541625417
\LMHash{}%
2541725418
In this algorithm, types are considered to be the same when they have
2541825419
the same canonical syntax
2541925420
(\ref{theCanonicalSyntaxOfTypes}).
25421+
\commentary{%
25422+
For example, \SubtypeStd{\code{C}}{\code{C}} does not hold if
25423+
the two occurrences of \code{C} refer to declarations in different libraries.%
25424+
}
2542025425
The algorithm must be performed such that the first case that matches
2542125426
is always the case which is performed.
2542225427
The algorithm produces results which are both positive and negative
25423-
(\commentary{
25428+
(\commentary{%
2542425429
that is, in some situations the subtype relation is determined to be false%
2542525430
}),
2542625431
which is important for performance because
@@ -25432,16 +25437,18 @@ \section*{Appendix: Algorithmic Subtyping}
2543225437
\begin{itemize}
2543325438
\item
2543425439
\textbf{Reflexivity:}
25435-
if $T_0$ and $T_1$ are the same type then \SubtypeNE{T_0}{T_1}
25440+
if $T_0$ and $T_1$ are the same atomic type then \SubtypeNE{T_0}{T_1}.
2543625441

2543725442
\commentary{%
25438-
Note that this check is necessary as the base case for primitive types,
25443+
This check is necessary as the base case for primitive types,
2543925444
and type variables, but not for composite types.
2544025445
In particular, a structural equality check is admissible,
2544125446
but not required here.
25442-
Pragmatically, non-constant time identity checks here are
25443-
counter-productive.
25444-
So this rule should only be used when $T$ is atomic.%
25447+
Non-constant time identity checks here are counter-productive
25448+
because the following rules will yield the same result anyway,
25449+
so we may just perform a full traversal of a large structure twice
25450+
for no reason.
25451+
Hence, this rule is only used when the given type is atomic.%
2544525452
}
2544625453
\item
2544725454
\textbf{Right Top:}
@@ -25451,7 +25458,7 @@ \section*{Appendix: Algorithmic Subtyping}
2545125458
if $T_0$ is \DYNAMIC{} or \VOID{}
2545225459
then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
2545325460
\item
25454-
\textbf{Left Bottom:}
25461+
\textbf{Bottom:}
2545525462
if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
2545625463
\item
2545725464
\textbf{Right Object:}
@@ -25504,7 +25511,7 @@ \section*{Appendix: Algorithmic Subtyping}
2550425511
or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
2550525512
then \SubtypeNE{T_0}{T_1}.
2550625513

25507-
\commentary{
25514+
\commentary{%
2550825515
Note that this rule is admissible, and can be safely elided if desired.%
2550925516
}
2551025517
\item
@@ -25587,7 +25594,7 @@ \section*{Appendix: Algorithmic Subtyping}
2558725594
for $i \in 0 .. q$.
2558825595
\item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2558925596
\item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
25590-
have the same canonical syntax, for $i \in 0 .. k$.
25597+
are subtypes of each other, for $i \in 0 .. k$.
2559125598
\end{itemize}
2559225599
\item
2559325600
\textbf{Named Function Types:}
@@ -25628,8 +25635,7 @@ \section*{Appendix: Algorithmic Subtyping}
2562825635
\SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2562925636
\item
2563025637
$B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
25631-
have the same canonical syntax,
25632-
for each $i \in 0 .. k$.
25638+
are subtypes of each other, for each $i \in 0 .. k$.
2563325639
\end{itemize}
2563425640

2563525641
\commentary{%

0 commit comments

Comments
 (0)