|
The desugaring of right associative calls happens in the parser. This
eagerly evaluates the arguments (to preserve left-to-right evaluation
order the arguments are evaluated before the qualifier).
This is pretty surprising if the method being called has a by-name
parameter in the first parameter section.
This commit adds a warning under -Xlint when defining such a method.
The relevent spec snippets:
> SLS 4.6.1 says that call-by-name argument "is not evaluated at the point of function application, but instead is evaluated at each use within the function".
>
> But 6.12.3 offers:
> "If op is right- associative, the same operation is interpreted as { val x=e1; e2.op(x ) }, where x is a fresh name."
|