@@ -13717,7 +13717,7 @@ \subsubsection{Ordinary Invocation}
13717
13717
Otherwise, let $d$ be the result of getter lookup
13718
13718
for $m$ in $T$ with respect to $L$,
13719
13719
and let $F$ be the return type of $d$.
13720
- (\commentary{
13720
+ (\commentary{%
13721
13721
Since \code{$T$.$m$} exists we cannot have a failure in both lookups.%
13722
13722
})
13723
13723
If the getter return type $F$ is an interface type
@@ -13741,7 +13741,7 @@ \subsubsection{Ordinary Invocation}
13741
13741
\LMHash{}%
13742
13742
It is a compile-time error to invoke an instance method on a type literal
13743
13743
that is immediately followed by the token `.' (a period).
13744
- \commentary{
13744
+ \commentary{%
13745
13745
For instance, \code{int.toString()} is an error.%
13746
13746
}
13747
13747
@@ -20337,13 +20337,13 @@ \subsection{Type Aliases}
20337
20337
it is a compile-time error if $T$ is not regular-bounded,
20338
20338
and it is a compile-time error if any type occurring in $T$ is not well-bounded.
20339
20339
20340
- \commentary{
20340
+ \commentary{%
20341
20341
This means that the bounds declared for
20342
20342
the formal type parameters of a generic type alias
20343
20343
must be such that when they are satisfied,
20344
20344
the bounds that pertain to the body are also satisfied,
20345
20345
and 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.%
20347
20347
}
20348
20348
20349
20349
\LMHash{}%
@@ -22384,7 +22384,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22384
22384
\DefEquals{\UpperBoundType{$T_1$}{$T_2$}}{T_2},
22385
22385
if \SubtypeNE{T_1}{T_2}.
22386
22386
22387
- \commentary{
22387
+ \commentary{%
22388
22388
In this and in the following cases, both types must be interface types.%
22389
22389
}
22390
22390
\item
@@ -22641,7 +22641,7 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22641
22641
\DefEquals{\LowerBoundType{$T_1$}{$T_2$}}{\code{Never}}, otherwise.
22642
22642
\end{itemize}
22643
22643
22644
- \rationale{
22644
+ \rationale{%
22645
22645
The rules defining \UpperBoundTypeName{} and \LowerBoundTypeName{}
22646
22646
are somewhat redundant in that they explicitly specify
22647
22647
a lot of pairs of symmetric cases.
@@ -24433,6 +24433,7 @@ \subsection{Type Promotion}
24433
24433
}
24434
24434
24435
24435
\LMHash{}%
24436
+ \BlindDefineSymbol{\ell, v}%
24436
24437
Let $\ell$ be a location,
24437
24438
and let $v$ be a local variable which is in scope at $\ell$.
24438
24439
Assume that $\ell$ occurs after the declaration of $v$.
@@ -24456,34 +24457,33 @@ \subsection{Type Promotion}
24456
24457
24457
24458
\LMHash{}%
24458
24459
In 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$}
24462
24462
where $v$ has type $T$ at $\ell$
24463
24463
promotes 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$}
24477
24473
promotes the type of $v$
24478
24474
to $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}).
24480
24479
24481
24480
\commentary{%
24482
24481
The resulting type of $v$ may be the obvious one, e.g.,
24483
24482
\code{$v$\,\,=\,\,1} may promote $v$ to \code{int},
24484
24483
but 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$
24487
24487
(e.g., when the static type of $e$ is not a type of interest).
24488
24488
These details will be specified in a future version of this specification.
24489
24489
@@ -24655,15 +24655,20 @@ \section*{Appendix: Algorithmic Subtyping}
24655
24655
the one which is specified in Fig.~\ref{fig:subtypeRules}.
24656
24656
It shows that Dart subtyping relationships can be decided
24657
24657
with good performance.
24658
+ This section is not normative.
24658
24659
24659
24660
\LMHash{}%
24660
24661
In this algorithm, types are considered to be the same when they have
24661
24662
the same canonical syntax
24662
24663
(\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
+ }
24663
24668
The algorithm must be performed such that the first case that matches
24664
24669
is always the case which is performed.
24665
24670
The algorithm produces results which are both positive and negative
24666
- (\commentary{
24671
+ (\commentary{%
24667
24672
that is, in some situations the subtype relation is determined to be false%
24668
24673
}),
24669
24674
which is important for performance because
@@ -24675,16 +24680,18 @@ \section*{Appendix: Algorithmic Subtyping}
24675
24680
\begin{itemize}
24676
24681
\item
24677
24682
\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}.
24679
24684
24680
24685
\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,
24682
24687
and type variables, but not for composite types.
24683
24688
In particular, a structural equality check is admissible,
24684
24689
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.%
24688
24695
}
24689
24696
\item
24690
24697
\textbf{Right Top:}
@@ -24694,7 +24701,7 @@ \section*{Appendix: Algorithmic Subtyping}
24694
24701
if $T_0$ is \DYNAMIC{} or \VOID{}
24695
24702
then \SubtypeNE{T_0}{T_1} if{}f \SubtypeNE{\code{Object?}}{T_1}.
24696
24703
\item
24697
- \textbf{Left Bottom:}
24704
+ \textbf{Bottom:}
24698
24705
if $T_0$ is \code{Never} then \SubtypeNE{T_0}{T_1}.
24699
24706
\item
24700
24707
\textbf{Right Object:}
@@ -24747,7 +24754,7 @@ \section*{Appendix: Algorithmic Subtyping}
24747
24754
or a promoted type variables \code{$X_0$\,\&\,$S_0$} and $T_1$ is $X_0$
24748
24755
then \SubtypeNE{T_0}{T_1}.
24749
24756
24750
- \commentary{
24757
+ \commentary{%
24751
24758
Note that this rule is admissible, and can be safely elided if desired.%
24752
24759
}
24753
24760
\item
@@ -24830,7 +24837,7 @@ \section*{Appendix: Algorithmic Subtyping}
24830
24837
for $i \in 0 .. q$.
24831
24838
\item \SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
24832
24839
\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$.
24834
24841
\end{itemize}
24835
24842
\item
24836
24843
\textbf{Named Function Types:}
@@ -24871,8 +24878,7 @@ \section*{Appendix: Algorithmic Subtyping}
24871
24878
\SubtypeNE{U_0[Z_0/X_0, \ldots, Z_k/X_k]}{U_1[Z_0/Y_0, \ldots, Z_k/Y_k]}.
24872
24879
\item
24873
24880
$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$.
24876
24882
\end{itemize}
24877
24883
24878
24884
\commentary{%
0 commit comments