Skip to content

Commit fd48cfe

Browse files
committed
Interface type and subtype rule fixes
1 parent f5304fd commit fd48cfe

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

specification/dartLangSpec.tex

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19991,7 +19991,8 @@ \section{Types}
1999119991
\LMLabel{types}
1999219992

1999319993
\LMHash{}%
19994-
Dart supports optional typing based on interface types.
19994+
Dart supports optional typing based on interface types
19995+
(\ref{interfaceTypes}).
1999519996

1999619997
\rationale{%
1999719998
The type system is unsound, due to the covariance of generic classes.
@@ -20787,8 +20788,7 @@ \subsection{Subtypes}
2078720788
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
2078820789
% ------------------------------------------------ Right Object
2078920790
\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}}
2079220792
% ------------------------------------------------ Left Null 2
2079320793
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
2079420794
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21163,8 +21163,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
2116321163
\Item{\SrnBottom}{Bottom}
2116421164
\code{Never} is a subtype of every type.
2116521165
\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}.
2116821167
\Item{\SrnNullOne}{Null Nullable}
2116921168
\code{Null} is a subtype of every type of the form \code{$T$?}.
2117021169
\Item{\SrnNullTwo}{Null FutureOr}
@@ -21352,7 +21351,7 @@ \subsection{Type Nullability}
2135221351
\item \code{Never}.
2135321352
\item Any function type.
2135421353
\item The type \FUNCTION.
21355-
\item Any interface type except \code{Null}.
21354+
\item Any interface type.
2135621355
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
2135721356
\item Any type variable $X$ whose bound is non-nullable.
2135821357
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -22671,15 +22670,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2267122670

2267222671
\LMHash{}%
2267322672
We define the auxiliary function \NominalTypeDepthName{}
22674-
on interface types and \code{Object?} as follows:
22673+
on interface types as follows:
2267522674

2267622675
\begin{itemize}
2267722676
\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}.
2268322680
\item
2268422681
Let $T$ be a class or a mixin,
2268522682
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -22688,10 +22685,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2268822685
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
2268922686
\end{itemize}
2269022687

22691-
\commentary{%
22692-
22693-
}
22694-
2269522688
\LMHash{}%
2269622689
\BlindDefineSymbol{I, J, M}%
2269722690
The algorithm that determines
@@ -23080,21 +23073,22 @@ \subsection{Interface Types}
2308023073
(\ref{typedef}).
2308123074
We say that $T$ is an \Index{interface type} if{}f
2308223075
$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},
2308423077
or $C$ denotes a mixin.
2308523078

2308623079
\commentary{%
2308723080
Note that \List{T}{1}{k} can be arbitrary types.
2308823081
Non-generic classes are included because we can have $k = 0$.
2308923082

2309023083
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},
2309223086
any function type, any type variable, any intersection type,
2309323087
and any type of the form \code{$T$?}.
2309423088

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,
2309823092
and so are
2309923093
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
2310023094
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},

0 commit comments

Comments
 (0)