I received damage from a production error in which I passed an unclean 0-ary function to a class that mistakenly expected a simple result type.
def impureFunc(): Future[Any] = ??? case class MyService(impureDependency: Future[Any] )
In fact, this made MyService immediately call impureFunc and cache the first result for the program's lifetime, which led to a very subtle error.
Typically, the type system prevents such errors, but because of the possibility of calling 0-ary functions without a list of arguments, the compiler accepted this program.
Obviously, this is a βfunctionβ of Scala, designed to make the code more understandable, but it was a bad way. Is there a way to make this a compiler warning or an enumeration error? In other words, reject the type "Empty application" implicit conversion method ?
acjay source share