@@ -21649,9 +21649,6 @@ \subsection{Subtypes}
2164921649\newcommand{\SrnRightTop}{2}
2165021650\newcommand{\SrnLeftTop}{3}
2165121651\newcommand{\SrnBottom}{4}
21652- %\newcommand{\SrnRightObjectOne}{} Redundant
21653- %\newcommand{\SrnRightObjectTwo}{} Redundant
21654- %\newcommand{\SrnRightObjectThree}{} Redundant
2165521652\newcommand{\SrnRightObjectFour}{5}
2165621653\newcommand{\SrnNullOne}{6}
2165721654\newcommand{\SrnNullTwo}{7}
@@ -22262,7 +22259,8 @@ \subsection{Type Nullability}
2226222259Nullable types are types which are
2226322260definitively known to include the null object,
2226422261regardless of the value of any type variables.
22265- This is equivalent to the syntactic criterion that $T$ is any of:
22262+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22263+ then this is equivalent to the syntactic criterion that $T'$ is any of:
2226622264
2226722265\begin{itemize}[itemsep=-0.5ex]
2226822266\item \VOID.
@@ -22284,7 +22282,8 @@ \subsection{Type Nullability}
2228422282Non-nullable types are types which are definitively known to
2228522283\emph{not} include the null object,
2228622284regardless of the value of any type variables.
22287- This is equivalent to the syntactic criterion that $T$ is any of:
22285+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22286+ then this is equivalent to the syntactic criterion that $T$ is any of:
2228822287
2228922288\begin{itemize}[itemsep=-0.5ex]
2229022289\item \code{Never}.
@@ -22651,21 +22650,23 @@ \subsection{Type Normalization}
2265122650
2265222651 \noindent
2265322652 then $T_r$ is
22654- \FunctionTypePositional{R_0 }{ }{X}{B}{s}{R }{n}{k}
22653+ \FunctionTypePositional{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{k}
2265522654
2265622655 \noindent
22657- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22656+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22657+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
2265822658\item If $T_u$ is of the form
2265922659 \FunctionTypeNamedStd{T_0}
2266022660
2266122661 \noindent
2266222662 where $r_j$ is either \REQUIRED{} or empty
2266322663 then $T_r$ is
2266422664 \noindent
22665- \FunctionTypeNamed{R_0 }{ }{X}{B}{s}{R }{n}{x}{k}{r }
22665+ \FunctionTypeNamed{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{x}{k}
2266622666
2266722667 \noindent
22668- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22668+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22669+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
2266922670\end{itemize}
2267022671
2267122672\commentary{%
@@ -23003,8 +23004,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2300323004which is defined as follows.
2300423005Assume that $P_1$ and $P_2$ are two formal parameter type declarations
2300523006with declared type $T_1$ respectively $T_2$,
23006- such that both are positional or both are named ,
23007- with the same name \DefineSymbol{n}.
23007+ such that both are positional,
23008+ or both are named and have the same name \DefineSymbol{n}.
2300823009Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
2300923010is the formal parameter declaration $P$,
2301023011with the following proporties:
@@ -23023,7 +23024,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2302323024 }
2302423025\item
2302523026 $P$ is named if $P_1$ and $P_2$ are named.
23026- In this case, the name of $P$ is $n$.
23027+ In this case, the name of $P$ is $n$
23028+ (\commentary{which is also the name of $P_1$ and $P_2$}).
2302723029 $P$ is marked with the modifier \REQUIRED{}
2302823030 if both $P_1$ and $P_2$ have this modifier
2302923031 (respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -23202,22 +23204,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2320223204
2320323205 \noindent
2320423206 \code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
23205- \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\ ,$P_{1k}$)}
23207+ \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\ ,$P_{1k}$] )}
2320623208
2320723209 \noindent
2320823210 \code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
23209- \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\ ,$P_{2l}$)}
23211+ \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\ ,$P_{2l}$] )}
2321023212
2321123213 \noindent
2321223214 such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
23213- and both have the same number of required positional parameters.
23215+ and both $U_1$ or $U_2$ have
23216+ the same number of required positional parameters.
23217+ In the case where $U_1$ or $U_2$ has no optional positional parameters,
23218+ the brackets are omitted.
2321423219 Let $q$ be $\metavar{min}(k, l)$,
2321523220 let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
23216- let $B_{3i}$ be $B_{1i}$, and
23221+ let $B_{3i}$ be $B_{1i}$, and finally
2321723222 let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
23218- Then \DefEquals {\UpperBoundType{$U_1$}{$U_2$}}{%
23223+ Then \DefEqualsNewline {\UpperBoundType{$U_1$}{$U_2$}}{%
2321923224 \code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
23220- \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\ ,$P_{3q}$)}}.
23225+ \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\ ,$P_{3q}$] )}}.
2322123226
2322223227 \commentary{%
2322323228 This case includes non-generic function types by allowing $m$ to be zero.%
@@ -23275,8 +23280,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2327523280%%
2327623281%% TODO(eernst), for review: Why do we not have a rule for
2327723282%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
23278- %% = T3 Function(R1..Rk), where the left operand has at least k parameters,
23279- %% plus the converse?
23283+ %% = T3 Function(R1..Rk), where the left operand has at least k parameters
23284+ %% and every named parameter of the right operand is optional (plus the
23285+ %% same rule with operands swapped)?
23286+ %% Motivation: Some expressions of type `Function` would then have a more
23287+ %% precise type, and programs would be safer (a tiny bit, at least).
2328023288%%
2328123289\item
2328223290 \DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -23639,7 +23647,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2363923647$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
2364023648for any natural number $n$.
2364123649Let $q$ be the largest number such that $M_q$ has cardinality one.
23642- Such a number must exist because $M_0$ is $\{\code{Object? }\}$.
23650+ Such a number must exist because $M_0$ is $\{\code{Object}\}$.
2364323651The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
2364423652
2364523653
@@ -23872,7 +23880,7 @@ \subsection{Least and Greatest Closure of Types}
2387223880 the least closure of $S$ with respect to $L$ is
2387323881
2387423882 \noindent
23875- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23883+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2387623884
2387723885 \noindent
2387823886 where
@@ -23887,7 +23895,7 @@ \subsection{Least and Greatest Closure of Types}
2388723895 the greatest closure of $S$ with respect to $L$ is
2388823896
2388923897 \noindent
23890- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23898+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2389123899
2389223900 \noindent
2389323901 where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23943,15 +23951,17 @@ \subsection{Types Bounded by Types}
2394323951\LMLabel{typesBoundedByTypes}
2394423952
2394523953\LMHash{}%
23946- For a given type $T_0$, we introduce the notion of a
23947- \IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
23948- $T_0$ itself is $T_0$ bounded;
23949- if $B$ is $T_0$ bounded and
23954+ For a given type $T$, we introduce the notion of a
23955+ % `T bounded` at the end should have been `$T$ bounded`, but makeindex
23956+ % seems to be unable to allow math mode in that position.
23957+ \IndexCustom{$T$ bounded type}{type!T bounded}:
23958+ $T$ itself is $T$ bounded;
23959+ if $B$ is $T$ bounded and
2395023960$X$ is a type variable with bound $B$
23951- then $X$ is $T_0 $ bounded;
23952- finally, if $B$ is $T_0 $ bounded and
23961+ then $X$ is $T $ bounded;
23962+ finally, if $B$ is $T $ bounded and
2395323963$X$ is a type variable
23954- then $X \& B$ is $T_0 $ bounded.
23964+ then $X \& B$ is $T $ bounded.
2395523965
2395623966\LMHash{}%
2395723967In particular, a
@@ -23965,11 +23975,11 @@ \subsection{Types Bounded by Types}
2396523975\LMHash{}%
2396623976A
2396723977\IndexCustom{function-type bounded type}{type!function-type bounded}
23968- is a type $T $ which is $T_0 $ bounded where $T_0 $ is a function type
23978+ is a type $S $ which is $T $ bounded where $T $ is a function type
2396923979(\ref{functionTypes}).
23970- A function-type bounded type $T $ has an
23980+ A function-type bounded type $S $ has an
2397123981\Index{associated function type}
23972- which is the unique function type $T_0 $ such that $T $ is $T_0 $ bounded.
23982+ which is the unique function type $T $ such that $S $ is $T $ bounded.
2397323983
2397423984
2397523985\subsection{Class Building Types}
@@ -24030,7 +24040,7 @@ \subsection{Interface Types}
2403024040are interface types,
2403124041and so are
2403224042\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
24033- \code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
24043+ \code{List<$T$>}, \code{Map<$S$,\,\,$T$> }, and \code{Set<$T$>},
2403424044for any $S$ and $T$.%
2403524045}
2403624046
@@ -24156,8 +24166,13 @@ \subsection{Type Null}
2415624166\code{Null} is a subtype of all types of the form \code{$T$?},
2415724167and of all types $S$ such that \futureOrBase{S} is
2415824168a top type or a type of the form \code{$T$?}.
24159- The only non-trivial subtypes of \code{Null} are
24160- \code{Never} and subtypes of \code{Never}
24169+ The only subtypes of \code{Null} are
24170+ other types that contain the null object and no other objects,
24171+ e.g., \code{Null?},
24172+ the empty type,
24173+ i.e., \code{Never} and subtypes of \code{Never},
24174+ and types that could be either,
24175+ e.g., a type variable with bound \code{Null}
2416124176(\ref{subtypeRules}).%
2416224177}
2416324178
@@ -24683,22 +24698,10 @@ \subsection{Type Void}
2468324698\commentary{%
2468424699The type \VOID{} is a top type
2468524700(\ref{superBoundedTypes}),
24686- so \VOID{} and \code{Object} are subtypes of each other
24701+ so \VOID{} and \code{Object? } are subtypes of each other
2468724702(\ref{subtypes}),
2468824703which also implies that any object can be
24689- the value of an expression of type \VOID.
24690- %
24691- Consequently, any instance of type \code{Type} which reifies the type \VOID{}
24692- must compare equal (according to the \lit{==} operator \ref{equality})
24693- to any instance of \code{Type} which reifies the type \code{Object}
24694- (\ref{dynamicTypeSystem}).
24695- It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
24696- the \TRUE{} object.
24697- In fact, it is not recommended that implementations strive to achieve this,
24698- because it may be more important to ensure that diagnostic messages
24699- (including stack traces and dynamic error messages)
24700- preserve enough information to use the word `void' when referring to types
24701- which are specified as such in source code.%
24704+ the value of an expression of type \VOID.%
2470224705}
2470324706
2470424707\LMHash{}%
@@ -24836,7 +24839,7 @@ \subsection{Type Void}
2483624839}
2483724840
2483824841\begin{dartCode}
24839- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
24842+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
2484024843\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
2484124844\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
2484224845\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -25145,9 +25148,11 @@ \subsection{Definite Assignment}
2514525148(\commentary{%
2514625149e.g., as an expression, or as the left hand side of an assignment%
2514725150}),
25148- the variable has a status as being
25149- \IndexCustom{definitely assigned}{local variable!definitely assigned} or
25150- \IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
25151+ the variable can be
25152+ \IndexCustom{definitely assigned}{local variable!definitely assigned},
25153+ and it can be
25154+ \IndexCustom{definitely unassigned}{local variable!definitely unassigned},
25155+ and it can be neither.
2515125156
2515225157\commentary{%
2515325158The precise flow analysis which determines this status at each location
@@ -25400,15 +25405,16 @@ \subsection{Type Promotion}
2540025405
2540125406%% TODO(eernst), for review: The null safety spec says that `T?` is
2540225407%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25403- %% `X & int`. So I've specified the latter. This is also more consistent
25404- %% with the approach used with `==`.
25408+ %% `X & int`. So we may be able to specify something which will yield
25409+ %% slightly more precise types, and which is more precisely the implemented
25410+ %% behavior.
2540525411\LMHash{}%
2540625412A check of the form \code{$v$\,\,!=\,\,\NULL},
2540725413\code{\NULL\,\,!=\,\,$v$},
2540825414or \code{$v$\,\,\IS\,\,$T$}
25409- where $v$ has type $T$ at $\ell$
25415+ where $v$ has static type $T? $ at $\ell$
2541025416promotes the type of $v$
25411- to \NonNullType{ $T$} in the \TRUE{} continuation,
25417+ to $T$ in the \TRUE{} continuation,
2541225418and to \code{Null} in the \FALSE{} continuation.
2541325419
2541425420\commentary{%
0 commit comments