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

后端 未结 6 1688
闹比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:18

    What about something like this:

    object Qx2 {
        @deprecated def callingWithATupleProducesAWarning(a: Product) = 2
        def callingWithATupleProducesAWarning(a: Any) = 3
    }
    

    Tuples have the Product trait, so any call to callingWithATupleProducesAWarning that passes a tuple will produce a deprecation warning.

提交回复
热议问题