Autotupling is when
x.op(y, z) is taken as
Autountupling or multiarg infix is when
x op (y, z) is taken as
x.op(y, z) instead of
It is specified in 6.12.3:
The right-hand operand of a left-associative operator may consist of several arguments enclosed in parentheses.
Here is an example of why it can be confusing. (The warning is inadvertently emitted in 2.13.3 without the lint flag; the behavior in 2.13.4 is shown below. The warning in 2.13.3 can be silenced with
scala> val xs = collection.mutable.Map(1 -> 100) val xs: scala.collection.mutable.Map[Int,Int] = HashMap(1 -> 100) scala> xs += (2, 200) ^ error: type mismatch; found : Int(2) required: (Int, Int) ^ error: type mismatch; found : Int(200) required: (Int, Int) scala> :se -Xlint:multiarg-infix scala> xs += (2, 200) ^ error: type mismatch; found : Int(2) required: (Int, Int) ^ error: type mismatch; found : Int(200) required: (Int, Int) ^ warning: multiarg infix syntax looks like a tuple and will be deprecated scala> xs addOne (2, 200) val res2: xs.type = HashMap(1 -> 100, 2 -> 200)
The purpose of the lint was to highlight the wart, and also as a chance to anticipate a possible change in Scala 3.
The purpose of this topic is to share information and encourage further discussion, especially about DSLs that leverage the syntax. Since “lints are made to be broken,” the lint can be selectively enabled. The ongoing discussion on the moribund Dotty PR can continue here. The current state seems to be that there are differing opinions about the language feature, how to improve it, and whether to improve it, but that usability remains a priority.
See the scala-dev ticket.