It was called auto-tupling.
The compiler will try to fill in additional arguments by wrapping them all in a tuple.
Wrapped(1,2,3,4)
automatically turns into
Wrapped((1,2,3,4))
By the way, this is an annoying and amazing feature, and I really hope that this will end up being obsolete. Meanwhile, you have two compiler options available:
-Ywarn-adapted-args , which warns in case of auto-tuning-Yno-adapted-args , which gives an error under the same circumstances
Example with a warning:
scala -Ywarn-adapted-args scala> case class Foo[A](a: A) scala> Foo(1, 2) <console>:10: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. signature: Foo.apply[A](a: A): Foo[A] given arguments: 1, 2 after adaptation: Foo((1, 2): (Int, Int)) Foo(1, 2) ^ res1: Foo[(Int, Int)] = Foo((1,2))
Error example:
scala -Yno-adapted-args scala> case class Foo[A](a: A) defined class Foo scala> Foo(1, 2) <console>:10: warning: No automatic adaptation here: use explicit parentheses. signature: Foo.apply[A](a: A): Foo[A] given arguments: 1, 2 after adaptation: Foo((1, 2): (Int, Int)) Foo(1, 2) ^ <console>:10: error: too many arguments for method apply: (a: (Int, Int))Foo[(Int, Int)] in object Foo Foo(1, 2) ^
Gabriele petronella
source share