I'm writing a Scala macro annotation @model
used to annotate my case classes and which automatically adds some metadata to the companion object of the annotated class, based on the fields of the annotated case class.
I would like to obtain more information about the type of the case class's parameters, especially, check if they implement a certain trait. I thought obtaining a WeakTypeTag
for them was the way to go, but I can't seem to get one the way they are obtained in def macros.
Concretely: I want to be able to tell in this case, from the macro implementation of @model
, that the address
field of the User
class has a type which extends ModelObject
, and that date
doesn't. Can I do that?
trait ModelObject
@model case case Address(street: String, city: String) extends ModelObject
@model case class User(name: String, since: Date, address: Address) extends ModelObject