|
36 | 36 | % that `o` is desugared as `o.call` when the context type is a function type.
|
37 | 37 | % - Clarify the treatment of `covariant` parameters in the interface of a class
|
38 | 38 | % that inherits an implementation where those parameters are not covariant.
|
| 39 | +% - Change the specified evaluation order for class instance methods such that |
| 40 | +% `x.m(a)` will evaluate `a` before calling `x.m`, which is observable in |
| 41 | +% the case where `x.m` is a getter with side effects. |
39 | 42 | %
|
40 | 43 | % 2.14
|
41 | 44 | % - Add constraint on type of parameter which is covariant-by-declaration in
|
@@ -13703,7 +13706,7 @@ \subsubsection{Ordinary Invocation}
|
13703 | 13706 | Otherwise, let $d$ be the result of getter lookup
|
13704 | 13707 | for $m$ in $T$ with respect to $L$,
|
13705 | 13708 | and let $F$ be the return type of $d$.
|
13706 |
| -(\commentary{ |
| 13709 | +(\commentary{% |
13707 | 13710 | Since \code{$T$.$m$} exists we cannot have a failure in both lookups.%
|
13708 | 13711 | })
|
13709 | 13712 | If the getter return type $F$ is an interface type
|
@@ -13787,12 +13790,34 @@ \subsubsection{Ordinary Invocation}
|
13787 | 13790 | $m$ in $o$ with respect to $L$.
|
13788 | 13791 |
|
13789 | 13792 | \LMHash{}%
|
13790 |
| -If the getter lookup succeeded then invoke the getter $o.m$ |
13791 |
| -and let $v_g$ be the returned object. |
13792 |
| -Then the value of $i$ is the value of |
| 13793 | +If the getter lookup succeeded then evaluate the actual argument list |
| 13794 | + |
| 13795 | +\noindent |
| 13796 | +\code{($a_1, \ldots,\ a_n,\ x_{n+1}$:\ $a_{n+1}, \ldots,\ x_{n+k}$:\ $a_{n+k}$)} |
13793 | 13797 |
|
13794 | 13798 | \noindent
|
13795 |
| -\code{$v_g$<$A_1, \ldots,\ A_r$>($a_1,\ \ldots,\ a_n,\ x_{n+1}$: $a_{n+1},\ \ldots,\ x_{n+k}$: $a_{n+k}$)}. |
| 13799 | +in textual order to a sequence of objects $o_1, \ldots,\ o_{n+k}$, |
| 13800 | +and let \List{v}{1}{n+k} be fresh variables |
| 13801 | +such that $v_j$ is bound to $o_j$ for each $j \in 1 .. n+k$. |
| 13802 | +Then invoke the getter $o.m$ and let $v_g$ be the returned object. |
| 13803 | +The value of $i$ is then the value of |
| 13804 | + |
| 13805 | +\noindent |
| 13806 | +\code{$v_g$<$A_1, \ldots,\ A_r$>($v_1,\ \ldots,\ v_n,\ x_{n+1}$:\ $v_{n+1},\ \ldots,\ x_{n+k}$:\ $v_{n+k}$)}. |
| 13807 | + |
| 13808 | +\rationale{% |
| 13809 | +Note that this evaluation order is inconsistent with the general rule that |
| 13810 | +expressions are evaluated left-to-right |
| 13811 | +(unless the expression has a non-trivial control flow, e.g., |
| 13812 | +\code{$e_1$\,?\,$e_2$\,:\,$e_3$}). |
| 13813 | +In particular all other function invocations use left-to-right evaluation, |
| 13814 | +including extension instance method invocations. |
| 13815 | +The reason for this inconsistency is mainly historical: |
| 13816 | +This evaluation order has been used for instance methods since the beginning of |
| 13817 | +the development of the language, |
| 13818 | +and it was not considered worthwhile to handle the breakage. |
| 13819 | +Another reason is that it allows for improved performance in some situations.% |
| 13820 | +} |
13796 | 13821 |
|
13797 | 13822 | \LMHash{}%
|
13798 | 13823 | If getter lookup has also failed,
|
|
0 commit comments