@@ -23607,7 +23607,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2360723607 \DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
2360823608 if \SubtypeNE{T_1}{T_2}.
2360923609
23610- \commentary{
23610+ \commentary{%
2361123611 In this and in the following cases, both types must be interface types.%
2361223612 }
2361323613\item
@@ -23864,7 +23864,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2386423864 \DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
2386523865\end{itemize}
2386623866
23867- \rationale{
23867+ \rationale{%
2386823868The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
2386923869are somewhat redundant in that they explicitly specify
2387023870a lot of pairs of symmetric cases.
@@ -25682,6 +25682,7 @@ \subsection{Type Promotion}
2568225682}
2568325683
2568425684\LMHash{}%
25685+ \BlindDefineSymbol{\ell, v}%
2568525686Let $\ell$ be a location,
2568625687and let $v$ be a local variable which is in scope at $\ell$.
2568725688Assume that $\ell$ occurs after the declaration of $v$.
@@ -25705,34 +25706,33 @@ \subsection{Type Promotion}
2570525706
2570625707\LMHash{}%
2570725708In particular,
25708- a check of the form \code{$v$\,\,==\,\,\NULL},
25709- \code{\NULL\,\,==\,\,$v$},
25710- or \code{$v$\,\,\IS\,\,Null}
25709+ an expression of the form \code{$v$\,\,==\,\,\NULL} or
25710+ \code{\NULL\,\,==\,\,$v$}
2571125711where $v$ has type $T$ at $\ell$
2571225712promotes the type of $v$
25713- to \code{Null} in the \TRUE{} continuation,
25714- and to \NonNullType{$T$} in the \FALSE{} continuation.
25715-
25716- %% TODO(eernst), for review: The null safety spec says that `T?` is
25717- %% promoted to `T`, but implementations _do_ promote `X extends int?` to
25718- %% `X & int`. So we may be able to specify something which will yield
25719- %% slightly more precise types, and which is more precisely the implemented
25720- %% behavior.
25721- \LMHash{}%
25722- A check of the form \code{$v$\,\,!=\,\,\NULL},
25723- \code{\NULL\,\,!=\,\,$v$},
25724- or \code{$v$\,\,\IS\,\,$T$}
25725- where $v$ has static type $T?$ at $\ell$
25713+ to \NonNullType{$T$} in the \FALSE{} continuation;
25714+ and an expression of the form \code{$v$\,\,!=\,\,\NULL} or
25715+ \code{\NULL\,\,!=\,\,$v$}
25716+ where $v$ has static type $T$ at $\ell$
25717+ promotes the type of $v$
25718+ to \NonNullType{$T$} in the \TRUE{} continuation.
25719+
25720+ \LMHash{}%
25721+ Similarly, a type test of the form \code{$v$\,\,\IS\,\,$T$}
2572625722promotes the type of $v$
2572725723to $T$ in the \TRUE{} continuation,
25728- and to \code{Null} in the \FALSE{} continuation.
25724+ and a type check of the form \code{$v$\,\,\AS\,\,$T$}
25725+ promotes the type of $v$
25726+ to $T$ in the continuation where the expression evaluated to an object
25727+ (\commentary{that is, it did not throw}).
2572925728
2573025729\commentary{%
2573125730 The resulting type of $v$ may be the obvious one, e.g.,
2573225731 \code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
2573325732 but it may also give rise to a demotion
25734- (changing the type of $v$ to a supertype of the type of $v$ at $\ell$),
25735- and it may have no effect on the type of $v$
25733+ (changing the type of $v$ to a supertype of the type of $v$ at $\ell$
25734+ and potentially promoting it to some other type of interest).
25735+ It may also have no effect on the type of $v$
2573625736 (e.g., when the static type of $e$ is not a type of interest).
2573725737 These details will be specified in a future version of this specification.
2573825738
@@ -25887,15 +25887,20 @@ \section*{Appendix: Algorithmic Subtyping}
2588725887the one which is specified in Fig.~\ref{fig:subtypeRules}.
2588825888It shows that Dart subtyping relationships can be decided
2588925889with good performance.
25890+ This section is not normative.
2589025891
2589125892\LMHash{}%
2589225893In this algorithm, types are considered to be the same when they have
2589325894the same canonical syntax
2589425895(\ref{theCanonicalSyntaxOfTypes}).
25896+ \commentary{%
25897+ For example, \SubtypeStd{\code{C}}{\code{C}} does not hold if
25898+ the two occurrences of \code{C} refer to declarations in different libraries.%
25899+ }
2589525900The algorithm must be performed such that the first case that matches
2589625901is always the case which is performed.
2589725902The algorithm produces results which are both positive and negative
25898- (\commentary{
25903+ (\commentary{%
2589925904 that is, in some situations the subtype relation is determined to be false%
2590025905}),
2590125906which is important for performance because
@@ -25907,16 +25912,18 @@ \section*{Appendix: Algorithmic Subtyping}
2590725912\begin{itemize}
2590825913\item
2590925914 \textbf{Reflexivity:}
25910- if $T_0$ and $T_1$ are the same type then \SubtypeNE{T_0}{T_1}
25915+ if $T_0$ and $T_1$ are the same atomic type then \SubtypeNE{T_0}{T_1}.
2591125916
2591225917 \commentary{%
25913- Note that this check is necessary as the base case for primitive types,
25918+ This check is necessary as the base case for primitive types,
2591425919 and type variables, but not for composite types.
2591525920 In particular, a structural equality check is admissible,
2591625921 but not required here.
25917- Pragmatically, non-constant time identity checks here are
25918- counter-productive.
25919- So this rule should only be used when $T$ is atomic.%
25922+ Non-constant time identity checks here are counter-productive
25923+ because the following rules will yield the same result anyway,
25924+ so we may just perform a full traversal of a large structure twice
25925+ for no reason.
25926+ Hence, this rule is only used when the given type is atomic.%
2592025927 }
2592125928\item
2592225929 \textbf{Right Top:}
@@ -25926,7 +25933,7 @@ \section*{Appendix: Algorithmic Subtyping}
2592625933 if $T_0$ is \DYNAMIC{} or \VOID{}
2592725934 then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
2592825935\item
25929- \textbf{Left Bottom:}
25936+ \textbf{Bottom:}
2593025937 if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
2593125938\item
2593225939 \textbf{Right Object:}
@@ -25979,7 +25986,7 @@ \section*{Appendix: Algorithmic Subtyping}
2597925986 or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
2598025987 then \SubtypeNE{T_0}{T_1}.
2598125988
25982- \commentary{
25989+ \commentary{%
2598325990 Note that this rule is admissible, and can be safely elided if desired.%
2598425991 }
2598525992\item
@@ -26062,7 +26069,7 @@ \section*{Appendix: Algorithmic Subtyping}
2606226069 for $i \in 0 .. q$.
2606326070 \item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2606426071 \item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
26065- have the same canonical syntax , for $i \in 0 .. k$.
26072+ are subtypes of each other , for $i \in 0 .. k$.
2606626073 \end{itemize}
2606726074\item
2606826075 \textbf{Named Function Types:}
@@ -26103,8 +26110,7 @@ \section*{Appendix: Algorithmic Subtyping}
2610326110 \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2610426111 \item
2610526112 $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
26106- have the same canonical syntax,
26107- for each $i \in 0 .. k$.
26113+ are subtypes of each other, for each $i \in 0 .. k$.
2610826114 \end{itemize}
2610926115
2611026116 \commentary{%
0 commit comments