Skip to content

Commit e054fc0

Browse files
committed
Interface type and subtype rule fixes
1 parent 9fa6d8f commit e054fc0

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
@@ -20691,7 +20691,8 @@ \section{Types}
2069120691
\LMLabel{types}
2069220692

2069320693
\LMHash{}%
20694-
Dart supports static typing based on interface types.
20694+
Dart supports static typing based on interface types
20695+
(\ref{interfaceTypes}).
2069520696

2069620697
\rationale{%
2069720698
The type system is sound in the sense that
@@ -21498,8 +21499,7 @@ \subsection{Subtypes}
2149821499
T \in \{\code{Object?}, \DYNAMIC, \VOID\}}{S}{T}
2149921500
% ------------------------------------------------ Right Object
2150021501
\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}}
2150321503
% ------------------------------------------------ Left Null 2
2150421504
\Rule{\SrnNullTwo}{\code{Null}}{T}{%
2150521505
\code{Null}}{\code{FutureOr<$T$>}}
@@ -21874,8 +21874,7 @@ \subsubsection{Informal Subtype Rule Descriptions}
2187421874
\Item{\SrnBottom}{Bottom}
2187521875
\code{Never} is a subtype of every type.
2187621876
\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}.
2187921878
\Item{\SrnNullOne}{Null Nullable}
2188021879
\code{Null} is a subtype of every type of the form \code{$T$?}.
2188121880
\Item{\SrnNullTwo}{Null FutureOr}
@@ -22063,7 +22062,7 @@ \subsection{Type Nullability}
2206322062
\item \code{Never}.
2206422063
\item Any function type.
2206522064
\item The type \FUNCTION.
22066-
\item Any interface type except \code{Null}.
22065+
\item Any interface type.
2206722066
\item \code{FutureOr<$S$>}, for any non-nullable type $S$.
2206822067
\item Any type variable $X$ whose bound is non-nullable.
2206922068
\item Any type of the form \code{$X$\,\&\,$S$}, where
@@ -23382,15 +23381,13 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2338223381

2338323382
\LMHash{}%
2338423383
We define the auxiliary function \NominalTypeDepthName{}
23385-
on interface types and \code{Object?} as follows:
23384+
on interface types as follows:
2338623385

2338723386
\begin{itemize}
2338823387
\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}.
2339423391
\item
2339523392
Let $T$ be a class or a mixin,
2339623393
and let $M$ be the set of immediate superinterfaces of $T$.
@@ -23399,10 +23396,6 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2339923396
$\metavar{max}\,\{\;\NominalTypeDepth{$S$}\;|\;S\;\in M\;\}$.
2340023397
\end{itemize}
2340123398

23402-
\commentary{%
23403-
23404-
}
23405-
2340623399
\LMHash{}%
2340723400
\BlindDefineSymbol{I, J, M}%
2340823401
The algorithm that determines
@@ -23791,21 +23784,22 @@ \subsection{Interface Types}
2379123784
(\ref{typedef}).
2379223785
We say that $T$ is an \Index{interface type} if{}f
2379323786
$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},
2379523788
or $C$ denotes a mixin.
2379623789

2379723790
\commentary{%
2379823791
Note that \List{T}{1}{k} can be arbitrary types.
2379923792
Non-generic classes are included because we can have $k = 0$.
2380023793

2380123794
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},
2380323797
any function type, any type variable, any intersection type,
2380423798
and any type of the form \code{$T$?}.
2380523799

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

0 commit comments

Comments
 (0)