@@ -20919,7 +20919,8 @@ \section{Types}
20919
20919
\LMLabel{types}
20920
20920
20921
20921
\LMHash{}%
20922
- Dart supports static typing based on interface types.
20922
+ Dart supports static typing based on interface types
20923
+ (\ref{interfaceTypes}).
20923
20924
20924
20925
\rationale{%
20925
20926
The type system is sound in the sense that
@@ -21726,8 +21727,7 @@ \subsection{Subtypes}
21726
21727
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
21727
21728
% ------------------------------------------------ Right Object
21728
21729
\RuleRaw{\SrnRightObjectFour}{%
21729
- \mbox{$S$ is an interface type,}\\
21730
- \mbox{a function type, or \FUNCTION}}{S}{\code{Object}}
21730
+ \mbox{$S$ is an interface type or \FUNCTION}}{S}{\code{Object}}
21731
21731
% ------------------------------------------------ Left Null 2
21732
21732
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
21733
21733
\code{Null}}{\code{FutureOr<$T$>}}
@@ -22102,8 +22102,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
22102
22102
\Item{\SrnBottom}{Bottom}
22103
22103
\code{Never} is a subtype of every type.
22104
22104
\Item{\SrnRightObjectFour}{Right Object}
22105
- Interface types, function types, and \FUNCTION{}
22106
- are subtypes of \code{Object}.
22105
+ Interface types and \FUNCTION{} are subtypes of \code{Object}.
22107
22106
\Item{\SrnNullOne}{Null Nullable}
22108
22107
\code{Null} is a subtype of every type of the form \code{$T$?}.
22109
22108
\Item{\SrnNullTwo}{Null FutureOr}
@@ -22291,7 +22290,7 @@ \subsection{Type Nullability}
22291
22290
\item \code{Never}.
22292
22291
\item Any function type.
22293
22292
\item The type \FUNCTION.
22294
- \item Any interface type except \code{Null} .
22293
+ \item Any interface type.
22295
22294
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
22296
22295
\item Any type variable $X$ whose bound is non-nullable.
22297
22296
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -23610,15 +23609,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23610
23609
23611
23610
\LMHash{}%
23612
23611
We define the auxiliary function \NominalTypeDepthName{}
23613
- on interface types and \code{Object?} as follows:
23612
+ on interface types as follows:
23614
23613
23615
23614
\begin{itemize}
23616
23615
\item
23617
- \DefEquals{\NominalTypeDepth{Object?}}{0}.
23618
- \item
23619
- \DefEquals{\NominalTypeDepth{Object}}{1}.
23620
- \item
23621
- \DefEquals{\NominalTypeDepth{Null}}{1}.
23616
+ % We could make it 1 rather than 0, to "reserve space" for `Object?`,
23617
+ % but this function is never used with `Object?` anyway.
23618
+ \DefEquals{\NominalTypeDepth{Object}}{0}.
23622
23619
\item
23623
23620
Let $T$ be a class or a mixin,
23624
23621
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -23627,10 +23624,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23627
23624
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
23628
23625
\end{itemize}
23629
23626
23630
- \commentary{%
23631
-
23632
- }
23633
-
23634
23627
\LMHash{}%
23635
23628
\BlindDefineSymbol{I, J, M}%
23636
23629
The algorithm that determines
@@ -24019,21 +24012,22 @@ \subsection{Interface Types}
24019
24012
(\ref{typedef}).
24020
24013
We say that $T$ is an \Index{interface type} if{}f
24021
24014
$T'$ is of the form \code{$C$<\List{T}{1}{k}>},
24022
- where $C$ denotes a class different from \code{Never},
24015
+ where $C$ denotes a class different from \code{Never} and \code{Null} ,
24023
24016
or $C$ denotes a mixin.
24024
24017
24025
24018
\commentary{%
24026
24019
Note that \List{T}{1}{k} can be arbitrary types.
24027
24020
Non-generic classes are included because we can have $k = 0$.
24028
24021
24029
24022
In particular, the following types are \emph{not} interface types:
24030
- \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$, \code{Never},
24023
+ \VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$,
24024
+ \code{Never}, \code{Null},
24031
24025
any function type, any type variable, any intersection type,
24032
24026
and any type of the form \code{$T$?}.
24033
24027
24034
- Conversely, built-in classes
24035
- like \code{Object}, \code{Null }, \code{num }, \code{int},
24036
- \code{String}, and \code{Exception} are interface types,
24028
+ Conversely, built-in classes like, e.g.,
24029
+ \code{Object}, \code{num }, \code{int }, \code{String}, and \code{Exception}
24030
+ are interface types,
24037
24031
and so are
24038
24032
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
24039
24033
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
0 commit comments