When I write for example a class A that extends a trait B and then use IDEA's Ctrl+Enter / "Implement Methods..." operation, the default method implementations will look like this:
def foo = null
Naturally, the IDE has no idea what I'm trying to accomplish and cannot return a sensible value. However, the intention I have as a developer when creating the method is to get a stub that either lets me quickly start implementing the method (in which case I don't care what its body is) or that lets me continue writing valid code in another class or function. In the latter case, I now have a method that will compile, will return a value, this value will potentially get passed around my program for a while and then cause a NullPointerException somewhere else. Now I have the scenario where the error (NPE) is quite far removed from the cause (a default method implementation generated by the IDE that I did not yet get around to adapting).
What one would rather have, I guess, is that invoking the method fails immediately (rather than causing an error elsewhere, potentially much later).
So for reasons of safety, it would seem preferable that IDEA by default generate the method as follows:
def foo = throw new UnsupportedOperationException
Since both 'null' and the exception may occasionally cause the compiler to complain about the type of the returned value not being what it expects, one might also expand this further (although this seems much less important) to:
def foo : Foo = throw new UnsupportedOperationException
What are your views on this? Does this make sense?