Skip to content

Instantly share code, notes, and snippets.

@leogrim
Last active May 2, 2016 20:06
Show Gist options
  • Save leogrim/d86a11c31b2e644ae2ebc7f4d50c0461 to your computer and use it in GitHub Desktop.
Save leogrim/d86a11c31b2e644ae2ebc7f4d50c0461 to your computer and use it in GitHub Desktop.
Scala Macro Annotation by Martin Raison
val (className, fields) = try {
val q"case class $className(..$fields) extends ..$bases { ..$body }" = classDecl
(className, fields)
} catch {
case _: MatchError => c.abort(c.enclosingPosition, "Annotation is only supported on case class")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment