【发布时间】:2019-07-14 23:32:22
【问题描述】:
根据scaladocumentation,有四种注解:
- 类注解:
@ClassAnnotation case class Foo(...) - 变量/值注释:
@ValAnnotation val field: String - 类型注释:
field: String @TypeAnnotation - 表达式注释
通过使用shapeless.Annotation 和shapeless.Annotations,很容易从案例类中获取类和变量注解(1&2)。如何获取其字段的类型注解(三)?
例子:
@ClassAnnotation
case class Foo(
@ValAnnotation field: String @TypeAnnotation
)
【问题讨论】:
标签: scala shapeless scala-macros