【发布时间】:2019-04-03 09:27:38
【问题描述】:
我尝试实现 documentation 中描述的 Scala 宏注释示例。我设法在使用它们的实际项目之前编译宏注释,即@compileTimeOnly("enable macro paradise to expand macro annotations") 没有被触发,这意味着宏注释在使用之前被编译。到目前为止一切顺利。
但是,当我在实际项目中对某些值进行如下注释时:
@identity val foo: Double = 1.1
@identity val bar: String = "bar"
那么我希望在运行主项目时会发生以下打印(通过之前链接的宏注释示例):
(<empty>,List(val foo: Double = 1.1))
(<empty>,List(val bar: String = "bar"))
这是我感到困惑的地方,当我运行主项目时不会发生打印。但是,在编译主项目时,它确实会出现一瞬间作为警告?
(我使用的是 IntelliJ IDEA 和 Scala 2.12.8)
【问题讨论】:
标签: scala macros annotations scala-macro-paradise