Skip to content

Commit 91ebaa4

Browse files
committed
Interface type and subtype rule fixes
1 parent 82b7419 commit 91ebaa4

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
@@ -20736,7 +20736,8 @@ \section{Types}
2073620736
\LMLabel{types}
2073720737

2073820738
\LMHash{}%
20739-
Dart supports static typing based on interface types.
20739+
Dart supports static typing based on interface types
20740+
(\ref{interfaceTypes}).
2074020741

2074120742
\rationale{%
2074220743
The type system is sound in the sense that
@@ -21543,8 +21544,7 @@ \subsection{Subtypes}
2154321544
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
2154421545
% ------------------------------------------------ Right Object
2154521546
\RuleRaw{\SrnRightObjectFour}{%
21546-
\mbox{$S$ is an interface type,}\\
21547-
\mbox{a function type, or \FUNCTION}}{S}{\code{Object}}
21547+
\mbox{$S$ is an interface type or \FUNCTION}}{S}{\code{Object}}
2154821548
% ------------------------------------------------ Left Null 2
2154921549
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
2155021550
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21919,8 +21919,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
2191921919
\Item{\SrnBottom}{Bottom}
2192021920
\code{Never} is a subtype of every type.
2192121921
\Item{\SrnRightObjectFour}{Right Object}
21922-
Interface types, function types, and \FUNCTION{}
21923-
are subtypes of \code{Object}.
21922+
Interface types and \FUNCTION{} are subtypes of \code{Object}.
2192421923
\Item{\SrnNullOne}{Null Nullable}
2192521924
\code{Null} is a subtype of every type of the form \code{$T$?}.
2192621925
\Item{\SrnNullTwo}{Null FutureOr}
@@ -22108,7 +22107,7 @@ \subsection{Type Nullability}
2210822107
\item \code{Never}.
2210922108
\item Any function type.
2211022109
\item The type \FUNCTION.
22111-
\item Any interface type except \code{Null}.
22110+
\item Any interface type.
2211222111
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
2211322112
\item Any type variable $X$ whose bound is non-nullable.
2211422113
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -23427,15 +23426,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2342723426

2342823427
\LMHash{}%
2342923428
We define the auxiliary function \NominalTypeDepthName{}
23430-
on interface types and \code{Object?} as follows:
23429+
on interface types as follows:
2343123430

2343223431
\begin{itemize}
2343323432
\item
23434-
\DefEquals{\NominalTypeDepth{Object?}}{0}.
23435-
\item
23436-
\DefEquals{\NominalTypeDepth{Object}}{1}.
23437-
\item
23438-
\DefEquals{\NominalTypeDepth{Null}}{1}.
23433+
% We could make it 1 rather than 0, to "reserve space" for `Object?`,
23434+
% but this function is never used with `Object?` anyway.
23435+
\DefEquals{\NominalTypeDepth{Object}}{0}.
2343923436
\item
2344023437
Let $T$ be a class or a mixin,
2344123438
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -23444,10 +23441,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2344423441
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
2344523442
\end{itemize}
2344623443

23447-
\commentary{%
23448-
23449-
}
23450-
2345123444
\LMHash{}%
2345223445
\BlindDefineSymbol{I, J, M}%
2345323446
The algorithm that determines
@@ -23836,21 +23829,22 @@ \subsection{Interface Types}
2383623829
(\ref{typedef}).
2383723830
We say that $T$ is an \Index{interface type} if{}f
2383823831
$T'$ is of the form \code{$C$<\List{T}{1}{k}>},
23839-
where $C$ denotes a class different from \code{Never},
23832+
where $C$ denotes a class different from \code{Never} and \code{Null},
2384023833
or $C$ denotes a mixin.
2384123834

2384223835
\commentary{%
2384323836
Note that \List{T}{1}{k} can be arbitrary types.
2384423837
Non-generic classes are included because we can have $k = 0$.
2384523838

2384623839
In particular, the following types are \emph{not} interface types:
23847-
\VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$, \code{Never},
23840+
\VOID, \DYNAMIC, \FUNCTION, \code{FutureOr<$T$>} for any $T$,
23841+
\code{Never}, \code{Null},
2384823842
any function type, any type variable, any intersection type,
2384923843
and any type of the form \code{$T$?}.
2385023844

23851-
Conversely, built-in classes
23852-
like \code{Object}, \code{Null}, \code{num}, \code{int},
23853-
\code{String}, and \code{Exception} are interface types,
23845+
Conversely, built-in classes like, e.g.,
23846+
\code{Object}, \code{num}, \code{int}, \code{String}, and \code{Exception}
23847+
are interface types,
2385423848
and so are
2385523849
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
2385623850
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},

0 commit comments

Comments
 (0)