Move in shared implementation between dotty and scalac.

Those methods ended having same implementation in dotty and scalac.
And even more they are implemented in terms of what is already part of exposed abstractions.
Providing default implementations, that can be overridden in backends if ever needed.