@@ -20689,9 +20689,6 @@ \subsection{Subtypes}
20689
20689
\newcommand{\SrnRightTop}{2}
20690
20690
\newcommand{\SrnLeftTop}{3}
20691
20691
\newcommand{\SrnBottom}{4}
20692
- %\newcommand{\SrnRightObjectOne}{} Redundant
20693
- %\newcommand{\SrnRightObjectTwo}{} Redundant
20694
- %\newcommand{\SrnRightObjectThree}{} Redundant
20695
20692
\newcommand{\SrnRightObjectFour}{5}
20696
20693
\newcommand{\SrnNullOne}{6}
20697
20694
\newcommand{\SrnNullTwo}{7}
@@ -21302,7 +21299,8 @@ \subsection{Type Nullability}
21302
21299
Nullable types are types which are
21303
21300
definitively known to include the null object,
21304
21301
regardless of the value of any type variables.
21305
- This is equivalent to the syntactic criterion that $T$ is any of:
21302
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21303
+ then this is equivalent to the syntactic criterion that $T'$ is any of:
21306
21304
21307
21305
\begin{itemize}[itemsep=-0.5ex]
21308
21306
\item \VOID.
@@ -21324,7 +21322,8 @@ \subsection{Type Nullability}
21324
21322
Non-nullable types are types which are definitively known to
21325
21323
\emph{not} include the null object,
21326
21324
regardless of the value of any type variables.
21327
- This is equivalent to the syntactic criterion that $T$ is any of:
21325
+ If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21326
+ then this is equivalent to the syntactic criterion that $T$ is any of:
21328
21327
21329
21328
\begin{itemize}[itemsep=-0.5ex]
21330
21329
\item \code{Never}.
@@ -21691,21 +21690,23 @@ \subsection{Type Normalization}
21691
21690
21692
21691
\noindent
21693
21692
then $T_r$ is
21694
- \FunctionTypePositional{R_0 }{ }{X}{B}{s}{R }{n}{k}
21693
+ \FunctionTypePositional{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{k}
21695
21694
21696
21695
\noindent
21697
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21696
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21697
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
21698
21698
\item If $T_u$ is of the form
21699
21699
\FunctionTypeNamedStd{T_0}
21700
21700
21701
21701
\noindent
21702
21702
where $r_j$ is either \REQUIRED{} or empty
21703
21703
then $T_r$ is
21704
21704
\noindent
21705
- \FunctionTypeNamed{R_0 }{ }{X}{B}{s}{R }{n}{x}{k}{r }
21705
+ \FunctionTypeNamed{T'\!_0 }{ }{X}{B'\! }{s}{T'\! }{n}{x}{k}
21706
21706
21707
21707
\noindent
21708
- where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21708
+ where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21709
+ and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
21709
21710
\end{itemize}
21710
21711
21711
21712
\commentary{%
@@ -22043,8 +22044,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22043
22044
which is defined as follows.
22044
22045
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
22045
22046
with declared type $T_1$ respectively $T_2$,
22046
- such that both are positional or both are named ,
22047
- with the same name \DefineSymbol{n}.
22047
+ such that both are positional,
22048
+ or both are named and have the same name \DefineSymbol{n}.
22048
22049
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
22049
22050
is the formal parameter declaration $P$,
22050
22051
with the following proporties:
@@ -22063,7 +22064,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22063
22064
}
22064
22065
\item
22065
22066
$P$ is named if $P_1$ and $P_2$ are named.
22066
- In this case, the name of $P$ is $n$.
22067
+ In this case, the name of $P$ is $n$
22068
+ (\commentary{which is also the name of $P_1$ and $P_2$}).
22067
22069
$P$ is marked with the modifier \REQUIRED{}
22068
22070
if both $P_1$ and $P_2$ have this modifier
22069
22071
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -22242,22 +22244,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22242
22244
22243
22245
\noindent
22244
22246
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
22245
- \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\ ,$P_{1k}$)}
22247
+ \EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\ ,$P_{1k}$] )}
22246
22248
22247
22249
\noindent
22248
22250
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
22249
- \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\ ,$P_{2l}$)}
22251
+ \EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\ ,$P_{2l}$] )}
22250
22252
22251
22253
\noindent
22252
22254
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
22253
- and both have the same number of required positional parameters.
22255
+ and both $U_1$ or $U_2$ have
22256
+ the same number of required positional parameters.
22257
+ In the case where $U_1$ or $U_2$ has no optional positional parameters,
22258
+ the brackets are omitted.
22254
22259
Let $q$ be $\metavar{min}(k, l)$,
22255
22260
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
22256
- let $B_{3i}$ be $B_{1i}$, and
22261
+ let $B_{3i}$ be $B_{1i}$, and finally
22257
22262
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
22258
- Then \DefEquals {\UpperBoundType{$U_1$}{$U_2$}}{%
22263
+ Then \DefEqualsNewline {\UpperBoundType{$U_1$}{$U_2$}}{%
22259
22264
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
22260
- \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\ ,$P_{3q}$)}}.
22265
+ \EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\ ,$P_{3q}$] )}}.
22261
22266
22262
22267
\commentary{%
22263
22268
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -22315,8 +22320,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
22315
22320
%%
22316
22321
%% TODO(eernst), for review: Why do we not have a rule for
22317
22322
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
22318
- %% = T3 Function(R1..Rk), where the left operand has at least k parameters,
22319
- %% plus the converse?
22323
+ %% = T3 Function(R1..Rk), where the left operand has at least k parameters
22324
+ %% and every named parameter of the right operand is optional (plus the
22325
+ %% same rule with operands swapped)?
22326
+ %% Motivation: Some expressions of type `Function` would then have a more
22327
+ %% precise type, and programs would be safer (a tiny bit, at least).
22320
22328
%%
22321
22329
\item
22322
22330
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -22679,7 +22687,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
22679
22687
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
22680
22688
for any natural number $n$.
22681
22689
Let $q$ be the largest number such that $M_q$ has cardinality one.
22682
- Such a number must exist because $M_0$ is $\{\code{Object? }\}$.
22690
+ Such a number must exist because $M_0$ is $\{\code{Object}\}$.
22683
22691
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
22684
22692
22685
22693
@@ -22912,7 +22920,7 @@ \subsection{Least and Greatest Closure of Types}
22912
22920
the least closure of $S$ with respect to $L$ is
22913
22921
22914
22922
\noindent
22915
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22923
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
22916
22924
22917
22925
\noindent
22918
22926
where
@@ -22927,7 +22935,7 @@ \subsection{Least and Greatest Closure of Types}
22927
22935
the greatest closure of $S$ with respect to $L$ is
22928
22936
22929
22937
\noindent
22930
- \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22938
+ \FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
22931
22939
22932
22940
\noindent
22933
22941
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -22983,15 +22991,17 @@ \subsection{Types Bounded by Types}
22983
22991
\LMLabel{typesBoundedByTypes}
22984
22992
22985
22993
\LMHash{}%
22986
- For a given type $T_0$, we introduce the notion of a
22987
- \IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
22988
- $T_0$ itself is $T_0$ bounded;
22989
- if $B$ is $T_0$ bounded and
22994
+ For a given type $T$, we introduce the notion of a
22995
+ % `T bounded` at the end should have been `$T$ bounded`, but makeindex
22996
+ % seems to be unable to allow math mode in that position.
22997
+ \IndexCustom{$T$ bounded type}{type!T bounded}:
22998
+ $T$ itself is $T$ bounded;
22999
+ if $B$ is $T$ bounded and
22990
23000
$X$ is a type variable with bound $B$
22991
- then $X$ is $T_0 $ bounded;
22992
- finally, if $B$ is $T_0 $ bounded and
23001
+ then $X$ is $T $ bounded;
23002
+ finally, if $B$ is $T $ bounded and
22993
23003
$X$ is a type variable
22994
- then $X \& B$ is $T_0 $ bounded.
23004
+ then $X \& B$ is $T $ bounded.
22995
23005
22996
23006
\LMHash{}%
22997
23007
In particular, a
@@ -23005,11 +23015,11 @@ \subsection{Types Bounded by Types}
23005
23015
\LMHash{}%
23006
23016
A
23007
23017
\IndexCustom{function-type bounded type}{type!function-type bounded}
23008
- is a type $T $ which is $T_0 $ bounded where $T_0 $ is a function type
23018
+ is a type $S $ which is $T $ bounded where $T $ is a function type
23009
23019
(\ref{functionTypes}).
23010
- A function-type bounded type $T $ has an
23020
+ A function-type bounded type $S $ has an
23011
23021
\Index{associated function type}
23012
- which is the unique function type $T_0 $ such that $T $ is $T_0 $ bounded.
23022
+ which is the unique function type $T $ such that $S $ is $T $ bounded.
23013
23023
23014
23024
23015
23025
\subsection{Class Building Types}
@@ -23070,7 +23080,7 @@ \subsection{Interface Types}
23070
23080
are interface types,
23071
23081
and so are
23072
23082
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23073
- \code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
23083
+ \code{List<$T$>}, \code{Map<$S$,\,\,$T$> }, and \code{Set<$T$>},
23074
23084
for any $S$ and $T$.%
23075
23085
}
23076
23086
@@ -23196,8 +23206,13 @@ \subsection{Type Null}
23196
23206
\code{Null} is a subtype of all types of the form \code{$T$?},
23197
23207
and of all types $S$ such that \futureOrBase{S} is
23198
23208
a top type or a type of the form \code{$T$?}.
23199
- The only non-trivial subtypes of \code{Null} are
23200
- \code{Never} and subtypes of \code{Never}
23209
+ The only subtypes of \code{Null} are
23210
+ other types that contain the null object and no other objects,
23211
+ e.g., \code{Null?},
23212
+ the empty type,
23213
+ i.e., \code{Never} and subtypes of \code{Never},
23214
+ and types that could be either,
23215
+ e.g., a type variable with bound \code{Null}
23201
23216
(\ref{subtypeRules}).%
23202
23217
}
23203
23218
@@ -23723,22 +23738,10 @@ \subsection{Type Void}
23723
23738
\commentary{%
23724
23739
The type \VOID{} is a top type
23725
23740
(\ref{superBoundedTypes}),
23726
- so \VOID{} and \code{Object} are subtypes of each other
23741
+ so \VOID{} and \code{Object? } are subtypes of each other
23727
23742
(\ref{subtypes}),
23728
23743
which also implies that any object can be
23729
- the value of an expression of type \VOID.
23730
- %
23731
- Consequently, any instance of type \code{Type} which reifies the type \VOID{}
23732
- must compare equal (according to the \lit{==} operator \ref{equality})
23733
- to any instance of \code{Type} which reifies the type \code{Object}
23734
- (\ref{dynamicTypeSystem}).
23735
- It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
23736
- the \TRUE{} object.
23737
- In fact, it is not recommended that implementations strive to achieve this,
23738
- because it may be more important to ensure that diagnostic messages
23739
- (including stack traces and dynamic error messages)
23740
- preserve enough information to use the word `void' when referring to types
23741
- which are specified as such in source code.%
23744
+ the value of an expression of type \VOID.%
23742
23745
}
23743
23746
23744
23747
\LMHash{}%
@@ -23876,7 +23879,7 @@ \subsection{Type Void}
23876
23879
}
23877
23880
23878
23881
\begin{dartCode}
23879
- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
23882
+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
23880
23883
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
23881
23884
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
23882
23885
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -24185,9 +24188,11 @@ \subsection{Definite Assignment}
24185
24188
(\commentary{%
24186
24189
e.g., as an expression, or as the left hand side of an assignment%
24187
24190
}),
24188
- the variable has a status as being
24189
- \IndexCustom{definitely assigned}{local variable!definitely assigned} or
24190
- \IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
24191
+ the variable can be
24192
+ \IndexCustom{definitely assigned}{local variable!definitely assigned},
24193
+ and it can be
24194
+ \IndexCustom{definitely unassigned}{local variable!definitely unassigned},
24195
+ and it can be neither.
24191
24196
24192
24197
\commentary{%
24193
24198
The precise flow analysis which determines this status at each location
@@ -24440,15 +24445,16 @@ \subsection{Type Promotion}
24440
24445
24441
24446
%% TODO(eernst), for review: The null safety spec says that `T?` is
24442
24447
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
24443
- %% `X & int`. So I've specified the latter. This is also more consistent
24444
- %% with the approach used with `==`.
24448
+ %% `X & int`. So we may be able to specify something which will yield
24449
+ %% slightly more precise types, and which is more precisely the implemented
24450
+ %% behavior.
24445
24451
\LMHash{}%
24446
24452
A check of the form \code{$v$\,\,!=\,\,\NULL},
24447
24453
\code{\NULL\,\,!=\,\,$v$},
24448
24454
or \code{$v$\,\,\IS\,\,$T$}
24449
- where $v$ has type $T$ at $\ell$
24455
+ where $v$ has static type $T? $ at $\ell$
24450
24456
promotes the type of $v$
24451
- to \NonNullType{ $T$} in the \TRUE{} continuation,
24457
+ to $T$ in the \TRUE{} continuation,
24452
24458
and to \code{Null} in the \FALSE{} continuation.
24453
24459
24454
24460
\commentary{%
0 commit comments