Scala 3 中的宏注解

Macro Annotations in Scala 3

以下引用Macros: the Plan for Scala 3 3年多前的一句话:

For instance, one will be able to define a macro annotation @json that adds a JSON serializer to a type.

任何想法how/if这在 Scala 3 中实际上是可能的吗?

更一般地说,Scala 3 中有什么可以提供“宏注释”功能的吗? 以下引自Macro Annotations - Scala 2.13:

Unlike in the previous versions of macro paradise, macro annotations in 2.0 are done right in the sense that they: 1) apply not just to classes and objects, but to arbitrary definitions, 2) allow expansions of classes to modify or even create companion objects

截至 2021 年 6 月,Scala 3 不支持宏注释,文档中也未提及它们。

现在,如果您想生成方法,类 或对象,我相信您必须使用 scalameta 或编写编译器插件。

显然,这种情况在未来可能会改变,宏注解一开始也不是Scala 2的一部分。