I'm trying to do dependency injection using the cake pattern like so:
trait FooComponent {
val foo: Foo
trait Foo;
}
trait AlsoNeedsFoo {
this: FooComponent =>
}
trait RequiresFoo {
this: FooComponent =>
val a = new AlsoNeedsFoo with FooComponent{
val foo: this.type#Foo = RequiresFoo.this.foo
}
}
but the compiler complains that the RequiresFoo.this.type#Foo
doesn't conform to the expected type this.type#Foo
.
So the question: is it possible to create a AlsoNeedsFoo
object inside RequiresFoo
so that dependency injection works properly?
AlsoNeedsFoo
(insideRequiresFoo
). Is that correct? – Reprimand