42
42
% - Clarify the conflicts between extension members and `Object` instance
43
43
% members.
44
44
% - Correct <partDeclaration> to include metadata.
45
+ % - Clarify the section about assignable expressions.
45
46
%
46
47
% 2.14
47
48
% - Add constraint on type of parameter which is covariant-by-declaration in
@@ -5946,7 +5947,7 @@ \subsection{Explicit Invocation of an Instance Member of an Extension}
5946
5947
\IndexCustom{instantiated \ON{} type}{extension!instantiated \ON{} type}
5947
5948
of $a$ as $[T_1/X_1, \ldots, T_s/X_s]T$.
5948
5949
We define the
5949
- \IndexCustom{instantiation-to-bound \ON{} type}{
5950
+ \IndexCustom{instantiation-to-bound \ON{} type}{%
5950
5951
extension!instantiation-to-bound \ON{} type}
5951
5952
of $a$ as $[U_1/X_1, \ldots, U_s/X_s]T$,
5952
5953
where \List{U}{1}{s} is the result of instantiation to bound
@@ -6021,7 +6022,7 @@ \subsection{Explicit Invocation of an Instance Member of an Extension}
6021
6022
6022
6023
\LMHash{}%
6023
6024
The member signature $s_1$ is called the
6024
- \IndexCustom{invocation member signature}{
6025
+ \IndexCustom{invocation member signature}{%
6025
6026
extension!invocation member signature}
6026
6027
of $i$.
6027
6028
The static type of $i$ is the return type of
@@ -13371,7 +13372,7 @@ \subsection{Member Invocations}
13371
13372
expression $r$ is an expression of
13372
13373
one of the forms shown in Fig.~\ref{fig:memberInvocations}.
13373
13374
Each member invocation has a
13374
- \IndexCustom{corresponding member name}{
13375
+ \IndexCustom{corresponding member name}{%
13375
13376
member invocation!corresponding member name}
13376
13377
as shown in the figure.
13377
13378
@@ -13712,7 +13713,7 @@ \subsubsection{Ordinary Invocation}
13712
13713
Otherwise, let $d$ be the result of getter lookup
13713
13714
for $m$ in $T$ with respect to $L$,
13714
13715
and let $F$ be the return type of $d$.
13715
- (\commentary{
13716
+ (\commentary{%
13716
13717
Since \code{$T$.$m$} exists we cannot have a failure in both lookups.%
13717
13718
})
13718
13719
If the getter return type $F$ is an interface type
@@ -13736,7 +13737,7 @@ \subsubsection{Ordinary Invocation}
13736
13737
\LMHash{}%
13737
13738
It is a compile-time error to invoke an instance method on a type literal
13738
13739
that is immediately followed by the token `.' (a period).
13739
- \commentary{
13740
+ \commentary{%
13740
13741
For instance, \code{int.toString()} is an error.%
13741
13742
}
13742
13743
@@ -14009,7 +14010,7 @@ \subsubsection{Superinvocations}
14009
14010
14010
14011
\LMHash{}%
14011
14012
An
14012
- \IndexCustom{implicit \CALL{} superinvocation}{
14013
+ \IndexCustom{implicit \CALL{} superinvocation}{%
14013
14014
method superinvocation!implicit \CALL}
14014
14015
has the form
14015
14016
@@ -16245,18 +16246,27 @@ \subsection{Assignable Expressions}
16245
16246
\LMLabel{assignableExpressions}
16246
16247
16247
16248
\LMHash{}%
16248
- Assignable expressions are expressions
16249
+ \IndexCustom{ Assignable expressions}{assignable expression} are terms
16249
16250
that can appear on the left hand side of an assignment.
16250
- This section describes how to evaluate these expressions
16251
- when they do not constitute the complete left hand side of an assignment.
16251
+ This section describes how to evaluate subterms of these terms when needed.
16252
+ The semantics of an assignment as a whole is described elsewhere
16253
+ (\ref{assignment}).
16252
16254
16253
- \rationale{%
16254
- Of course, if assignable expressions
16255
- always appeared \emph{as} the left hand side,
16256
- one would have no need for their value,
16257
- and the rules for evaluating them would be unnecessary.
16258
- However, assignable expressions can be subexpressions of other expressions
16259
- and therefore must be evaluated.%
16255
+ \commentary{%
16256
+ The grammar of assignable expressions includes very general forms
16257
+ like an identifier \id{} or a qualified identifier \code{$\id_1$.$\id_2$}.
16258
+ Hence, an assignable expression can have many different meanings,
16259
+ depending on the binding of those identifiers in the context.
16260
+
16261
+ For example, the term \code{x.y.z} is an assignable expression.
16262
+ \code{x.y} may refer to a getter \code{y} on
16263
+ an object referenced by a variable \code{x},
16264
+ in which case \code{x.y} will be evaluated to an object
16265
+ before accessing the \code{z} member of that object.
16266
+ The term \code{x.y} could also denote a class \code{y} referenced through
16267
+ an import prefix \code{x},
16268
+ with \code{z} denoting a static variable of that class.
16269
+ In this case \code{x.y} will not be evaluated to a value.%
16260
16270
}
16261
16271
16262
16272
\begin{grammar}
@@ -16276,38 +16286,57 @@ \subsection{Assignable Expressions}
16276
16286
\end{grammar}
16277
16287
16278
16288
\LMHash{}%
16279
- An \Index{assignable expression} is either:
16280
- \begin{itemize}
16281
- \item An identifier.
16282
- \item An invocation (possibly conditional) of a getter (\ref{getters})
16283
- or list access operator on an expression $e$.
16284
- \item An invocation of a getter or list access operator on \SUPER.
16285
- \end{itemize}
16286
-
16287
- \LMHash{}%
16288
- An assignable expression of the form \id{} is evaluated as
16289
- an identifier expression (\ref{identifierReference}).
16290
-
16291
- %An assignable expression of the form \code{$e$.\id($a_1, \ldots,\ a_n$)}
16292
- % is evaluated as a method invocation (\ref{methodInvocation}).
16289
+ The section about assignments
16290
+ (\ref{assignment})
16291
+ specifies the static analysis and dynamic semantics of
16292
+ various forms of assignment.
16293
+ Each of those cases is applicable when the specified subterms satisfy
16294
+ the given side conditions
16295
+ (\commentary{%
16296
+ e.g., one case of the form \code{$e_1$.$v$\,\,??=\,\,$e_2$} requires $e_1$
16297
+ to be an expression, whereas \code{$C$.$v$\,\,??=\,\,$e$}
16298
+ requires $C$ to be a type literal%
16299
+ }).
16300
+ The cases requiring subterms to be expressions are considered least specific,
16301
+ that is, they are only used if no other case matches
16302
+ (\commentary{%
16303
+ so the case containing $C$ is used if the corresponding term is a type literal%
16304
+ }).
16293
16305
16294
- \LMHash{}%
16295
- An assignable expression of the form \code{$e$.\id} or \code{$e$?.\id}
16296
- is evaluated as a property extraction (\ref{propertyExtraction}).
16306
+ \commentary{%
16307
+ Syntactically, these expressions are not derived from \synt{expression},
16308
+ but they are derivable from \synt{expression}, e.g., because
16309
+ an \synt{assignableExpression} may contain a \synt{primary}
16310
+ which is derivable from \synt{expression}.
16311
+ We use the following rule to find such expressions:%
16312
+ }
16297
16313
16298
16314
\LMHash{}%
16299
- An assignable expression of the form \code{$e_1$[$e_2$]}
16300
- is evaluated as a method invocation of
16301
- the operator method \code{[]} on $e_1$ with argument $e_2$.
16315
+ \BlindDefineSymbol{e, t}%
16316
+ Let $e$ be an \synt{assignableExpression}.
16317
+ Assume that $t$ is a term such that $e$ can be derived from
16318
+ \syntax{$t$ <assignableSelector>}.
16319
+ In this case we say that $t$ is the
16320
+ \IndexCustom{receiver term}{assignable expression!receiver term}
16321
+ of $e$.
16322
+ When $t$ is an expression, we say that $t$ is the
16323
+ \IndexCustom{receiver expression}{assignable expression!receiver expression}
16324
+ of $e$.
16302
16325
16303
- \LMHash{}%
16304
- An assignable expression of the form \code{\SUPER.\id} is evaluated as
16305
- a property extraction.
16326
+ \commentary{%
16327
+ In short, we obtain $t$ by cutting off an assignable selector
16328
+ from the end of $e$.
16329
+ It is easy to see that only some \synt{assignableExpression}s
16330
+ have a receiver term.
16331
+ For instance, a plain \synt{identifier} does not.
16332
+ %
16333
+ }
16306
16334
16307
16335
\LMHash{}%
16308
- Evaluation of an assignable expression of the form \code{\SUPER{}[$e_2$]}
16309
- is equivalent to
16310
- evaluation of the method invocation \code{\SUPER.[]($e_2$)}.
16336
+ Let $e$ be an assignable expression.
16337
+ Assume that $e$ has a receiver expression $t$.
16338
+ Evaluation of $t$ proceeds in the same way as
16339
+ evaluation of any other expression.
16311
16340
16312
16341
16313
16342
\subsection{Lexical Lookup}
@@ -20331,13 +20360,13 @@ \subsection{Type Aliases}
20331
20360
it is a compile-time error if $T$ is not regular-bounded,
20332
20361
and it is a compile-time error if any type occurring in $T$ is not well-bounded.
20333
20362
20334
- \commentary{
20363
+ \commentary{%
20335
20364
This means that the bounds declared for
20336
20365
the formal type parameters of a generic type alias
20337
20366
must be such that when they are satisfied,
20338
20367
the bounds that pertain to the body are also satisfied,
20339
20368
and a type occurring as a subterm of the body can violate its bounds,
20340
- but only if it is a correct super-bounded type.
20369
+ but only if it is a correct super-bounded type.%
20341
20370
}
20342
20371
20343
20372
\LMHash{}%
@@ -20475,7 +20504,7 @@ \subsection{Type Aliases}
20475
20504
we say that the parameterized type $U$ of the form
20476
20505
\code{$F$<\List{U}{1}{s}>}
20477
20506
in a scope where $F$ resolves to $D$
20478
- \IndexCustom{alias expands in one step to}{
20507
+ \IndexCustom{alias expands in one step to}{%
20479
20508
type alias!alias expands in one step}
20480
20509
$[U_1/X_1, \ldots, U_s/X_s]T$.
20481
20510
@@ -20490,7 +20519,7 @@ \subsection{Type Aliases}
20490
20519
by its alias expansion in one step
20491
20520
(\commentary{including the non-generic case where there are no type arguments}).
20492
20521
When no further steps are possible we say that the resulting type is the
20493
- \IndexCustom{transitive alias expansion}{
20522
+ \IndexCustom{transitive alias expansion}{%
20494
20523
type alias!transitive alias expansion}
20495
20524
of $U$.
20496
20525
@@ -20762,7 +20791,7 @@ \subsection{Subtypes}
20762
20791
\begin{minipage}[c]{0.49\textwidth}
20763
20792
\RuleTwo{\SrnLeftFutureOr}{Left FutureOr}{S}{T}{%
20764
20793
\code{Future<$S$>}}{T}{\code{FutureOr<$S$>}}{T}
20765
- \RuleTwo{\SrnRightPromotedVariable}{Right Promoted Variable}{S}{X}{S}{T}{
20794
+ \RuleTwo{\SrnRightPromotedVariable}{Right Promoted Variable}{S}{X}{S}{T}{%
20766
20795
S}{X \& T}
20767
20796
\Rule{\SrnRightFutureOrB}{Right FutureOr B}{S}{T}{S}{\code{FutureOr<$T$>}}
20768
20797
\Rule{\SrnLeftVariableBound}{Left Variable Bound}{\Gamma(X)}{T}{X}{T}
@@ -20772,7 +20801,7 @@ \subsection{Subtypes}
20772
20801
\Rule{\SrnRightFutureOrA}{Right FutureOr A}{S}{\code{Future<$T$>}}{%
20773
20802
S}{\code{FutureOr<$T$>}}
20774
20803
\Rule{\SrnLeftPromotedVariable}{Left Promoted Variable B}{S}{T}{X \& S}{T}
20775
- \RuleRaw{\SrnRightFunction}{Right Function}{T\mbox{ is a function type}}{
20804
+ \RuleRaw{\SrnRightFunction}{Right Function}{T\mbox{ is a function type}}{%
20776
20805
T}{\FUNCTION}
20777
20806
\end{minipage}
20778
20807
%
@@ -20788,7 +20817,7 @@ \subsection{Subtypes}
20788
20817
\RawFunctionTypePositional{T_0}{X}{B}{s}{T}{n_2}{k_2}
20789
20818
\end{array}}
20790
20819
\ExtraVSP\ExtraVSP
20791
- \RuleRawRaw{\SrnNamedFunctionType}{Named Function Types}{
20820
+ \RuleRawRaw{\SrnNamedFunctionType}{Named Function Types}{%
20792
20821
\Gamma' = \Gamma\uplus\{X_i\mapsto{}B_i\,|\,1 \leq i \leq s\} &
20793
20822
\Subtype{\Gamma'}{S_0}{T_0} &
20794
20823
\forall j \in 1 .. n\!:\;\Subtype{\Gamma'}{T_j}{S_j} \\
0 commit comments