@@ -19947,7 +19947,8 @@ \section{Types}
19947
19947
\LMLabel{types}
19948
19948
19949
19949
\LMHash{}%
19950
- Dart supports optional typing based on interface types.
19950
+ Dart supports optional typing based on interface types
19951
+ (\ref{interfaceTypes}).
19951
19952
19952
19953
\rationale{%
19953
19954
The type system is unsound, due to the covariance of generic classes.
@@ -20747,8 +20748,7 @@ \subsection{Subtypes}
20747
20748
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
20748
20749
% ------------------------------------------------ Right Object
20749
20750
\RuleRaw{\SrnRightObjectFour}{%
20750
- \mbox{$S$ is an interface type,}\\
20751
- \mbox{a function type, or \FUNCTION}}{S}{\code{Object}}
20751
+ \mbox{$S$ is an interface type or \FUNCTION}}{S}{\code{Object}}
20752
20752
% ------------------------------------------------ Left Null 2
20753
20753
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
20754
20754
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21123,8 +21123,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
21123
21123
\Item{\SrnBottom}{Bottom}
21124
21124
\code{Never} is a subtype of every type.
21125
21125
\Item{\SrnRightObjectFour}{Right Object}
21126
- Interface types, function types, and \FUNCTION{}
21127
- are subtypes of \code{Object}.
21126
+ Interface types and \FUNCTION{} are subtypes of \code{Object}.
21128
21127
\Item{\SrnNullOne}{Null Nullable}
21129
21128
\code{Null} is a subtype of every type of the form \code{$T$?}.
21130
21129
\Item{\SrnNullTwo}{Null FutureOr}
@@ -21312,7 +21311,7 @@ \subsection{Type Nullability}
21312
21311
\item \code{Never}.
21313
21312
\item Any function type.
21314
21313
\item The type \FUNCTION.
21315
- \item Any interface type except \code{Null} .
21314
+ \item Any interface type.
21316
21315
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
21317
21316
\item Any type variable $X$ whose bound is non-nullable.
21318
21317
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -22631,15 +22630,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22631
22630
22632
22631
\LMHash{}%
22633
22632
We define the auxiliary function \NominalTypeDepthName{}
22634
- on interface types and \code{Object?} as follows:
22633
+ on interface types as follows:
22635
22634
22636
22635
\begin{itemize}
22637
22636
\item
22638
- \DefEquals{\NominalTypeDepth{Object?}}{0}.
22639
- \item
22640
- \DefEquals{\NominalTypeDepth{Object}}{1}.
22641
- \item
22642
- \DefEquals{\NominalTypeDepth{Null}}{1}.
22637
+ % We could make it 1 rather than 0, to "reserve space" for `Object?`,
22638
+ % but this function is never used with `Object?` anyway.
22639
+ \DefEquals{\NominalTypeDepth{Object}}{0}.
22643
22640
\item
22644
22641
Let $T$ be a class or a mixin,
22645
22642
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -22648,10 +22645,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22648
22645
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
22649
22646
\end{itemize}
22650
22647
22651
- \commentary{%
22652
-
22653
- }
22654
-
22655
22648
\LMHash{}%
22656
22649
\BlindDefineSymbol{I, J, M}%
22657
22650
The algorithm that determines
@@ -23040,21 +23033,22 @@ \subsection{Interface Types}
23040
23033
(\ref{typedef}).
23041
23034
We say that $T$ is an \Index{interface type} if{}f
23042
23035
$T'$ is of the form \code{$C$<\List{T}{1}{k}>},
23043
- where $C$ denotes a class different from \code{Never},
23036
+ where $C$ denotes a class different from \code{Never} and \code{Null} ,
23044
23037
or $C$ denotes a mixin.
23045
23038
23046
23039
\commentary{%
23047
23040
Note that \List{T}{1}{k} can be arbitrary types.
23048
23041
Non-generic classes are included because we can have $k = 0$.
23049
23042
23050
23043
In particular, the following types are \emph{not} interface types:
23051
- \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$, \code{Never},
23044
+ \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$,
23045
+ \code{Never}, \code{Null},
23052
23046
any function type, any type variable, any intersection type,
23053
23047
and any type of the form \code{$T$?}.
23054
23048
23055
- Conversely, built-in classes
23056
- like \code{Object}, \code{Null }, \code{num }, \code{int},
23057
- \code{String}, and \code{Exception} are interface types,
23049
+ Conversely, built-in classes like, e.g.,
23050
+ \code{Object}, \code{num }, \code{int }, \code{String}, and \code{Exception}
23051
+ are interface types,
23058
23052
and so are
23059
23053
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23060
23054
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
0 commit comments