@@ -19991,7 +19991,8 @@ \section{Types}
19991
19991
\LMLabel{types}
19992
19992
19993
19993
\LMHash{}%
19994
- Dart supports optional typing based on interface types.
19994
+ Dart supports optional typing based on interface types
19995
+ (\ref{interfaceTypes}).
19995
19996
19996
19997
\rationale{%
19997
19998
The type system is unsound, due to the covariance of generic classes.
@@ -20787,8 +20788,7 @@ \subsection{Subtypes}
20787
20788
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
20788
20789
% ------------------------------------------------ Right Object
20789
20790
\RuleRaw{\SrnRightObjectFour}{%
20790
- \mbox{$S$ is an interface type,}\\
20791
- \mbox{a function type, or \FUNCTION}}{S}{\code{Object}}
20791
+ \mbox{$S$ is an interface type or \FUNCTION}}{S}{\code{Object}}
20792
20792
% ------------------------------------------------ Left Null 2
20793
20793
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
20794
20794
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21163,8 +21163,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
21163
21163
\Item{\SrnBottom}{Bottom}
21164
21164
\code{Never} is a subtype of every type.
21165
21165
\Item{\SrnRightObjectFour}{Right Object}
21166
- Interface types, function types, and \FUNCTION{}
21167
- are subtypes of \code{Object}.
21166
+ Interface types and \FUNCTION{} are subtypes of \code{Object}.
21168
21167
\Item{\SrnNullOne}{Null Nullable}
21169
21168
\code{Null} is a subtype of every type of the form \code{$T$?}.
21170
21169
\Item{\SrnNullTwo}{Null FutureOr}
@@ -21352,7 +21351,7 @@ \subsection{Type Nullability}
21352
21351
\item \code{Never}.
21353
21352
\item Any function type.
21354
21353
\item The type \FUNCTION.
21355
- \item Any interface type except \code{Null} .
21354
+ \item Any interface type.
21356
21355
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
21357
21356
\item Any type variable $X$ whose bound is non-nullable.
21358
21357
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -22671,15 +22670,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22671
22670
22672
22671
\LMHash{}%
22673
22672
We define the auxiliary function \NominalTypeDepthName{}
22674
- on interface types and \code{Object?} as follows:
22673
+ on interface types as follows:
22675
22674
22676
22675
\begin{itemize}
22677
22676
\item
22678
- \DefEquals{\NominalTypeDepth{Object?}}{0}.
22679
- \item
22680
- \DefEquals{\NominalTypeDepth{Object}}{1}.
22681
- \item
22682
- \DefEquals{\NominalTypeDepth{Null}}{1}.
22677
+ % We could make it 1 rather than 0, to "reserve space" for `Object?`,
22678
+ % but this function is never used with `Object?` anyway.
22679
+ \DefEquals{\NominalTypeDepth{Object}}{0}.
22683
22680
\item
22684
22681
Let $T$ be a class or a mixin,
22685
22682
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -22688,10 +22685,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22688
22685
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
22689
22686
\end{itemize}
22690
22687
22691
- \commentary{%
22692
-
22693
- }
22694
-
22695
22688
\LMHash{}%
22696
22689
\BlindDefineSymbol{I, J, M}%
22697
22690
The algorithm that determines
@@ -23080,21 +23073,22 @@ \subsection{Interface Types}
23080
23073
(\ref{typedef}).
23081
23074
We say that $T$ is an \Index{interface type} if{}f
23082
23075
$T'$ is of the form \code{$C$<\List{T}{1}{k}>},
23083
- where $C$ denotes a class different from \code{Never},
23076
+ where $C$ denotes a class different from \code{Never} and \code{Null} ,
23084
23077
or $C$ denotes a mixin.
23085
23078
23086
23079
\commentary{%
23087
23080
Note that \List{T}{1}{k} can be arbitrary types.
23088
23081
Non-generic classes are included because we can have $k = 0$.
23089
23082
23090
23083
In particular, the following types are \emph{not} interface types:
23091
- \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$, \code{Never},
23084
+ \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$,
23085
+ \code{Never}, \code{Null},
23092
23086
any function type, any type variable, any intersection type,
23093
23087
and any type of the form \code{$T$?}.
23094
23088
23095
- Conversely, built-in classes
23096
- like \code{Object}, \code{Null }, \code{num }, \code{int},
23097
- \code{String}, and \code{Exception} are interface types,
23089
+ Conversely, built-in classes like, e.g.,
23090
+ \code{Object}, \code{num }, \code{int }, \code{String}, and \code{Exception}
23091
+ are interface types,
23098
23092
and so are
23099
23093
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23100
23094
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
0 commit comments