@@ -21649,9 +21649,6 @@ \subsection{Subtypes}
21649
21649
\newcommand{\SrnRightTop}{2}
21650
21650
\newcommand{\SrnLeftTop}{3}
21651
21651
\newcommand{\SrnBottom}{4}
21652
- %\newcommand{\SrnRightObjectOne}{} Redundant
21653
- %\newcommand{\SrnRightObjectTwo}{} Redundant
21654
- %\newcommand{\SrnRightObjectThree}{} Redundant
21655
21652
\newcommand{\SrnRightObjectFour}{5}
21656
21653
\newcommand{\SrnNullOne}{6}
21657
21654
\newcommand{\SrnNullTwo}{7}
@@ -22262,7 +22259,8 @@ \subsection{Type Nullability}
22262
22259
Nullable types are types which are
22263
22260
definitively known to include the null object,
22264
22261
regardless 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:
22266
22264
22267
22265
\begin{itemize}[itemsep=-0.5ex]
22268
22266
\item \VOID.
@@ -22284,7 +22282,8 @@ \subsection{Type Nullability}
22284
22282
Non-nullable types are types which are definitively known to
22285
22283
\emph{not} include the null object,
22286
22284
regardless 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:
22288
22287
22289
22288
\begin{itemize}[itemsep=-0.5ex]
22290
22289
\item \code{Never}.
@@ -22651,21 +22650,23 @@ \subsection{Type Normalization}
22651
22650
22652
22651
\noindent
22653
22652
then $T_r$ is
22654
- \FunctionTypePositional{R_0 }{ }{X}{B}{s}{R }{n}{k}
22653
+ \FunctionTypePositional{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{k}
22655
22654
22656
22655
\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$.
22658
22658
\item If $T_u$ is of the form
22659
22659
\FunctionTypeNamedStd{T_0}
22660
22660
22661
22661
\noindent
22662
22662
where $r_j$ is either \REQUIRED{} or empty
22663
22663
then $T_r$ is
22664
22664
\noindent
22665
- \FunctionTypeNamed{R_0 }{ }{X}{B}{s}{R }{n}{x}{k}{r }
22665
+ \FunctionTypeNamed{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{x}{k}
22666
22666
22667
22667
\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$.
22669
22670
\end{itemize}
22670
22671
22671
22672
\commentary{%
@@ -23003,8 +23004,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23003
23004
which is defined as follows.
23004
23005
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
23005
23006
with 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}.
23008
23009
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
23009
23010
is the formal parameter declaration $P$,
23010
23011
with the following proporties:
@@ -23023,7 +23024,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23023
23024
}
23024
23025
\item
23025
23026
$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$}).
23027
23029
$P$ is marked with the modifier \REQUIRED{}
23028
23030
if both $P_1$ and $P_2$ have this modifier
23029
23031
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -23202,22 +23204,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23202
23204
23203
23205
\noindent
23204
23206
\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}$] )}
23206
23208
23207
23209
\noindent
23208
23210
\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}$] )}
23210
23212
23211
23213
\noindent
23212
23214
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.
23214
23219
Let $q$ be $\metavar{min}(k, l)$,
23215
23220
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
23217
23222
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$}}{%
23219
23224
\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}$] )}}.
23221
23226
23222
23227
\commentary{%
23223
23228
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}
23275
23280
%%
23276
23281
%% TODO(eernst), for review: Why do we not have a rule for
23277
23282
%% \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).
23280
23288
%%
23281
23289
\item
23282
23290
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -23639,7 +23647,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23639
23647
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
23640
23648
for any natural number $n$.
23641
23649
Let $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}\}$.
23643
23651
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
23644
23652
23645
23653
@@ -23872,7 +23880,7 @@ \subsection{Least and Greatest Closure of Types}
23872
23880
the least closure of $S$ with respect to $L$ is
23873
23881
23874
23882
\noindent
23875
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23883
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23876
23884
23877
23885
\noindent
23878
23886
where
@@ -23887,7 +23895,7 @@ \subsection{Least and Greatest Closure of Types}
23887
23895
the greatest closure of $S$ with respect to $L$ is
23888
23896
23889
23897
\noindent
23890
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23898
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23891
23899
23892
23900
\noindent
23893
23901
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23943,15 +23951,17 @@ \subsection{Types Bounded by Types}
23943
23951
\LMLabel{typesBoundedByTypes}
23944
23952
23945
23953
\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
23950
23960
$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
23953
23963
$X$ is a type variable
23954
- then $X \& B$ is $T_0 $ bounded.
23964
+ then $X \& B$ is $T $ bounded.
23955
23965
23956
23966
\LMHash{}%
23957
23967
In particular, a
@@ -23965,11 +23975,11 @@ \subsection{Types Bounded by Types}
23965
23975
\LMHash{}%
23966
23976
A
23967
23977
\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
23969
23979
(\ref{functionTypes}).
23970
- A function-type bounded type $T $ has an
23980
+ A function-type bounded type $S $ has an
23971
23981
\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.
23973
23983
23974
23984
23975
23985
\subsection{Class Building Types}
@@ -24030,7 +24040,7 @@ \subsection{Interface Types}
24030
24040
are interface types,
24031
24041
and so are
24032
24042
\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$>},
24034
24044
for any $S$ and $T$.%
24035
24045
}
24036
24046
@@ -24156,8 +24166,13 @@ \subsection{Type Null}
24156
24166
\code{Null} is a subtype of all types of the form \code{$T$?},
24157
24167
and of all types $S$ such that \futureOrBase{S} is
24158
24168
a 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}
24161
24176
(\ref{subtypeRules}).%
24162
24177
}
24163
24178
@@ -24683,22 +24698,10 @@ \subsection{Type Void}
24683
24698
\commentary{%
24684
24699
The type \VOID{} is a top type
24685
24700
(\ref{superBoundedTypes}),
24686
- so \VOID{} and \code{Object} are subtypes of each other
24701
+ so \VOID{} and \code{Object? } are subtypes of each other
24687
24702
(\ref{subtypes}),
24688
24703
which 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.%
24702
24705
}
24703
24706
24704
24707
\LMHash{}%
@@ -24836,7 +24839,7 @@ \subsection{Type Void}
24836
24839
}
24837
24840
24838
24841
\begin{dartCode}
24839
- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
24842
+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
24840
24843
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
24841
24844
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
24842
24845
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -25145,9 +25148,11 @@ \subsection{Definite Assignment}
25145
25148
(\commentary{%
25146
25149
e.g., as an expression, or as the left hand side of an assignment%
25147
25150
}),
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.
25151
25156
25152
25157
\commentary{%
25153
25158
The precise flow analysis which determines this status at each location
@@ -25400,15 +25405,16 @@ \subsection{Type Promotion}
25400
25405
25401
25406
%% TODO(eernst), for review: The null safety spec says that `T?` is
25402
25407
%% 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.
25405
25411
\LMHash{}%
25406
25412
A check of the form \code{$v$\,\,!=\,\,\NULL},
25407
25413
\code{\NULL\,\,!=\,\,$v$},
25408
25414
or \code{$v$\,\,\IS\,\,$T$}
25409
- where $v$ has type $T$ at $\ell$
25415
+ where $v$ has static type $T? $ at $\ell$
25410
25416
promotes the type of $v$
25411
- to \NonNullType{ $T$} in the \TRUE{} continuation,
25417
+ to $T$ in the \TRUE{} continuation,
25412
25418
and to \code{Null} in the \FALSE{} continuation.
25413
25419
25414
25420
\commentary{%
0 commit comments