Error if existing file conflicts with package dir (fixes SI-5717)

If there's an existing file foo when emitting a class file for foo.Bar,
then emit an error at foo.Bar, similar to what javac does.

The error message looks something like:

foo.scala:4: error: error writing object Foo: ./mypkg/Foo.class: ./mypkg is not a directory

This is a non-destructive version of
https://github.com/scala/scala/pull/1746