@@ -21466,9 +21466,6 @@ \subsection{Subtypes}
21466
21466
\newcommand{\SrnRightTop}{2}
21467
21467
\newcommand{\SrnLeftTop}{3}
21468
21468
\newcommand{\SrnBottom}{4}
21469
- %\newcommand{\SrnRightObjectOne}{} Redundant
21470
- %\newcommand{\SrnRightObjectTwo}{} Redundant
21471
- %\newcommand{\SrnRightObjectThree}{} Redundant
21472
21469
\newcommand{\SrnRightObjectFour}{5}
21473
21470
\newcommand{\SrnNullOne}{6}
21474
21471
\newcommand{\SrnNullTwo}{7}
@@ -22079,7 +22076,8 @@ \subsection{Type Nullability}
22079
22076
Nullable types are types which are
22080
22077
definitively known to include the null object,
22081
22078
regardless of the value of any type variables.
22082
- This is equivalent to the syntactic criterion that $T$ is any of:
22079
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22080
+ then this is equivalent to the syntactic criterion that $T'$ is any of:
22083
22081
22084
22082
\begin{itemize}[itemsep=-0.5ex]
22085
22083
\item \VOID.
@@ -22101,7 +22099,8 @@ \subsection{Type Nullability}
22101
22099
Non-nullable types are types which are definitively known to
22102
22100
\emph{not} include the null object,
22103
22101
regardless of the value of any type variables.
22104
- This is equivalent to the syntactic criterion that $T$ is any of:
22102
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22103
+ then this is equivalent to the syntactic criterion that $T$ is any of:
22105
22104
22106
22105
\begin{itemize}[itemsep=-0.5ex]
22107
22106
\item \code{Never}.
@@ -22468,21 +22467,23 @@ \subsection{Type Normalization}
22468
22467
22469
22468
\noindent
22470
22469
then $T_r$ is
22471
- \FunctionTypePositional{R_0 }{ }{X}{B}{s}{R }{n}{k}
22470
+ \FunctionTypePositional{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{k}
22472
22471
22473
22472
\noindent
22474
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22473
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22474
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
22475
22475
\item If $T_u$ is of the form
22476
22476
\FunctionTypeNamedStd{T_0}
22477
22477
22478
22478
\noindent
22479
22479
where $r_j$ is either \REQUIRED{} or empty
22480
22480
then $T_r$ is
22481
22481
\noindent
22482
- \FunctionTypeNamed{R_0 }{ }{X}{B}{s}{R }{n}{x}{k}{r }
22482
+ \FunctionTypeNamed{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{x}{k}
22483
22483
22484
22484
\noindent
22485
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22485
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22486
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
22486
22487
\end{itemize}
22487
22488
22488
22489
\commentary{%
@@ -22820,8 +22821,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22820
22821
which is defined as follows.
22821
22822
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
22822
22823
with declared type $T_1$ respectively $T_2$,
22823
- such that both are positional or both are named ,
22824
- with the same name \DefineSymbol{n}.
22824
+ such that both are positional,
22825
+ or both are named and have the same name \DefineSymbol{n}.
22825
22826
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
22826
22827
is the formal parameter declaration $P$,
22827
22828
with the following proporties:
@@ -22840,7 +22841,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22840
22841
}
22841
22842
\item
22842
22843
$P$ is named if $P_1$ and $P_2$ are named.
22843
- In this case, the name of $P$ is $n$.
22844
+ In this case, the name of $P$ is $n$
22845
+ (\commentary{which is also the name of $P_1$ and $P_2$}).
22844
22846
$P$ is marked with the modifier \REQUIRED{}
22845
22847
if both $P_1$ and $P_2$ have this modifier
22846
22848
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -23019,22 +23021,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23019
23021
23020
23022
\noindent
23021
23023
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
23022
- \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\ ,$P_{1k}$)}
23024
+ \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\ ,$P_{1k}$] )}
23023
23025
23024
23026
\noindent
23025
23027
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
23026
- \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\ ,$P_{2l}$)}
23028
+ \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\ ,$P_{2l}$] )}
23027
23029
23028
23030
\noindent
23029
23031
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
23030
- and both have the same number of required positional parameters.
23032
+ and both $U_1$ or $U_2$ have
23033
+ the same number of required positional parameters.
23034
+ In the case where $U_1$ or $U_2$ has no optional positional parameters,
23035
+ the brackets are omitted.
23031
23036
Let $q$ be $\metavar{min}(k, l)$,
23032
23037
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
23033
- let $B_{3i}$ be $B_{1i}$, and
23038
+ let $B_{3i}$ be $B_{1i}$, and finally
23034
23039
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
23035
- Then \DefEquals {\UpperBoundType{$U_1$}{$U_2$}}{%
23040
+ Then \DefEqualsNewline {\UpperBoundType{$U_1$}{$U_2$}}{%
23036
23041
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
23037
- \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\ ,$P_{3q}$)}}.
23042
+ \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\ ,$P_{3q}$] )}}.
23038
23043
23039
23044
\commentary{%
23040
23045
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -23092,8 +23097,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
23092
23097
%%
23093
23098
%% TODO(eernst), for review: Why do we not have a rule for
23094
23099
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
23095
- %% = T3 Function(R1..Rk), where the left operand has at least k parameters,
23096
- %% plus the converse?
23100
+ %% = T3 Function(R1..Rk), where the left operand has at least k parameters
23101
+ %% and every named parameter of the right operand is optional (plus the
23102
+ %% same rule with operands swapped)?
23103
+ %% Motivation: Some expressions of type `Function` would then have a more
23104
+ %% precise type, and programs would be safer (a tiny bit, at least).
23097
23105
%%
23098
23106
\item
23099
23107
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -23456,7 +23464,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
23456
23464
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
23457
23465
for any natural number $n$.
23458
23466
Let $q$ be the largest number such that $M_q$ has cardinality one.
23459
- Such a number must exist because $M_0$ is $\{\code{Object? }\}$.
23467
+ Such a number must exist because $M_0$ is $\{\code{Object}\}$.
23460
23468
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
23461
23469
23462
23470
@@ -23689,7 +23697,7 @@ \subsection{Least and Greatest Closure of Types}
23689
23697
the least closure of $S$ with respect to $L$ is
23690
23698
23691
23699
\noindent
23692
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23700
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23693
23701
23694
23702
\noindent
23695
23703
where
@@ -23704,7 +23712,7 @@ \subsection{Least and Greatest Closure of Types}
23704
23712
the greatest closure of $S$ with respect to $L$ is
23705
23713
23706
23714
\noindent
23707
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23715
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
23708
23716
23709
23717
\noindent
23710
23718
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23760,15 +23768,17 @@ \subsection{Types Bounded by Types}
23760
23768
\LMLabel{typesBoundedByTypes}
23761
23769
23762
23770
\LMHash{}%
23763
- For a given type $T_0$, we introduce the notion of a
23764
- \IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
23765
- $T_0$ itself is $T_0$ bounded;
23766
- if $B$ is $T_0$ bounded and
23771
+ For a given type $T$, we introduce the notion of a
23772
+ % `T bounded` at the end should have been `$T$ bounded`, but makeindex
23773
+ % seems to be unable to allow math mode in that position.
23774
+ \IndexCustom{$T$ bounded type}{type!T bounded}:
23775
+ $T$ itself is $T$ bounded;
23776
+ if $B$ is $T$ bounded and
23767
23777
$X$ is a type variable with bound $B$
23768
- then $X$ is $T_0 $ bounded;
23769
- finally, if $B$ is $T_0 $ bounded and
23778
+ then $X$ is $T $ bounded;
23779
+ finally, if $B$ is $T $ bounded and
23770
23780
$X$ is a type variable
23771
- then $X \& B$ is $T_0 $ bounded.
23781
+ then $X \& B$ is $T $ bounded.
23772
23782
23773
23783
\LMHash{}%
23774
23784
In particular, a
@@ -23782,11 +23792,11 @@ \subsection{Types Bounded by Types}
23782
23792
\LMHash{}%
23783
23793
A
23784
23794
\IndexCustom{function-type bounded type}{type!function-type bounded}
23785
- is a type $T $ which is $T_0 $ bounded where $T_0 $ is a function type
23795
+ is a type $S $ which is $T $ bounded where $T $ is a function type
23786
23796
(\ref{functionTypes}).
23787
- A function-type bounded type $T $ has an
23797
+ A function-type bounded type $S $ has an
23788
23798
\Index{associated function type}
23789
- which is the unique function type $T_0 $ such that $T $ is $T_0 $ bounded.
23799
+ which is the unique function type $T $ such that $S $ is $T $ bounded.
23790
23800
23791
23801
23792
23802
\subsection{Class Building Types}
@@ -23847,7 +23857,7 @@ \subsection{Interface Types}
23847
23857
are interface types,
23848
23858
and so are
23849
23859
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23850
- \code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
23860
+ \code{List<$T$>}, \code{Map<$S$,\,\,$T$> }, and \code{Set<$T$>},
23851
23861
for any $S$ and $T$.%
23852
23862
}
23853
23863
@@ -23973,8 +23983,13 @@ \subsection{Type Null}
23973
23983
\code{Null} is a subtype of all types of the form \code{$T$?},
23974
23984
and of all types $S$ such that \futureOrBase{S} is
23975
23985
a top type or a type of the form \code{$T$?}.
23976
- The only non-trivial subtypes of \code{Null} are
23977
- \code{Never} and subtypes of \code{Never}
23986
+ The only subtypes of \code{Null} are
23987
+ other types that contain the null object and no other objects,
23988
+ e.g., \code{Null?},
23989
+ the empty type,
23990
+ i.e., \code{Never} and subtypes of \code{Never},
23991
+ and types that could be either,
23992
+ e.g., a type variable with bound \code{Null}
23978
23993
(\ref{subtypeRules}).%
23979
23994
}
23980
23995
@@ -24500,22 +24515,10 @@ \subsection{Type Void}
24500
24515
\commentary{%
24501
24516
The type \VOID{} is a top type
24502
24517
(\ref{superBoundedTypes}),
24503
- so \VOID{} and \code{Object} are subtypes of each other
24518
+ so \VOID{} and \code{Object? } are subtypes of each other
24504
24519
(\ref{subtypes}),
24505
24520
which also implies that any object can be
24506
- the value of an expression of type \VOID.
24507
- %
24508
- Consequently, any instance of type \code{Type} which reifies the type \VOID{}
24509
- must compare equal (according to the \lit{==} operator \ref{equality})
24510
- to any instance of \code{Type} which reifies the type \code{Object}
24511
- (\ref{dynamicTypeSystem}).
24512
- It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
24513
- the \TRUE{} object.
24514
- In fact, it is not recommended that implementations strive to achieve this,
24515
- because it may be more important to ensure that diagnostic messages
24516
- (including stack traces and dynamic error messages)
24517
- preserve enough information to use the word `void' when referring to types
24518
- which are specified as such in source code.%
24521
+ the value of an expression of type \VOID.%
24519
24522
}
24520
24523
24521
24524
\LMHash{}%
@@ -24653,7 +24656,7 @@ \subsection{Type Void}
24653
24656
}
24654
24657
24655
24658
\begin{dartCode}
24656
- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
24659
+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
24657
24660
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
24658
24661
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
24659
24662
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -24962,9 +24965,11 @@ \subsection{Definite Assignment}
24962
24965
(\commentary{%
24963
24966
e.g., as an expression, or as the left hand side of an assignment%
24964
24967
}),
24965
- the variable has a status as being
24966
- \IndexCustom{definitely assigned}{local variable!definitely assigned} or
24967
- \IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
24968
+ the variable can be
24969
+ \IndexCustom{definitely assigned}{local variable!definitely assigned},
24970
+ and it can be
24971
+ \IndexCustom{definitely unassigned}{local variable!definitely unassigned},
24972
+ and it can be neither.
24968
24973
24969
24974
\commentary{%
24970
24975
The precise flow analysis which determines this status at each location
@@ -25217,15 +25222,16 @@ \subsection{Type Promotion}
25217
25222
25218
25223
%% TODO(eernst), for review: The null safety spec says that `T?` is
25219
25224
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25220
- %% `X & int`. So I've specified the latter. This is also more consistent
25221
- %% with the approach used with `==`.
25225
+ %% `X & int`. So we may be able to specify something which will yield
25226
+ %% slightly more precise types, and which is more precisely the implemented
25227
+ %% behavior.
25222
25228
\LMHash{}%
25223
25229
A check of the form \code{$v$\,\,!=\,\,\NULL},
25224
25230
\code{\NULL\,\,!=\,\,$v$},
25225
25231
or \code{$v$\,\,\IS\,\,$T$}
25226
- where $v$ has type $T$ at $\ell$
25232
+ where $v$ has static type $T? $ at $\ell$
25227
25233
promotes the type of $v$
25228
- to \NonNullType{ $T$} in the \TRUE{} continuation,
25234
+ to $T$ in the \TRUE{} continuation,
25229
25235
and to \code{Null} in the \FALSE{} continuation.
25230
25236
25231
25237
\commentary{%
0 commit comments