我可以在扩展给定类型时自动 运行 Scala 宏吗?

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

目前,我使用 Scala 宏注释自动将一些代码生成到 Scala 对象中。它是这样工作的:

@constants
object PopoverCommands extends Constants { … }

我发现必须扩展 Constants 并用 @constants 注释 PopoverCommands 有点多余。我知道宏注释可以插入 extends Constants 部分。我的问题反过来:有没有什么办法可以通过简单地扩展类型(这里是 Constants)来 运行 一些宏代码(例如模拟 @constants 的存在)?

不,这目前不可能。