For example
object TimeHelpers {
def seconds(in: Long): Long = in * 1000L
}
import TimeHelpers._
class Base {
seconds(1000L)
}
// separate file
class Base2 extends Base {
// does not compile
//seconds(1000L)
}
Do I have to manually import for Base2 or is there a way to automatically do this?
There’s no such mechanism, sorry.
One trick, though, is to use trait inheritance rather than imports. This can be a useful way of grouping what would otherwise be multiple imports. For example,
Another possibility is to have
BaseinheritHelpers1 with Helpers2, but then you’d probably want the methods to beprotected.