You can do the following:
class A extends B with C { super[B].foo() }
This will be compiled only if B implements foo . Use with caution, although it (potentially) introduces some unintuitive connection. Also, if A overrides foo , there will still be B foo .
One valid use case for IMHO is conflict resolution :
trait B { def foo() = println("B") } trait C { def foo() = println("C") } class A extends B with C { override def foo() = super[B].foo() }
If you want B declare foo , you can use a type:
class A extends B with C { (this:B).foo() }
This will compile only if B declares foo (but can be implemented in C or A ).
source share