support for extra class annotations
Opened this issue · 1 comments
aalleexxeeii commented
When other class annotations (such as @serialversionuid) are required, the macro can't work: "Annotation is only supported on case class"
jxnu-liguobin commented
We can use match
resolve it, like this:
val (className, fields) = classDecl match {
case q"$mods class $className(..$fields) extends ..$bases { ..$body }" =>
if (!mods.asInstanceOf[Modifiers].hasFlag(Flag.CASE)) {
c.abort(c.enclosingPosition, s"Annotation is only supported on case class. classDef: $classDecl, mods: $mods")
} else {
(className, fields)
}
case _ => c.abort(c.enclosingPosition, s"Annotation is only supported on case class. classDef: $classDecl")
}