There is a very handy <:<
operator to test if a type is a subtype of another:
def modelMembers = members.filter(_.typeSignature <:< typeOf[Model])
Note: this will only get you fields, not methods with Model
return type.
Example:
trait A
class B extends A
class C extends A
class X {
val hello: C = null
var world: B = null
}
scala> import reflect.runtime.universe._
import reflect.runtime.universe._
scala> typeOf[X].members.filter(_.typeSignature <:< typeOf[A])
res0: Iterable[Symbol] = SynchronizedOps(variable world, value hello)