Why does the Scala compiler disallow overloaded methods with default arguments?

后端 未结 7 1712
失恋的感觉
失恋的感觉 2020-11-29 19:26

While there might be valid cases where such method overloadings could become ambiguous, why does the compiler disallow code which is neither ambiguous at compile time nor at

相关标签:
7条回答
  • 2020-11-29 19:59

    It would be very hard to get a readable and precise spec for the interactions of overloading resolution with default arguments. Of course, for many individual cases, like the one presented here, it's easy to say what should happen. But that is not enough. We'd need a spec that decides all possible corner cases. Overloading resolution is already very hard to specify. Adding default arguments in the mix would make it harder still. That's why we have opted to separate the two.

    0 讨论(0)
提交回复
热议问题