So, as written, I can't get as far as defining the case class FooLookup, because I get an error "not found: value Foo" in defining the trait HasFoos.
To get HasFoos to compile as written, you must at some point have defined an object Foo, as well as the trait, no? If I do that, HasFoos will compile. But then "Foo.type" is the type of the singleton object Foo, not the type of companion objects of classes that extend the trait Foo.
A.type would be the type of object A. It would not be the type of things implementing a companion trait A, if one were defined.
I don't think that there is a type abstraction for what you want, something that automatically captures the description "Companion object of a type that implements Foo." I think you'll have to define such a type yourself:
trait FooCompanion
trait Foo
case class A() extends Foo
object A extends FooCompanion
case class B() extends Foo
object B extends FooCompanion
case class C() extends Foo
object C extends FooCompanion
trait HasFoos {
def allFoos: List[FooCompanion]
}
case class FooLookup() extends HasFoos {
def allFoos = List(A,B,C)
}
Good luck!