I've been playing with the cake pattern and there's something I don't fully understand.
Given the following common code:
trait AServiceComponent {
this: ARepositoryComponent =>
}
trait ARepositoryComponent {}
the following way of mixing them works
trait Controller {
this: AServiceComponent =>
}
object Controller extends
Controller with
AServiceComponent with
ARepositoryComponent
But the following does not
trait Controller extends AServiceComponent {}
object Controller extends
Controller with
ARepositoryComponent
with error:
illegal inheritance; self-type Controller does not conform to AServiceComponent's selftype AServiceComponent with ARepositoryComponent
Shouldn't we be able to "push" dependencies up in the hierarchy if we know that they will be common for all subclasses?
Shouldn't the compiler allow for Controller
to have dependencies, as long as it's not instantiated without resolving them?