The presentation compiler of your IDE appears to be more confused than it should be.
If you try the code in a REPL it will work. Unfortunately, though, the resolution of set
depends on the definition order.
Here's a scala REPL session demonstrating this fact:
scala> :paste
// Entering paste mode (ctrl-D to finish)
def set(value: Any) : Unit = {
val (a, b, c, d) = value.asInstanceOf[(Int, Int, Int, Int)]
set(a, b, c, d)
}
def set(aValue: Int, bValue: Int, cValue: Int, dValue: Int) = println("ok")
// Exiting paste mode, now interpreting.
set: (value: Any)Unit <and> (aValue: Int, bValue: Int, cValue: Int, dValue: Int)Unit
set: (value: Any)Unit <and> (aValue: Int, bValue: Int, cValue: Int, dValue: Int)Unit
scala> (set _).tupled((1, 2, 3, 4))
ok
scala> :paste
// Entering paste mode (ctrl-D to finish)
def set(value: Any) : Unit = {
val (a, b, c, d) = value.asInstanceOf[(Int, Int, Int, Int)]
set(a, b, c, d)
}
// Exiting paste mode, now interpreting.
set: (value: Any)Unit
scala> (set _).tupled((1, 2, 3, 4))
<console>:9: error: value tupled is not a member of Any => Unit
(set _).tupled((1, 2, 3, 4))
Generally speaking, the confusion comes from overloading mixed with partially applied function.
Overloaded methods are disambiguated using their parameter list, but, when you partially apply them, you're throwing this information away, and you can only hope that the compiler will see the "right" set
before the wrong one.
However, I doubt this is specified anywhere, so you're basically binding the semantic of your program to a compiler implementation detail: bad idea, isn't it?
As Travis Brown already suggested in the comments, why don't you just avoid overloading and make your life (and the compiler) happier?