How to get list of traits that were mixed in the specified class?
问题 And more specific example: abstract trait A trait B extends A trait C extends A How to check what traits that extend trait A (it can be from 0 to many) were mixed in specified class? 回答1: How about a hybrid of the other answers abstract trait A //interested in this one trait B extends A //and this one trait C extends A //this one too trait D //don't care about this one though val x = new A with B with D x.getClass.getInterfaces.filter(classOf[A].isAssignableFrom(_)) returns Array[java.lang