@@ -19958,7 +19958,8 @@ \section{Types}
19958
19958
\LMLabel{types}
19959
19959
19960
19960
\LMHash{}%
19961
- Dart supports optional typing based on interface types.
19961
+ Dart supports optional typing based on interface types
19962
+ (\ref{interfaceTypes}).
19962
19963
19963
19964
\rationale{%
19964
19965
The type system is unsound, due to the covariance of generic classes.
@@ -20758,8 +20759,7 @@ \subsection{Subtypes}
20758
20759
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
20759
20760
% ------------------------------------------------ Right Object
20760
20761
\RuleRaw{\SrnRightObjectFour}{%
20761
- \mbox{$S$ is an interface type,}\\
20762
- \mbox{a function type, or \FUNCTION}}{S}{\code{Object}}
20762
+ \mbox{$S$ is an interface type or \FUNCTION}}{S}{\code{Object}}
20763
20763
% ------------------------------------------------ Left Null 2
20764
20764
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
20765
20765
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21134,8 +21134,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
21134
21134
\Item{\SrnBottom}{Bottom}
21135
21135
\code{Never} is a subtype of every type.
21136
21136
\Item{\SrnRightObjectFour}{Right Object}
21137
- Interface types, function types, and \FUNCTION{}
21138
- are subtypes of \code{Object}.
21137
+ Interface types and \FUNCTION{} are subtypes of \code{Object}.
21139
21138
\Item{\SrnNullOne}{Null Nullable}
21140
21139
\code{Null} is a subtype of every type of the form \code{$T$?}.
21141
21140
\Item{\SrnNullTwo}{Null FutureOr}
@@ -21323,7 +21322,7 @@ \subsection{Type Nullability}
21323
21322
\item \code{Never}.
21324
21323
\item Any function type.
21325
21324
\item The type \FUNCTION.
21326
- \item Any interface type except \code{Null} .
21325
+ \item Any interface type.
21327
21326
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
21328
21327
\item Any type variable $X$ whose bound is non-nullable.
21329
21328
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -22642,15 +22641,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22642
22641
22643
22642
\LMHash{}%
22644
22643
We define the auxiliary function \NominalTypeDepthName{}
22645
- on interface types and \code{Object?} as follows:
22644
+ on interface types as follows:
22646
22645
22647
22646
\begin{itemize}
22648
22647
\item
22649
- \DefEquals{\NominalTypeDepth{Object?}}{0}.
22650
- \item
22651
- \DefEquals{\NominalTypeDepth{Object}}{1}.
22652
- \item
22653
- \DefEquals{\NominalTypeDepth{Null}}{1}.
22648
+ % We could make it 1 rather than 0, to "reserve space" for `Object?`,
22649
+ % but this function is never used with `Object?` anyway.
22650
+ \DefEquals{\NominalTypeDepth{Object}}{0}.
22654
22651
\item
22655
22652
Let $T$ be a class or a mixin,
22656
22653
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -22659,10 +22656,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22659
22656
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
22660
22657
\end{itemize}
22661
22658
22662
- \commentary{%
22663
-
22664
- }
22665
-
22666
22659
\LMHash{}%
22667
22660
\BlindDefineSymbol{I, J, M}%
22668
22661
The algorithm that determines
@@ -23051,21 +23044,22 @@ \subsection{Interface Types}
23051
23044
(\ref{typedef}).
23052
23045
We say that $T$ is an \Index{interface type} if{}f
23053
23046
$T'$ is of the form \code{$C$<\List{T}{1}{k}>},
23054
- where $C$ denotes a class different from \code{Never},
23047
+ where $C$ denotes a class different from \code{Never} and \code{Null} ,
23055
23048
or $C$ denotes a mixin.
23056
23049
23057
23050
\commentary{%
23058
23051
Note that \List{T}{1}{k} can be arbitrary types.
23059
23052
Non-generic classes are included because we can have $k = 0$.
23060
23053
23061
23054
In particular, the following types are \emph{not} interface types:
23062
- \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$, \code{Never},
23055
+ \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$,
23056
+ \code{Never}, \code{Null},
23063
23057
any function type, any type variable, any intersection type,
23064
23058
and any type of the form \code{$T$?}.
23065
23059
23066
- Conversely, built-in classes
23067
- like \code{Object}, \code{Null }, \code{num }, \code{int},
23068
- \code{String}, and \code{Exception} are interface types,
23060
+ Conversely, built-in classes like, e.g.,
23061
+ \code{Object}, \code{num }, \code{int }, \code{String}, and \code{Exception}
23062
+ are interface types,
23069
23063
and so are
23070
23064
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23071
23065
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
0 commit comments