1

I would like to know how I can list every objects that extend a given trait.

For instance I have :

trait MyTrait

object MyTObjA extends MyTrait

object MyTObjB extends MyTrait

and what I want to achieve is something like that without having to list all these objects myself :

val myTraitObjects: Seq[Type] = Seq(typeOf[MyTObjA], typeOf[MyTObjB])
Roch
  • 21,741
  • 29
  • 77
  • 120
  • 1
    Note: If your trait is not sealed, it is only possible to find all of its implementations by typechecking the entire classpath. – kiritsuku Nov 25 '14 at 16:10

0 Answers0