scala coalesces multiple function call parameters into a Tuple — can this be disabled?

后端 未结 6 1685
闹比i
闹比i 2020-12-10 06:34

This is a troublesome violation of type safety in my project, so I\'m looking for a way to disable it. It seems that if a function takes an AnyRef (or a java.lang.Object), y

6条回答
  •  情深已故
    2020-12-10 07:04

    No implicits or Predef at play here at all -- just good old fashioned compiler magic. You can find it in the type checker. I can't locate it in the spec right now.

    If you're motivated enough, you could add a -X option to the compiler prevent this.

    Alternatively, you could avoid writing arity-1 methods that accept a supertype of TupleN.

提交回复
热议问题