@@ -21654,9 +21654,6 @@ \subsection{Subtypes}
21654
21654
\newcommand{\SrnRightTop}{2}
21655
21655
\newcommand{\SrnLeftTop}{3}
21656
21656
\newcommand{\SrnBottom}{4}
21657
- %\newcommand{\SrnRightObjectOne}{} Redundant
21658
- %\newcommand{\SrnRightObjectTwo}{} Redundant
21659
- %\newcommand{\SrnRightObjectThree}{} Redundant
21660
21657
\newcommand{\SrnRightObjectFour}{5}
21661
21658
\newcommand{\SrnNullOne}{6}
21662
21659
\newcommand{\SrnNullTwo}{7}
@@ -22267,7 +22264,8 @@ \subsection{Type Nullability}
22267
22264
Nullable types are types which are
22268
22265
definitively known to include the null object,
22269
22266
regardless of the value of any type variables.
22270
- This is equivalent to the syntactic criterion that $T$ is any of:
22267
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22268
+ then this is equivalent to the syntactic criterion that $T'$ is any of:
22271
22269
22272
22270
\begin{itemize}[itemsep=-0.5ex]
22273
22271
\item \VOID.
@@ -22289,7 +22287,8 @@ \subsection{Type Nullability}
22289
22287
Non-nullable types are types which are definitively known to
22290
22288
\emph{not} include the null object,
22291
22289
regardless of the value of any type variables.
22292
- This is equivalent to the syntactic criterion that $T$ is any of:
22290
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22291
+ then this is equivalent to the syntactic criterion that $T$ is any of:
22293
22292
22294
22293
\begin{itemize}[itemsep=-0.5ex]
22295
22294
\item \code{Never}.
@@ -22656,21 +22655,23 @@ \subsection{Type Normalization}
22656
22655
22657
22656
\noindent
22658
22657
then $T_r$ is
22659
- \FunctionTypePositional{R_0 }{ }{X}{B}{s}{R }{n}{k}
22658
+ \FunctionTypePositional{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{k}
22660
22659
22661
22660
\noindent
22662
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22661
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22662
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
22663
22663
\item If $T_u$ is of the form
22664
22664
\FunctionTypeNamedStd{T_0}
22665
22665
22666
22666
\noindent
22667
22667
where $r_j$ is either \REQUIRED{} or empty
22668
22668
then $T_r$ is
22669
22669
\noindent
22670
- \FunctionTypeNamed{R_0 }{ }{X}{B}{s}{R }{n}{x}{k}{r }
22670
+ \FunctionTypeNamed{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{x}{k}
22671
22671
22672
22672
\noindent
22673
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22673
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22674
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
22674
22675
\end{itemize}
22675
22676
22676
22677
\commentary{%
@@ -23008,8 +23009,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23008
23009
which is defined as follows.
23009
23010
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
23010
23011
with declared type $T_1$ respectively $T_2$,
23011
- such that both are positional or both are named ,
23012
- with the same name \DefineSymbol{n}.
23012
+ such that both are positional,
23013
+ or both are named and have the same name \DefineSymbol{n}.
23013
23014
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
23014
23015
is the formal parameter declaration $P$,
23015
23016
with the following proporties:
@@ -23028,7 +23029,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23028
23029
}
23029
23030
\item
23030
23031
$P$ is named if $P_1$ and $P_2$ are named.
23031
- In this case, the name of $P$ is $n$.
23032
+ In this case, the name of $P$ is $n$
23033
+ (\commentary{which is also the name of $P_1$ and $P_2$}).
23032
23034
$P$ is marked with the modifier \REQUIRED{}
23033
23035
if both $P_1$ and $P_2$ have this modifier
23034
23036
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -23207,22 +23209,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23207
23209
23208
23210
\noindent
23209
23211
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
23210
- \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\ ,$P_{1k}$)}
23212
+ \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\ ,$P_{1k}$] )}
23211
23213
23212
23214
\noindent
23213
23215
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
23214
- \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\ ,$P_{2l}$)}
23216
+ \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\ ,$P_{2l}$] )}
23215
23217
23216
23218
\noindent
23217
23219
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
23218
- and both have the same number of required positional parameters.
23220
+ and both $U_1$ or $U_2$ have
23221
+ the same number of required positional parameters.
23222
+ In the case where $U_1$ or $U_2$ has no optional positional parameters,
23223
+ the brackets are omitted.
23219
23224
Let $q$ be $\metavar{min}(k, l)$,
23220
23225
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
23221
- let $B_{3i}$ be $B_{1i}$, and
23226
+ let $B_{3i}$ be $B_{1i}$, and finally
23222
23227
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
23223
- Then \DefEquals {\UpperBoundType{$U_1$}{$U_2$}}{%
23228
+ Then \DefEqualsNewline {\UpperBoundType{$U_1$}{$U_2$}}{%
23224
23229
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
23225
- \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\ ,$P_{3q}$)}}.
23230
+ \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\ ,$P_{3q}$] )}}.
23226
23231
23227
23232
\commentary{%
23228
23233
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -23280,8 +23285,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23280
23285
%%
23281
23286
%% TODO(eernst), for review: Why do we not have a rule for
23282
23287
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
23283
- %% = T3 Function(R1..Rk), where the left operand has at least k parameters,
23284
- %% plus the converse?
23288
+ %% = T3 Function(R1..Rk), where the left operand has at least k parameters
23289
+ %% and every named parameter of the right operand is optional (plus the
23290
+ %% same rule with operands swapped)?
23291
+ %% Motivation: Some expressions of type `Function` would then have a more
23292
+ %% precise type, and programs would be safer (a tiny bit, at least).
23285
23293
%%
23286
23294
\item
23287
23295
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -23644,7 +23652,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23644
23652
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
23645
23653
for any natural number $n$.
23646
23654
Let $q$ be the largest number such that $M_q$ has cardinality one.
23647
- Such a number must exist because $M_0$ is $\{\code{Object? }\}$.
23655
+ Such a number must exist because $M_0$ is $\{\code{Object}\}$.
23648
23656
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
23649
23657
23650
23658
@@ -23877,7 +23885,7 @@ \subsection{Least and Greatest Closure of Types}
23877
23885
the least closure of $S$ with respect to $L$ is
23878
23886
23879
23887
\noindent
23880
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23888
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23881
23889
23882
23890
\noindent
23883
23891
where
@@ -23892,7 +23900,7 @@ \subsection{Least and Greatest Closure of Types}
23892
23900
the greatest closure of $S$ with respect to $L$ is
23893
23901
23894
23902
\noindent
23895
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23903
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23896
23904
23897
23905
\noindent
23898
23906
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23948,15 +23956,17 @@ \subsection{Types Bounded by Types}
23948
23956
\LMLabel{typesBoundedByTypes}
23949
23957
23950
23958
\LMHash{}%
23951
- For a given type $T_0$, we introduce the notion of a
23952
- \IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
23953
- $T_0$ itself is $T_0$ bounded;
23954
- if $B$ is $T_0$ bounded and
23959
+ For a given type $T$, we introduce the notion of a
23960
+ % `T bounded` at the end should have been `$T$ bounded`, but makeindex
23961
+ % seems to be unable to allow math mode in that position.
23962
+ \IndexCustom{$T$ bounded type}{type!T bounded}:
23963
+ $T$ itself is $T$ bounded;
23964
+ if $B$ is $T$ bounded and
23955
23965
$X$ is a type variable with bound $B$
23956
- then $X$ is $T_0 $ bounded;
23957
- finally, if $B$ is $T_0 $ bounded and
23966
+ then $X$ is $T $ bounded;
23967
+ finally, if $B$ is $T $ bounded and
23958
23968
$X$ is a type variable
23959
- then $X \& B$ is $T_0 $ bounded.
23969
+ then $X \& B$ is $T $ bounded.
23960
23970
23961
23971
\LMHash{}%
23962
23972
In particular, a
@@ -23970,11 +23980,11 @@ \subsection{Types Bounded by Types}
23970
23980
\LMHash{}%
23971
23981
A
23972
23982
\IndexCustom{function-type bounded type}{type!function-type bounded}
23973
- is a type $T $ which is $T_0 $ bounded where $T_0 $ is a function type
23983
+ is a type $S $ which is $T $ bounded where $T $ is a function type
23974
23984
(\ref{functionTypes}).
23975
- A function-type bounded type $T $ has an
23985
+ A function-type bounded type $S $ has an
23976
23986
\Index{associated function type}
23977
- which is the unique function type $T_0 $ such that $T $ is $T_0 $ bounded.
23987
+ which is the unique function type $T $ such that $S $ is $T $ bounded.
23978
23988
23979
23989
23980
23990
\subsection{Class Building Types}
@@ -24035,7 +24045,7 @@ \subsection{Interface Types}
24035
24045
are interface types,
24036
24046
and so are
24037
24047
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
24038
- \code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
24048
+ \code{List<$T$>}, \code{Map<$S$,\,\,$T$> }, and \code{Set<$T$>},
24039
24049
for any $S$ and $T$.%
24040
24050
}
24041
24051
@@ -24161,8 +24171,13 @@ \subsection{Type Null}
24161
24171
\code{Null} is a subtype of all types of the form \code{$T$?},
24162
24172
and of all types $S$ such that \futureOrBase{S} is
24163
24173
a top type or a type of the form \code{$T$?}.
24164
- The only non-trivial subtypes of \code{Null} are
24165
- \code{Never} and subtypes of \code{Never}
24174
+ The only subtypes of \code{Null} are
24175
+ other types that contain the null object and no other objects,
24176
+ e.g., \code{Null?},
24177
+ the empty type,
24178
+ i.e., \code{Never} and subtypes of \code{Never},
24179
+ and types that could be either,
24180
+ e.g., a type variable with bound \code{Null}
24166
24181
(\ref{subtypeRules}).%
24167
24182
}
24168
24183
@@ -24688,22 +24703,10 @@ \subsection{Type Void}
24688
24703
\commentary{%
24689
24704
The type \VOID{} is a top type
24690
24705
(\ref{superBoundedTypes}),
24691
- so \VOID{} and \code{Object} are subtypes of each other
24706
+ so \VOID{} and \code{Object? } are subtypes of each other
24692
24707
(\ref{subtypes}),
24693
24708
which also implies that any object can be
24694
- the value of an expression of type \VOID.
24695
- %
24696
- Consequently, any instance of type \code{Type} which reifies the type \VOID{}
24697
- must compare equal (according to the \lit{==} operator \ref{equality})
24698
- to any instance of \code{Type} which reifies the type \code{Object}
24699
- (\ref{dynamicTypeSystem}).
24700
- It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
24701
- the \TRUE{} object.
24702
- In fact, it is not recommended that implementations strive to achieve this,
24703
- because it may be more important to ensure that diagnostic messages
24704
- (including stack traces and dynamic error messages)
24705
- preserve enough information to use the word `void' when referring to types
24706
- which are specified as such in source code.%
24709
+ the value of an expression of type \VOID.%
24707
24710
}
24708
24711
24709
24712
\LMHash{}%
@@ -24841,7 +24844,7 @@ \subsection{Type Void}
24841
24844
}
24842
24845
24843
24846
\begin{dartCode}
24844
- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
24847
+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
24845
24848
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
24846
24849
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
24847
24850
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -25150,9 +25153,11 @@ \subsection{Definite Assignment}
25150
25153
(\commentary{%
25151
25154
e.g., as an expression, or as the left hand side of an assignment%
25152
25155
}),
25153
- the variable has a status as being
25154
- \IndexCustom{definitely assigned}{local variable!definitely assigned} or
25155
- \IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
25156
+ the variable can be
25157
+ \IndexCustom{definitely assigned}{local variable!definitely assigned},
25158
+ and it can be
25159
+ \IndexCustom{definitely unassigned}{local variable!definitely unassigned},
25160
+ and it can be neither.
25156
25161
25157
25162
\commentary{%
25158
25163
The precise flow analysis which determines this status at each location
@@ -25405,15 +25410,16 @@ \subsection{Type Promotion}
25405
25410
25406
25411
%% TODO(eernst), for review: The null safety spec says that `T?` is
25407
25412
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25408
- %% `X & int`. So I've specified the latter. This is also more consistent
25409
- %% with the approach used with `==`.
25413
+ %% `X & int`. So we may be able to specify something which will yield
25414
+ %% slightly more precise types, and which is more precisely the implemented
25415
+ %% behavior.
25410
25416
\LMHash{}%
25411
25417
A check of the form \code{$v$\,\,!=\,\,\NULL},
25412
25418
\code{\NULL\,\,!=\,\,$v$},
25413
25419
or \code{$v$\,\,\IS\,\,$T$}
25414
- where $v$ has type $T$ at $\ell$
25420
+ where $v$ has static type $T? $ at $\ell$
25415
25421
promotes the type of $v$
25416
- to \NonNullType{ $T$} in the \TRUE{} continuation,
25422
+ to $T$ in the \TRUE{} continuation,
25417
25423
and to \code{Null} in the \FALSE{} continuation.
25418
25424
25419
25425
\commentary{%
0 commit comments