@@ -19966,7 +19966,8 @@ \section{Types}
19966
19966
\LMLabel{types}
19967
19967
19968
19968
\LMHash{}%
19969
- Dart supports optional typing based on interface types.
19969
+ Dart supports optional typing based on interface types
19970
+ (\ref{interfaceTypes}).
19970
19971
19971
19972
\rationale{%
19972
19973
The type system is unsound, due to the covariance of generic classes.
@@ -20766,8 +20767,7 @@ \subsection{Subtypes}
20766
20767
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
20767
20768
% ------------------------------------------------ Right Object
20768
20769
\RuleRaw{\SrnRightObjectFour}{%
20769
- \mbox{$S$ is an interface type,}\\
20770
- \mbox{a function type, or \FUNCTION}}{S}{\code{Object}}
20770
+ \mbox{$S$ is an interface type or \FUNCTION}}{S}{\code{Object}}
20771
20771
% ------------------------------------------------ Left Null 2
20772
20772
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
20773
20773
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21142,8 +21142,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
21142
21142
\Item{\SrnBottom}{Bottom}
21143
21143
\code{Never} is a subtype of every type.
21144
21144
\Item{\SrnRightObjectFour}{Right Object}
21145
- Interface types, function types, and \FUNCTION{}
21146
- are subtypes of \code{Object}.
21145
+ Interface types and \FUNCTION{} are subtypes of \code{Object}.
21147
21146
\Item{\SrnNullOne}{Null Nullable}
21148
21147
\code{Null} is a subtype of every type of the form \code{$T$?}.
21149
21148
\Item{\SrnNullTwo}{Null FutureOr}
@@ -21331,7 +21330,7 @@ \subsection{Type Nullability}
21331
21330
\item \code{Never}.
21332
21331
\item Any function type.
21333
21332
\item The type \FUNCTION.
21334
- \item Any interface type except \code{Null} .
21333
+ \item Any interface type.
21335
21334
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
21336
21335
\item Any type variable $X$ whose bound is non-nullable.
21337
21336
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -22650,15 +22649,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22650
22649
22651
22650
\LMHash{}%
22652
22651
We define the auxiliary function \NominalTypeDepthName{}
22653
- on interface types and \code{Object?} as follows:
22652
+ on interface types as follows:
22654
22653
22655
22654
\begin{itemize}
22656
22655
\item
22657
- \DefEquals{\NominalTypeDepth{Object?}}{0}.
22658
- \item
22659
- \DefEquals{\NominalTypeDepth{Object}}{1}.
22660
- \item
22661
- \DefEquals{\NominalTypeDepth{Null}}{1}.
22656
+ % We could make it 1 rather than 0, to "reserve space" for `Object?`,
22657
+ % but this function is never used with `Object?` anyway.
22658
+ \DefEquals{\NominalTypeDepth{Object}}{0}.
22662
22659
\item
22663
22660
Let $T$ be a class or a mixin,
22664
22661
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -22667,10 +22664,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22667
22664
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
22668
22665
\end{itemize}
22669
22666
22670
- \commentary{%
22671
-
22672
- }
22673
-
22674
22667
\LMHash{}%
22675
22668
\BlindDefineSymbol{I, J, M}%
22676
22669
The algorithm that determines
@@ -23059,21 +23052,22 @@ \subsection{Interface Types}
23059
23052
(\ref{typedef}).
23060
23053
We say that $T$ is an \Index{interface type} if{}f
23061
23054
$T'$ is of the form \code{$C$<\List{T}{1}{k}>},
23062
- where $C$ denotes a class different from \code{Never},
23055
+ where $C$ denotes a class different from \code{Never} and \code{Null} ,
23063
23056
or $C$ denotes a mixin.
23064
23057
23065
23058
\commentary{%
23066
23059
Note that \List{T}{1}{k} can be arbitrary types.
23067
23060
Non-generic classes are included because we can have $k = 0$.
23068
23061
23069
23062
In particular, the following types are \emph{not} interface types:
23070
- \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$, \code{Never},
23063
+ \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$,
23064
+ \code{Never}, \code{Null},
23071
23065
any function type, any type variable, any intersection type,
23072
23066
and any type of the form \code{$T$?}.
23073
23067
23074
- Conversely, built-in classes
23075
- like \code{Object}, \code{Null }, \code{num }, \code{int},
23076
- \code{String}, and \code{Exception} are interface types,
23068
+ Conversely, built-in classes like, e.g.,
23069
+ \code{Object}, \code{num }, \code{int }, \code{String}, and \code{Exception}
23070
+ are interface types,
23077
23071
and so are
23078
23072
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23079
23073
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
0 commit comments