@@ -13704,7 +13704,7 @@ \subsubsection{Ordinary Invocation}
1370413704Otherwise, let $d$ be the result of getter lookup
1370513705for $m$ in $T$ with respect to $L$,
1370613706and let $F$ be the return type of $d$.
13707- (\commentary{
13707+ (\commentary{%
1370813708Since \code{$T$.$m$} exists we cannot have a failure in both lookups.%
1370913709})
1371013710If the getter return type $F$ is an interface type
@@ -13728,7 +13728,7 @@ \subsubsection{Ordinary Invocation}
1372813728\LMHash{}%
1372913729It is a compile-time error to invoke an instance method on a type literal
1373013730that is immediately followed by the token `.' (a period).
13731- \commentary{
13731+ \commentary{%
1373213732For instance, \code{int.toString()} is an error.%
1373313733}
1373413734
@@ -20316,13 +20316,13 @@ \subsection{Type Aliases}
2031620316it is a compile-time error if $T$ is not regular-bounded,
2031720317and it is a compile-time error if any type occurring in $T$ is not well-bounded.
2031820318
20319- \commentary{
20319+ \commentary{%
2032020320This means that the bounds declared for
2032120321the formal type parameters of a generic type alias
2032220322must be such that when they are satisfied,
2032320323the bounds that pertain to the body are also satisfied,
2032420324and a type occurring as a subterm of the body can violate its bounds,
20325- but only if it is a correct super-bounded type.
20325+ but only if it is a correct super-bounded type.%
2032620326}
2032720327
2032820328\LMHash{}%
@@ -22363,7 +22363,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2236322363 \DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
2236422364 if \SubtypeNE{T_1}{T_2}.
2236522365
22366- \commentary{
22366+ \commentary{%
2236722367 In this and in the following cases, both types must be interface types.%
2236822368 }
2236922369\item
@@ -22620,7 +22620,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2262022620 \DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
2262122621\end{itemize}
2262222622
22623- \rationale{
22623+ \rationale{%
2262422624The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
2262522625are somewhat redundant in that they explicitly specify
2262622626a lot of pairs of symmetric cases.
@@ -24412,6 +24412,7 @@ \subsection{Type Promotion}
2441224412}
2441324413
2441424414\LMHash{}%
24415+ \BlindDefineSymbol{\ell, v}%
2441524416Let $\ell$ be a location,
2441624417and let $v$ be a local variable which is in scope at $\ell$.
2441724418Assume that $\ell$ occurs after the declaration of $v$.
@@ -24435,34 +24436,33 @@ \subsection{Type Promotion}
2443524436
2443624437\LMHash{}%
2443724438In particular,
24438- a check of the form \code{$v$\,\,==\,\,\NULL},
24439- \code{\NULL\,\,==\,\,$v$},
24440- or \code{$v$\,\,\IS\,\,Null}
24439+ an expression of the form \code{$v$\,\,==\,\,\NULL} or
24440+ \code{\NULL\,\,==\,\,$v$}
2444124441where $v$ has type $T$ at $\ell$
2444224442promotes the type of $v$
24443- to \code{Null} in the \TRUE{} continuation,
24444- and to \NonNullType{$T$} in the \FALSE{} continuation.
24445-
24446- %% TODO(eernst), for review: The null safety spec says that `T?` is
24447- %% promoted to `T`, but implementations _do_ promote `X extends int?` to
24448- %% `X & int`. So we may be able to specify something which will yield
24449- %% slightly more precise types, and which is more precisely the implemented
24450- %% behavior.
24451- \LMHash{}%
24452- A check of the form \code{$v$\,\,!=\,\,\NULL},
24453- \code{\NULL\,\,!=\,\,$v$},
24454- or \code{$v$\,\,\IS\,\,$T$}
24455- where $v$ has static type $T?$ at $\ell$
24443+ to \NonNullType{$T$} in the \FALSE{} continuation;
24444+ and an expression of the form \code{$v$\,\,!=\,\,\NULL} or
24445+ \code{\NULL\,\,!=\,\,$v$}
24446+ where $v$ has static type $T$ at $\ell$
24447+ promotes the type of $v$
24448+ to \NonNullType{$T$} in the \TRUE{} continuation.
24449+
24450+ \LMHash{}%
24451+ Similarly, a type test of the form \code{$v$\,\,\IS\,\,$T$}
2445624452promotes the type of $v$
2445724453to $T$ in the \TRUE{} continuation,
24458- and to \code{Null} in the \FALSE{} continuation.
24454+ and a type check of the form \code{$v$\,\,\AS\,\,$T$}
24455+ promotes the type of $v$
24456+ to $T$ in the continuation where the expression evaluated to an object
24457+ (\commentary{that is, it did not throw}).
2445924458
2446024459\commentary{%
2446124460The resulting type of $v$ may be the obvious one, e.g.,
2446224461\code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
2446324462but it may also give rise to a demotion
24464- (changing the type of $v$ to a supertype of the type of $v$ at $\ell$),
24465- and it may have no effect on the type of $v$
24463+ (changing the type of $v$ to a supertype of the type of $v$ at $\ell$
24464+ and potentially promoting it to some other type of interest).
24465+ It may also have no effect on the type of $v$
2446624466(e.g., when the static type of $e$ is not a type of interest).
2446724467These details will be specified in a future version of this specification.
2446824468
@@ -24624,15 +24624,20 @@ \section*{Appendix: Algorithmic Subtyping}
2462424624the one which is specified in Fig.~\ref{fig:subtypeRules}.
2462524625It shows that Dart subtyping relationships can be decided
2462624626with good performance.
24627+ This section is not normative.
2462724628
2462824629\LMHash{}%
2462924630In this algorithm, types are considered to be the same when they have
2463024631the same canonical syntax
2463124632(\ref{theCanonicalSyntaxOfTypes}).
24633+ \commentary{%
24634+ For example, \SubtypeStd{\code{C}}{\code{C}} does not hold if
24635+ the two occurrences of \code{C} refer to declarations in different libraries.%
24636+ }
2463224637The algorithm must be performed such that the first case that matches
2463324638is always the case which is performed.
2463424639The algorithm produces results which are both positive and negative
24635- (\commentary{
24640+ (\commentary{%
2463624641 that is, in some situations the subtype relation is determined to be false%
2463724642}),
2463824643which is important for performance because
@@ -24644,16 +24649,18 @@ \section*{Appendix: Algorithmic Subtyping}
2464424649\begin{itemize}
2464524650\item
2464624651 \textbf{Reflexivity:}
24647- if $T_0$ and $T_1$ are the same type then \SubtypeNE{T_0}{T_1}
24652+ if $T_0$ and $T_1$ are the same atomic type then \SubtypeNE{T_0}{T_1}.
2464824653
2464924654 \commentary{%
24650- Note that this check is necessary as the base case for primitive types,
24655+ This check is necessary as the base case for primitive types,
2465124656 and type variables, but not for composite types.
2465224657 In particular, a structural equality check is admissible,
2465324658 but not required here.
24654- Pragmatically, non-constant time identity checks here are
24655- counter-productive.
24656- So this rule should only be used when $T$ is atomic.%
24659+ Non-constant time identity checks here are counter-productive
24660+ because the following rules will yield the same result anyway,
24661+ so we may just perform a full traversal of a large structure twice
24662+ for no reason.
24663+ Hence, this rule is only used when the given type is atomic.%
2465724664 }
2465824665\item
2465924666 \textbf{Right Top:}
@@ -24663,7 +24670,7 @@ \section*{Appendix: Algorithmic Subtyping}
2466324670 if $T_0$ is \DYNAMIC{} or \VOID{}
2466424671 then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
2466524672\item
24666- \textbf{Left Bottom:}
24673+ \textbf{Bottom:}
2466724674 if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
2466824675\item
2466924676 \textbf{Right Object:}
@@ -24716,7 +24723,7 @@ \section*{Appendix: Algorithmic Subtyping}
2471624723 or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
2471724724 then \SubtypeNE{T_0}{T_1}.
2471824725
24719- \commentary{
24726+ \commentary{%
2472024727 Note that this rule is admissible, and can be safely elided if desired.%
2472124728 }
2472224729\item
@@ -24799,7 +24806,7 @@ \section*{Appendix: Algorithmic Subtyping}
2479924806 for $i \in 0 .. q$.
2480024807 \item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2480124808 \item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
24802- have the same canonical syntax , for $i \in 0 .. k$.
24809+ are subtypes of each other , for $i \in 0 .. k$.
2480324810 \end{itemize}
2480424811\item
2480524812 \textbf{Named Function Types:}
@@ -24840,8 +24847,7 @@ \section*{Appendix: Algorithmic Subtyping}
2484024847 \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2484124848 \item
2484224849 $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
24843- have the same canonical syntax,
24844- for each $i \in 0 .. k$.
24850+ are subtypes of each other, for each $i \in 0 .. k$.
2484524851 \end{itemize}
2484624852
2484724853 \commentary{%
0 commit comments