@@ -13717,7 +13717,7 @@ \subsubsection{Ordinary Invocation}
1371713717Otherwise, let $d$ be the result of getter lookup
1371813718for $m$ in $T$ with respect to $L$,
1371913719and let $F$ be the return type of $d$.
13720- (\commentary{
13720+ (\commentary{%
1372113721Since \code{$T$.$m$} exists we cannot have a failure in both lookups.%
1372213722})
1372313723If the getter return type $F$ is an interface type
@@ -13741,7 +13741,7 @@ \subsubsection{Ordinary Invocation}
1374113741\LMHash{}%
1374213742It is a compile-time error to invoke an instance method on a type literal
1374313743that is immediately followed by the token `.' (a period).
13744- \commentary{
13744+ \commentary{%
1374513745For instance, \code{int.toString()} is an error.%
1374613746}
1374713747
@@ -20337,13 +20337,13 @@ \subsection{Type Aliases}
2033720337it is a compile-time error if $T$ is not regular-bounded,
2033820338and it is a compile-time error if any type occurring in $T$ is not well-bounded.
2033920339
20340- \commentary{
20340+ \commentary{%
2034120341This means that the bounds declared for
2034220342the formal type parameters of a generic type alias
2034320343must be such that when they are satisfied,
2034420344the bounds that pertain to the body are also satisfied,
2034520345and a type occurring as a subterm of the body can violate its bounds,
20346- but only if it is a correct super-bounded type.
20346+ but only if it is a correct super-bounded type.%
2034720347}
2034820348
2034920349\LMHash{}%
@@ -22384,7 +22384,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2238422384 \DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
2238522385 if \SubtypeNE{T_1}{T_2}.
2238622386
22387- \commentary{
22387+ \commentary{%
2238822388 In this and in the following cases, both types must be interface types.%
2238922389 }
2239022390\item
@@ -22641,7 +22641,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2264122641 \DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
2264222642\end{itemize}
2264322643
22644- \rationale{
22644+ \rationale{%
2264522645The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
2264622646are somewhat redundant in that they explicitly specify
2264722647a lot of pairs of symmetric cases.
@@ -24433,6 +24433,7 @@ \subsection{Type Promotion}
2443324433}
2443424434
2443524435\LMHash{}%
24436+ \BlindDefineSymbol{\ell, v}%
2443624437Let $\ell$ be a location,
2443724438and let $v$ be a local variable which is in scope at $\ell$.
2443824439Assume that $\ell$ occurs after the declaration of $v$.
@@ -24456,34 +24457,33 @@ \subsection{Type Promotion}
2445624457
2445724458\LMHash{}%
2445824459In particular,
24459- a check of the form \code{$v$\,\,==\,\,\NULL},
24460- \code{\NULL\,\,==\,\,$v$},
24461- or \code{$v$\,\,\IS\,\,Null}
24460+ an expression of the form \code{$v$\,\,==\,\,\NULL} or
24461+ \code{\NULL\,\,==\,\,$v$}
2446224462where $v$ has type $T$ at $\ell$
2446324463promotes the type of $v$
24464- to \code{Null} in the \TRUE{} continuation,
24465- and to \NonNullType{$T$} in the \FALSE{} continuation.
24466-
24467- %% TODO(eernst), for review: The null safety spec says that `T?` is
24468- %% promoted to `T`, but implementations _do_ promote `X extends int?` to
24469- %% `X & int`. So we may be able to specify something which will yield
24470- %% slightly more precise types, and which is more precisely the implemented
24471- %% behavior.
24472- \LMHash{}%
24473- A check of the form \code{$v$\,\,!=\,\,\NULL},
24474- \code{\NULL\,\,!=\,\,$v$},
24475- or \code{$v$\,\,\IS\,\,$T$}
24476- where $v$ has static type $T?$ at $\ell$
24464+ to \NonNullType{$T$} in the \FALSE{} continuation;
24465+ and an expression of the form \code{$v$\,\,!=\,\,\NULL} or
24466+ \code{\NULL\,\,!=\,\,$v$}
24467+ where $v$ has static type $T$ at $\ell$
24468+ promotes the type of $v$
24469+ to \NonNullType{$T$} in the \TRUE{} continuation.
24470+
24471+ \LMHash{}%
24472+ Similarly, a type test of the form \code{$v$\,\,\IS\,\,$T$}
2447724473promotes the type of $v$
2447824474to $T$ in the \TRUE{} continuation,
24479- and to \code{Null} in the \FALSE{} continuation.
24475+ and a type check of the form \code{$v$\,\,\AS\,\,$T$}
24476+ promotes the type of $v$
24477+ to $T$ in the continuation where the expression evaluated to an object
24478+ (\commentary{that is, it did not throw}).
2448024479
2448124480\commentary{%
2448224481The resulting type of $v$ may be the obvious one, e.g.,
2448324482\code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
2448424483but it may also give rise to a demotion
24485- (changing the type of $v$ to a supertype of the type of $v$ at $\ell$),
24486- and it may have no effect on the type of $v$
24484+ (changing the type of $v$ to a supertype of the type of $v$ at $\ell$
24485+ and potentially promoting it to some other type of interest).
24486+ It may also have no effect on the type of $v$
2448724487(e.g., when the static type of $e$ is not a type of interest).
2448824488These details will be specified in a future version of this specification.
2448924489
@@ -24655,15 +24655,20 @@ \section*{Appendix: Algorithmic Subtyping}
2465524655the one which is specified in Fig.~\ref{fig:subtypeRules}.
2465624656It shows that Dart subtyping relationships can be decided
2465724657with good performance.
24658+ This section is not normative.
2465824659
2465924660\LMHash{}%
2466024661In this algorithm, types are considered to be the same when they have
2466124662the same canonical syntax
2466224663(\ref{theCanonicalSyntaxOfTypes}).
24664+ \commentary{%
24665+ For example, \SubtypeStd{\code{C}}{\code{C}} does not hold if
24666+ the two occurrences of \code{C} refer to declarations in different libraries.%
24667+ }
2466324668The algorithm must be performed such that the first case that matches
2466424669is always the case which is performed.
2466524670The algorithm produces results which are both positive and negative
24666- (\commentary{
24671+ (\commentary{%
2466724672 that is, in some situations the subtype relation is determined to be false%
2466824673}),
2466924674which is important for performance because
@@ -24675,16 +24680,18 @@ \section*{Appendix: Algorithmic Subtyping}
2467524680\begin{itemize}
2467624681\item
2467724682 \textbf{Reflexivity:}
24678- if $T_0$ and $T_1$ are the same type then \SubtypeNE{T_0}{T_1}
24683+ if $T_0$ and $T_1$ are the same atomic type then \SubtypeNE{T_0}{T_1}.
2467924684
2468024685 \commentary{%
24681- Note that this check is necessary as the base case for primitive types,
24686+ This check is necessary as the base case for primitive types,
2468224687 and type variables, but not for composite types.
2468324688 In particular, a structural equality check is admissible,
2468424689 but not required here.
24685- Pragmatically, non-constant time identity checks here are
24686- counter-productive.
24687- So this rule should only be used when $T$ is atomic.%
24690+ Non-constant time identity checks here are counter-productive
24691+ because the following rules will yield the same result anyway,
24692+ so we may just perform a full traversal of a large structure twice
24693+ for no reason.
24694+ Hence, this rule is only used when the given type is atomic.%
2468824695 }
2468924696\item
2469024697 \textbf{Right Top:}
@@ -24694,7 +24701,7 @@ \section*{Appendix: Algorithmic Subtyping}
2469424701 if $T_0$ is \DYNAMIC{} or \VOID{}
2469524702 then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
2469624703\item
24697- \textbf{Left Bottom:}
24704+ \textbf{Bottom:}
2469824705 if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
2469924706\item
2470024707 \textbf{Right Object:}
@@ -24747,7 +24754,7 @@ \section*{Appendix: Algorithmic Subtyping}
2474724754 or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
2474824755 then \SubtypeNE{T_0}{T_1}.
2474924756
24750- \commentary{
24757+ \commentary{%
2475124758 Note that this rule is admissible, and can be safely elided if desired.%
2475224759 }
2475324760\item
@@ -24830,7 +24837,7 @@ \section*{Appendix: Algorithmic Subtyping}
2483024837 for $i \in 0 .. q$.
2483124838 \item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2483224839 \item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
24833- have the same canonical syntax , for $i \in 0 .. k$.
24840+ are subtypes of each other , for $i \in 0 .. k$.
2483424841 \end{itemize}
2483524842\item
2483624843 \textbf{Named Function Types:}
@@ -24871,8 +24878,7 @@ \section*{Appendix: Algorithmic Subtyping}
2487124878 \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
2487224879 \item
2487324880 $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
24874- have the same canonical syntax,
24875- for each $i \in 0 .. k$.
24881+ are subtypes of each other, for each $i \in 0 .. k$.
2487624882 \end{itemize}
2487724883
2487824884 \commentary{%
0 commit comments