@@ -20710,9 +20710,6 @@ \subsection{Subtypes}
20710
20710
\newcommand{\SrnRightTop}{2}
20711
20711
\newcommand{\SrnLeftTop}{3}
20712
20712
\newcommand{\SrnBottom}{4}
20713
- %\newcommand{\SrnRightObjectOne}{} Redundant
20714
- %\newcommand{\SrnRightObjectTwo}{} Redundant
20715
- %\newcommand{\SrnRightObjectThree}{} Redundant
20716
20713
\newcommand{\SrnRightObjectFour}{5}
20717
20714
\newcommand{\SrnNullOne}{6}
20718
20715
\newcommand{\SrnNullTwo}{7}
@@ -21323,7 +21320,8 @@ \subsection{Type Nullability}
21323
21320
Nullable types are types which are
21324
21321
definitively known to include the null object,
21325
21322
regardless of the value of any type variables.
21326
- This is equivalent to the syntactic criterion that $T$ is any of:
21323
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21324
+ then this is equivalent to the syntactic criterion that $T'$ is any of:
21327
21325
21328
21326
\begin{itemize}[itemsep=-0.5ex]
21329
21327
\item \VOID.
@@ -21345,7 +21343,8 @@ \subsection{Type Nullability}
21345
21343
Non-nullable types are types which are definitively known to
21346
21344
\emph{not} include the null object,
21347
21345
regardless of the value of any type variables.
21348
- This is equivalent to the syntactic criterion that $T$ is any of:
21346
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21347
+ then this is equivalent to the syntactic criterion that $T$ is any of:
21349
21348
21350
21349
\begin{itemize}[itemsep=-0.5ex]
21351
21350
\item \code{Never}.
@@ -21712,21 +21711,23 @@ \subsection{Type Normalization}
21712
21711
21713
21712
\noindent
21714
21713
then $T_r$ is
21715
- \FunctionTypePositional{R_0 }{ }{X}{B}{s}{R }{n}{k}
21714
+ \FunctionTypePositional{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{k}
21716
21715
21717
21716
\noindent
21718
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21717
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21718
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
21719
21719
\item If $T_u$ is of the form
21720
21720
\FunctionTypeNamedStd{T_0}
21721
21721
21722
21722
\noindent
21723
21723
where $r_j$ is either \REQUIRED{} or empty
21724
21724
then $T_r$ is
21725
21725
\noindent
21726
- \FunctionTypeNamed{R_0 }{ }{X}{B}{s}{R }{n}{x}{k}{r }
21726
+ \FunctionTypeNamed{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{x}{k}
21727
21727
21728
21728
\noindent
21729
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21729
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21730
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
21730
21731
\end{itemize}
21731
21732
21732
21733
\commentary{%
@@ -22064,8 +22065,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22064
22065
which is defined as follows.
22065
22066
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
22066
22067
with declared type $T_1$ respectively $T_2$,
22067
- such that both are positional or both are named ,
22068
- with the same name \DefineSymbol{n}.
22068
+ such that both are positional,
22069
+ or both are named and have the same name \DefineSymbol{n}.
22069
22070
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
22070
22071
is the formal parameter declaration $P$,
22071
22072
with the following proporties:
@@ -22084,7 +22085,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22084
22085
}
22085
22086
\item
22086
22087
$P$ is named if $P_1$ and $P_2$ are named.
22087
- In this case, the name of $P$ is $n$.
22088
+ In this case, the name of $P$ is $n$
22089
+ (\commentary{which is also the name of $P_1$ and $P_2$}).
22088
22090
$P$ is marked with the modifier \REQUIRED{}
22089
22091
if both $P_1$ and $P_2$ have this modifier
22090
22092
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -22263,22 +22265,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22263
22265
22264
22266
\noindent
22265
22267
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
22266
- \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\ ,$P_{1k}$)}
22268
+ \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\ ,$P_{1k}$] )}
22267
22269
22268
22270
\noindent
22269
22271
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
22270
- \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\ ,$P_{2l}$)}
22272
+ \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\ ,$P_{2l}$] )}
22271
22273
22272
22274
\noindent
22273
22275
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
22274
- and both have the same number of required positional parameters.
22276
+ and both $U_1$ or $U_2$ have
22277
+ the same number of required positional parameters.
22278
+ In the case where $U_1$ or $U_2$ has no optional positional parameters,
22279
+ the brackets are omitted.
22275
22280
Let $q$ be $\metavar{min}(k, l)$,
22276
22281
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
22277
- let $B_{3i}$ be $B_{1i}$, and
22282
+ let $B_{3i}$ be $B_{1i}$, and finally
22278
22283
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
22279
- Then \DefEquals {\UpperBoundType{$U_1$}{$U_2$}}{%
22284
+ Then \DefEqualsNewline {\UpperBoundType{$U_1$}{$U_2$}}{%
22280
22285
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
22281
- \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\ ,$P_{3q}$)}}.
22286
+ \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\ ,$P_{3q}$] )}}.
22282
22287
22283
22288
\commentary{%
22284
22289
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -22336,8 +22341,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22336
22341
%%
22337
22342
%% TODO(eernst), for review: Why do we not have a rule for
22338
22343
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
22339
- %% = T3 Function(R1..Rk), where the left operand has at least k parameters,
22340
- %% plus the converse?
22344
+ %% = T3 Function(R1..Rk), where the left operand has at least k parameters
22345
+ %% and every named parameter of the right operand is optional (plus the
22346
+ %% same rule with operands swapped)?
22347
+ %% Motivation: Some expressions of type `Function` would then have a more
22348
+ %% precise type, and programs would be safer (a tiny bit, at least).
22341
22349
%%
22342
22350
\item
22343
22351
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -22700,7 +22708,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22700
22708
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
22701
22709
for any natural number $n$.
22702
22710
Let $q$ be the largest number such that $M_q$ has cardinality one.
22703
- Such a number must exist because $M_0$ is $\{\code{Object? }\}$.
22711
+ Such a number must exist because $M_0$ is $\{\code{Object}\}$.
22704
22712
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
22705
22713
22706
22714
@@ -22933,7 +22941,7 @@ \subsection{Least and Greatest Closure of Types}
22933
22941
the least closure of $S$ with respect to $L$ is
22934
22942
22935
22943
\noindent
22936
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22944
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
22937
22945
22938
22946
\noindent
22939
22947
where
@@ -22948,7 +22956,7 @@ \subsection{Least and Greatest Closure of Types}
22948
22956
the greatest closure of $S$ with respect to $L$ is
22949
22957
22950
22958
\noindent
22951
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22959
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
22952
22960
22953
22961
\noindent
22954
22962
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23004,15 +23012,17 @@ \subsection{Types Bounded by Types}
23004
23012
\LMLabel{typesBoundedByTypes}
23005
23013
23006
23014
\LMHash{}%
23007
- For a given type $T_0$, we introduce the notion of a
23008
- \IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
23009
- $T_0$ itself is $T_0$ bounded;
23010
- if $B$ is $T_0$ bounded and
23015
+ For a given type $T$, we introduce the notion of a
23016
+ % `T bounded` at the end should have been `$T$ bounded`, but makeindex
23017
+ % seems to be unable to allow math mode in that position.
23018
+ \IndexCustom{$T$ bounded type}{type!T bounded}:
23019
+ $T$ itself is $T$ bounded;
23020
+ if $B$ is $T$ bounded and
23011
23021
$X$ is a type variable with bound $B$
23012
- then $X$ is $T_0 $ bounded;
23013
- finally, if $B$ is $T_0 $ bounded and
23022
+ then $X$ is $T $ bounded;
23023
+ finally, if $B$ is $T $ bounded and
23014
23024
$X$ is a type variable
23015
- then $X \& B$ is $T_0 $ bounded.
23025
+ then $X \& B$ is $T $ bounded.
23016
23026
23017
23027
\LMHash{}%
23018
23028
In particular, a
@@ -23026,11 +23036,11 @@ \subsection{Types Bounded by Types}
23026
23036
\LMHash{}%
23027
23037
A
23028
23038
\IndexCustom{function-type bounded type}{type!function-type bounded}
23029
- is a type $T $ which is $T_0 $ bounded where $T_0 $ is a function type
23039
+ is a type $S $ which is $T $ bounded where $T $ is a function type
23030
23040
(\ref{functionTypes}).
23031
- A function-type bounded type $T $ has an
23041
+ A function-type bounded type $S $ has an
23032
23042
\Index{associated function type}
23033
- which is the unique function type $T_0 $ such that $T $ is $T_0 $ bounded.
23043
+ which is the unique function type $T $ such that $S $ is $T $ bounded.
23034
23044
23035
23045
23036
23046
\subsection{Class Building Types}
@@ -23091,7 +23101,7 @@ \subsection{Interface Types}
23091
23101
are interface types,
23092
23102
and so are
23093
23103
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23094
- \code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
23104
+ \code{List<$T$>}, \code{Map<$S$,\,\,$T$> }, and \code{Set<$T$>},
23095
23105
for any $S$ and $T$.%
23096
23106
}
23097
23107
@@ -23217,8 +23227,13 @@ \subsection{Type Null}
23217
23227
\code{Null} is a subtype of all types of the form \code{$T$?},
23218
23228
and of all types $S$ such that \futureOrBase{S} is
23219
23229
a top type or a type of the form \code{$T$?}.
23220
- The only non-trivial subtypes of \code{Null} are
23221
- \code{Never} and subtypes of \code{Never}
23230
+ The only subtypes of \code{Null} are
23231
+ other types that contain the null object and no other objects,
23232
+ e.g., \code{Null?},
23233
+ the empty type,
23234
+ i.e., \code{Never} and subtypes of \code{Never},
23235
+ and types that could be either,
23236
+ e.g., a type variable with bound \code{Null}
23222
23237
(\ref{subtypeRules}).%
23223
23238
}
23224
23239
@@ -23744,22 +23759,10 @@ \subsection{Type Void}
23744
23759
\commentary{%
23745
23760
The type \VOID{} is a top type
23746
23761
(\ref{superBoundedTypes}),
23747
- so \VOID{} and \code{Object} are subtypes of each other
23762
+ so \VOID{} and \code{Object? } are subtypes of each other
23748
23763
(\ref{subtypes}),
23749
23764
which also implies that any object can be
23750
- the value of an expression of type \VOID.
23751
- %
23752
- Consequently, any instance of type \code{Type} which reifies the type \VOID{}
23753
- must compare equal (according to the \lit{==} operator \ref{equality})
23754
- to any instance of \code{Type} which reifies the type \code{Object}
23755
- (\ref{dynamicTypeSystem}).
23756
- It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
23757
- the \TRUE{} object.
23758
- In fact, it is not recommended that implementations strive to achieve this,
23759
- because it may be more important to ensure that diagnostic messages
23760
- (including stack traces and dynamic error messages)
23761
- preserve enough information to use the word `void' when referring to types
23762
- which are specified as such in source code.%
23765
+ the value of an expression of type \VOID.%
23763
23766
}
23764
23767
23765
23768
\LMHash{}%
@@ -23897,7 +23900,7 @@ \subsection{Type Void}
23897
23900
}
23898
23901
23899
23902
\begin{dartCode}
23900
- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
23903
+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
23901
23904
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
23902
23905
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
23903
23906
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -24206,9 +24209,11 @@ \subsection{Definite Assignment}
24206
24209
(\commentary{%
24207
24210
e.g., as an expression, or as the left hand side of an assignment%
24208
24211
}),
24209
- the variable has a status as being
24210
- \IndexCustom{definitely assigned}{local variable!definitely assigned} or
24211
- \IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
24212
+ the variable can be
24213
+ \IndexCustom{definitely assigned}{local variable!definitely assigned},
24214
+ and it can be
24215
+ \IndexCustom{definitely unassigned}{local variable!definitely unassigned},
24216
+ and it can be neither.
24212
24217
24213
24218
\commentary{%
24214
24219
The precise flow analysis which determines this status at each location
@@ -24461,15 +24466,16 @@ \subsection{Type Promotion}
24461
24466
24462
24467
%% TODO(eernst), for review: The null safety spec says that `T?` is
24463
24468
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
24464
- %% `X & int`. So I've specified the latter. This is also more consistent
24465
- %% with the approach used with `==`.
24469
+ %% `X & int`. So we may be able to specify something which will yield
24470
+ %% slightly more precise types, and which is more precisely the implemented
24471
+ %% behavior.
24466
24472
\LMHash{}%
24467
24473
A check of the form \code{$v$\,\,!=\,\,\NULL},
24468
24474
\code{\NULL\,\,!=\,\,$v$},
24469
24475
or \code{$v$\,\,\IS\,\,$T$}
24470
- where $v$ has type $T$ at $\ell$
24476
+ where $v$ has static type $T? $ at $\ell$
24471
24477
promotes the type of $v$
24472
- to \NonNullType{ $T$} in the \TRUE{} continuation,
24478
+ to $T$ in the \TRUE{} continuation,
24473
24479
and to \code{Null} in the \FALSE{} continuation.
24474
24480
24475
24481
\commentary{%
0 commit comments