Some questions were asked that are somewhat related to this problem, but they do not seem to be true.
I use the Cake pattern to shift the Storage system into production code and the stub storage system for testing. This is cool, but there is a class created in the original class, which should also have a mixed stub storage system. Since it is hidden inside the implementation, I do not have access to it.
Everything looks like this:
class Main { this: Storage =>
...
val used = Used(...)
...
}
class Used { this: Storage =>
...
}
When testing "Used," I just new Used with StubStorageleave. I did the same with Main, but before that, he used Used. Now that I am Maincreating a naive instance Used, I have this problem.
:
class Main[T <: Storage] { this: T =>
...
val used = Used[T](...)
...
}
class Used[T <: Storage] { this: T =>
...
}
object Used {
def apply[T <: Storage](...) = new Used(...) with T
}
, , , T. ? , , , OO , - .
Factory, mixins.
: , .:) , , :
trait UsedProvider {
def createUsed = Used.apply _
}
class Main { this: Storage with UsedProvider =>
val used = createUsed(...)
}
: new Main with StubStorage with StubUsedProvider.