Jean-Philippe Pellet
Jean-Philippe Pellet

Reputation: 60006

Can I run a Scala macro automatically when I extend a given type?

Currently, I use a Scala macro annotation to automatically generate some code into a Scala object. It works like this:

@constants
object PopoverCommands extends Constants { … }

I find it somewhat redundant to have to extend Constants and to annotate PopoverCommands with @constants. I know the macro annotation can insert the extends Constants part. My question goes the other way round: is there any way I can run some macro code (e.g. simulate the presence of @constants) by simply extending a type (here, Constants)?

Upvotes: 1

Views: 54

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170899

No, this isn't currently possible.

Upvotes: 1

Related Questions