scala/scala — pull request #2852 by retronym (2013-08-19 08:37:19+00:00)
Title: SI-1980 A lint warning for by-name parameters in right assoc methods

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."

Review by @JamesIry