@@ -20691,7 +20691,8 @@ \section{Types}
20691
20691
\LMLabel{types}
20692
20692
20693
20693
\LMHash{}%
20694
- Dart supports static typing based on interface types.
20694
+ Dart supports static typing based on interface types
20695
+ (\ref{interfaceTypes}).
20695
20696
20696
20697
\rationale{%
20697
20698
The type system is sound in the sense that
@@ -21498,8 +21499,7 @@ \subsection{Subtypes}
21498
21499
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
21499
21500
% ------------------------------------------------ Right Object
21500
21501
\RuleRaw{\SrnRightObjectFour}{%
21501
- \mbox{$S$ is an interface type,}\\
21502
- \mbox{a function type, or \FUNCTION}}{S}{\code{Object}}
21502
+ \mbox{$S$ is an interface type or \FUNCTION}}{S}{\code{Object}}
21503
21503
% ------------------------------------------------ Left Null 2
21504
21504
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
21505
21505
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21874,8 +21874,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
21874
21874
\Item{\SrnBottom}{Bottom}
21875
21875
\code{Never} is a subtype of every type.
21876
21876
\Item{\SrnRightObjectFour}{Right Object}
21877
- Interface types, function types, and \FUNCTION{}
21878
- are subtypes of \code{Object}.
21877
+ Interface types and \FUNCTION{} are subtypes of \code{Object}.
21879
21878
\Item{\SrnNullOne}{Null Nullable}
21880
21879
\code{Null} is a subtype of every type of the form \code{$T$?}.
21881
21880
\Item{\SrnNullTwo}{Null FutureOr}
@@ -22063,7 +22062,7 @@ \subsection{Type Nullability}
22063
22062
\item \code{Never}.
22064
22063
\item Any function type.
22065
22064
\item The type \FUNCTION.
22066
- \item Any interface type except \code{Null} .
22065
+ \item Any interface type.
22067
22066
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
22068
22067
\item Any type variable $X$ whose bound is non-nullable.
22069
22068
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -23382,15 +23381,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23382
23381
23383
23382
\LMHash{}%
23384
23383
We define the auxiliary function \NominalTypeDepthName{}
23385
- on interface types and \code{Object?} as follows:
23384
+ on interface types as follows:
23386
23385
23387
23386
\begin{itemize}
23388
23387
\item
23389
- \DefEquals{\NominalTypeDepth{Object?}}{0}.
23390
- \item
23391
- \DefEquals{\NominalTypeDepth{Object}}{1}.
23392
- \item
23393
- \DefEquals{\NominalTypeDepth{Null}}{1}.
23388
+ % We could make it 1 rather than 0, to "reserve space" for `Object?`,
23389
+ % but this function is never used with `Object?` anyway.
23390
+ \DefEquals{\NominalTypeDepth{Object}}{0}.
23394
23391
\item
23395
23392
Let $T$ be a class or a mixin,
23396
23393
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -23399,10 +23396,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23399
23396
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
23400
23397
\end{itemize}
23401
23398
23402
- \commentary{%
23403
-
23404
- }
23405
-
23406
23399
\LMHash{}%
23407
23400
\BlindDefineSymbol{I, J, M}%
23408
23401
The algorithm that determines
@@ -23791,21 +23784,22 @@ \subsection{Interface Types}
23791
23784
(\ref{typedef}).
23792
23785
We say that $T$ is an \Index{interface type} if{}f
23793
23786
$T'$ is of the form \code{$C$<\List{T}{1}{k}>},
23794
- where $C$ denotes a class different from \code{Never},
23787
+ where $C$ denotes a class different from \code{Never} and \code{Null} ,
23795
23788
or $C$ denotes a mixin.
23796
23789
23797
23790
\commentary{%
23798
23791
Note that \List{T}{1}{k} can be arbitrary types.
23799
23792
Non-generic classes are included because we can have $k = 0$.
23800
23793
23801
23794
In particular, the following types are \emph{not} interface types:
23802
- \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$, \code{Never},
23795
+ \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$,
23796
+ \code{Never}, \code{Null},
23803
23797
any function type, any type variable, any intersection type,
23804
23798
and any type of the form \code{$T$?}.
23805
23799
23806
- Conversely, built-in classes
23807
- like \code{Object}, \code{Null }, \code{num }, \code{int},
23808
- \code{String}, and \code{Exception} are interface types,
23800
+ Conversely, built-in classes like, e.g.,
23801
+ \code{Object}, \code{num }, \code{int }, \code{String}, and \code{Exception}
23802
+ are interface types,
23809
23803
and so are
23810
23804
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23811
23805
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
0 commit comments