Reputation: 804
I have a Scala (2.10) def macro with argument x. It's body looks like this:
if (x.actualType =:= typeOf[generic.Type[String]]) {
// branch 1: do something with x
}
else {
// branch 2: do something else
}
The implementation of the generic.Type class itself is not accessible and its implementation cannot be modified. Now, I'd like this macro to call branch 1 not just for generic.Type[String] s, but for generic.Type[T] , where T is any type.
Is there a canonical way to achieve that? Or is the only option doing it manually using the AST?
Upvotes: 1
Views: 375
Reputation: 13048
Try x.actualType.typeSymbol == typeOf[generic.Type[_]].typeSymbol
Upvotes: 2