jeudi 17 octobre 2019

How to know if type from typeSignature property refers to any of classes extending a certain class?

I have a following code, which goes through class properties

val members = typeOf[Product].members.filterNot(_.isMethod).foreach {
  field: Symbol => {
    val t = field.typeSignature
  }
}

also i have an abstract class A and classes B, C, D etc which extends it

How can i know in my loop through Product class properties if property has a type which extends A. It can be or types B, C, D and etc... or it can be Option[B], Option[C], Option[D] and etc... or List[B], List[C], List[D] and etc

I have tried inside foreach method

typeOf[A].contains(t)

but it always returns false

Thanks in advance





Aucun commentaire:

Enregistrer un commentaire