@@ -21421,9 +21421,6 @@ \subsection{Subtypes}
21421
21421
\newcommand{\SrnRightTop}{2}
21422
21422
\newcommand{\SrnLeftTop}{3}
21423
21423
\newcommand{\SrnBottom}{4}
21424
- %\newcommand{\SrnRightObjectOne}{} Redundant
21425
- %\newcommand{\SrnRightObjectTwo}{} Redundant
21426
- %\newcommand{\SrnRightObjectThree}{} Redundant
21427
21424
\newcommand{\SrnRightObjectFour}{5}
21428
21425
\newcommand{\SrnNullOne}{6}
21429
21426
\newcommand{\SrnNullTwo}{7}
@@ -22034,7 +22031,8 @@ \subsection{Type Nullability}
22034
22031
Nullable types are types which are
22035
22032
definitively known to include the null object,
22036
22033
regardless of the value of any type variables.
22037
- This is equivalent to the syntactic criterion that $T$ is any of:
22034
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22035
+ then this is equivalent to the syntactic criterion that $T'$ is any of:
22038
22036
22039
22037
\begin{itemize}[itemsep=-0.5ex]
22040
22038
\item \VOID.
@@ -22056,7 +22054,8 @@ \subsection{Type Nullability}
22056
22054
Non-nullable types are types which are definitively known to
22057
22055
\emph{not} include the null object,
22058
22056
regardless of the value of any type variables.
22059
- This is equivalent to the syntactic criterion that $T$ is any of:
22057
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22058
+ then this is equivalent to the syntactic criterion that $T$ is any of:
22060
22059
22061
22060
\begin{itemize}[itemsep=-0.5ex]
22062
22061
\item \code{Never}.
@@ -22423,21 +22422,23 @@ \subsection{Type Normalization}
22423
22422
22424
22423
\noindent
22425
22424
then $T_r$ is
22426
- \FunctionTypePositional{R_0 }{ }{X}{B}{s}{R }{n}{k}
22425
+ \FunctionTypePositional{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{k}
22427
22426
22428
22427
\noindent
22429
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22428
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22429
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
22430
22430
\item If $T_u$ is of the form
22431
22431
\FunctionTypeNamedStd{T_0}
22432
22432
22433
22433
\noindent
22434
22434
where $r_j$ is either \REQUIRED{} or empty
22435
22435
then $T_r$ is
22436
22436
\noindent
22437
- \FunctionTypeNamed{R_0 }{ }{X}{B}{s}{R }{n}{x}{k}{r }
22437
+ \FunctionTypeNamed{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{x}{k}
22438
22438
22439
22439
\noindent
22440
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22440
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22441
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
22441
22442
\end{itemize}
22442
22443
22443
22444
\commentary{%
@@ -22775,8 +22776,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22775
22776
which is defined as follows.
22776
22777
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
22777
22778
with declared type $T_1$ respectively $T_2$,
22778
- such that both are positional or both are named ,
22779
- with the same name \DefineSymbol{n}.
22779
+ such that both are positional,
22780
+ or both are named and have the same name \DefineSymbol{n}.
22780
22781
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
22781
22782
is the formal parameter declaration $P$,
22782
22783
with the following proporties:
@@ -22795,7 +22796,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22795
22796
}
22796
22797
\item
22797
22798
$P$ is named if $P_1$ and $P_2$ are named.
22798
- In this case, the name of $P$ is $n$.
22799
+ In this case, the name of $P$ is $n$
22800
+ (\commentary{which is also the name of $P_1$ and $P_2$}).
22799
22801
$P$ is marked with the modifier \REQUIRED{}
22800
22802
if both $P_1$ and $P_2$ have this modifier
22801
22803
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -22974,22 +22976,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22974
22976
22975
22977
\noindent
22976
22978
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
22977
- \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\ ,$P_{1k}$)}
22979
+ \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\ ,$P_{1k}$] )}
22978
22980
22979
22981
\noindent
22980
22982
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
22981
- \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\ ,$P_{2l}$)}
22983
+ \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\ ,$P_{2l}$] )}
22982
22984
22983
22985
\noindent
22984
22986
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
22985
- and both have the same number of required positional parameters.
22987
+ and both $U_1$ or $U_2$ have
22988
+ the same number of required positional parameters.
22989
+ In the case where $U_1$ or $U_2$ has no optional positional parameters,
22990
+ the brackets are omitted.
22986
22991
Let $q$ be $\metavar{min}(k, l)$,
22987
22992
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
22988
- let $B_{3i}$ be $B_{1i}$, and
22993
+ let $B_{3i}$ be $B_{1i}$, and finally
22989
22994
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
22990
- Then \DefEquals {\UpperBoundType{$U_1$}{$U_2$}}{%
22995
+ Then \DefEqualsNewline {\UpperBoundType{$U_1$}{$U_2$}}{%
22991
22996
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
22992
- \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\ ,$P_{3q}$)}}.
22997
+ \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\ ,$P_{3q}$] )}}.
22993
22998
22994
22999
\commentary{%
22995
23000
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -23047,8 +23052,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23047
23052
%%
23048
23053
%% TODO(eernst), for review: Why do we not have a rule for
23049
23054
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
23050
- %% = T3 Function(R1..Rk), where the left operand has at least k parameters,
23051
- %% plus the converse?
23055
+ %% = T3 Function(R1..Rk), where the left operand has at least k parameters
23056
+ %% and every named parameter of the right operand is optional (plus the
23057
+ %% same rule with operands swapped)?
23058
+ %% Motivation: Some expressions of type `Function` would then have a more
23059
+ %% precise type, and programs would be safer (a tiny bit, at least).
23052
23060
%%
23053
23061
\item
23054
23062
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -23411,7 +23419,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23411
23419
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
23412
23420
for any natural number $n$.
23413
23421
Let $q$ be the largest number such that $M_q$ has cardinality one.
23414
- Such a number must exist because $M_0$ is $\{\code{Object? }\}$.
23422
+ Such a number must exist because $M_0$ is $\{\code{Object}\}$.
23415
23423
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
23416
23424
23417
23425
@@ -23644,7 +23652,7 @@ \subsection{Least and Greatest Closure of Types}
23644
23652
the least closure of $S$ with respect to $L$ is
23645
23653
23646
23654
\noindent
23647
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23655
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23648
23656
23649
23657
\noindent
23650
23658
where
@@ -23659,7 +23667,7 @@ \subsection{Least and Greatest Closure of Types}
23659
23667
the greatest closure of $S$ with respect to $L$ is
23660
23668
23661
23669
\noindent
23662
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23670
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23663
23671
23664
23672
\noindent
23665
23673
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23715,15 +23723,17 @@ \subsection{Types Bounded by Types}
23715
23723
\LMLabel{typesBoundedByTypes}
23716
23724
23717
23725
\LMHash{}%
23718
- For a given type $T_0$, we introduce the notion of a
23719
- \IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
23720
- $T_0$ itself is $T_0$ bounded;
23721
- if $B$ is $T_0$ bounded and
23726
+ For a given type $T$, we introduce the notion of a
23727
+ % `T bounded` at the end should have been `$T$ bounded`, but makeindex
23728
+ % seems to be unable to allow math mode in that position.
23729
+ \IndexCustom{$T$ bounded type}{type!T bounded}:
23730
+ $T$ itself is $T$ bounded;
23731
+ if $B$ is $T$ bounded and
23722
23732
$X$ is a type variable with bound $B$
23723
- then $X$ is $T_0 $ bounded;
23724
- finally, if $B$ is $T_0 $ bounded and
23733
+ then $X$ is $T $ bounded;
23734
+ finally, if $B$ is $T $ bounded and
23725
23735
$X$ is a type variable
23726
- then $X \& B$ is $T_0 $ bounded.
23736
+ then $X \& B$ is $T $ bounded.
23727
23737
23728
23738
\LMHash{}%
23729
23739
In particular, a
@@ -23737,11 +23747,11 @@ \subsection{Types Bounded by Types}
23737
23747
\LMHash{}%
23738
23748
A
23739
23749
\IndexCustom{function-type bounded type}{type!function-type bounded}
23740
- is a type $T $ which is $T_0 $ bounded where $T_0 $ is a function type
23750
+ is a type $S $ which is $T $ bounded where $T $ is a function type
23741
23751
(\ref{functionTypes}).
23742
- A function-type bounded type $T $ has an
23752
+ A function-type bounded type $S $ has an
23743
23753
\Index{associated function type}
23744
- which is the unique function type $T_0 $ such that $T $ is $T_0 $ bounded.
23754
+ which is the unique function type $T $ such that $S $ is $T $ bounded.
23745
23755
23746
23756
23747
23757
\subsection{Class Building Types}
@@ -23802,7 +23812,7 @@ \subsection{Interface Types}
23802
23812
are interface types,
23803
23813
and so are
23804
23814
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23805
- \code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
23815
+ \code{List<$T$>}, \code{Map<$S$,\,\,$T$> }, and \code{Set<$T$>},
23806
23816
for any $S$ and $T$.%
23807
23817
}
23808
23818
@@ -23928,8 +23938,13 @@ \subsection{Type Null}
23928
23938
\code{Null} is a subtype of all types of the form \code{$T$?},
23929
23939
and of all types $S$ such that \futureOrBase{S} is
23930
23940
a top type or a type of the form \code{$T$?}.
23931
- The only non-trivial subtypes of \code{Null} are
23932
- \code{Never} and subtypes of \code{Never}
23941
+ The only subtypes of \code{Null} are
23942
+ other types that contain the null object and no other objects,
23943
+ e.g., \code{Null?},
23944
+ the empty type,
23945
+ i.e., \code{Never} and subtypes of \code{Never},
23946
+ and types that could be either,
23947
+ e.g., a type variable with bound \code{Null}
23933
23948
(\ref{subtypeRules}).%
23934
23949
}
23935
23950
@@ -24455,22 +24470,10 @@ \subsection{Type Void}
24455
24470
\commentary{%
24456
24471
The type \VOID{} is a top type
24457
24472
(\ref{superBoundedTypes}),
24458
- so \VOID{} and \code{Object} are subtypes of each other
24473
+ so \VOID{} and \code{Object? } are subtypes of each other
24459
24474
(\ref{subtypes}),
24460
24475
which also implies that any object can be
24461
- the value of an expression of type \VOID.
24462
- %
24463
- Consequently, any instance of type \code{Type} which reifies the type \VOID{}
24464
- must compare equal (according to the \lit{==} operator \ref{equality})
24465
- to any instance of \code{Type} which reifies the type \code{Object}
24466
- (\ref{dynamicTypeSystem}).
24467
- It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
24468
- the \TRUE{} object.
24469
- In fact, it is not recommended that implementations strive to achieve this,
24470
- because it may be more important to ensure that diagnostic messages
24471
- (including stack traces and dynamic error messages)
24472
- preserve enough information to use the word `void' when referring to types
24473
- which are specified as such in source code.%
24476
+ the value of an expression of type \VOID.%
24474
24477
}
24475
24478
24476
24479
\LMHash{}%
@@ -24608,7 +24611,7 @@ \subsection{Type Void}
24608
24611
}
24609
24612
24610
24613
\begin{dartCode}
24611
- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
24614
+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
24612
24615
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
24613
24616
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
24614
24617
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -24917,9 +24920,11 @@ \subsection{Definite Assignment}
24917
24920
(\commentary{%
24918
24921
e.g., as an expression, or as the left hand side of an assignment%
24919
24922
}),
24920
- the variable has a status as being
24921
- \IndexCustom{definitely assigned}{local variable!definitely assigned} or
24922
- \IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
24923
+ the variable can be
24924
+ \IndexCustom{definitely assigned}{local variable!definitely assigned},
24925
+ and it can be
24926
+ \IndexCustom{definitely unassigned}{local variable!definitely unassigned},
24927
+ and it can be neither.
24923
24928
24924
24929
\commentary{%
24925
24930
The precise flow analysis which determines this status at each location
@@ -25172,15 +25177,16 @@ \subsection{Type Promotion}
25172
25177
25173
25178
%% TODO(eernst), for review: The null safety spec says that `T?` is
25174
25179
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25175
- %% `X & int`. So I've specified the latter. This is also more consistent
25176
- %% with the approach used with `==`.
25180
+ %% `X & int`. So we may be able to specify something which will yield
25181
+ %% slightly more precise types, and which is more precisely the implemented
25182
+ %% behavior.
25177
25183
\LMHash{}%
25178
25184
A check of the form \code{$v$\,\,!=\,\,\NULL},
25179
25185
\code{\NULL\,\,!=\,\,$v$},
25180
25186
or \code{$v$\,\,\IS\,\,$T$}
25181
- where $v$ has type $T$ at $\ell$
25187
+ where $v$ has static type $T? $ at $\ell$
25182
25188
promotes the type of $v$
25183
- to \NonNullType{ $T$} in the \TRUE{} continuation,
25189
+ to $T$ in the \TRUE{} continuation,
25184
25190
and to \code{Null} in the \FALSE{} continuation.
25185
25191
25186
25192
\commentary{%
0 commit comments