I'm trying to answer this question.
Instead of writing:
case class Person(name: String, age: Int) {
def this() = this("",1)
}
I thought I'd use macro annotations to expand it from:
@Annotation
case class Person(name: String, age: Int)
So I tried adding the new constructor as a plain-old DefDef
using quasiquotes in a macro annotation's impl, like:
val newCtor = q"""def this() = this("", 1)"""
val newBody = body :+ newCtor
q"$mods class $name[..$tparams](..$first)(...$rest) extends ..$parents { $self => ..$newBody }"
But that returns an error: called constructor's definition must precede calling constructor's definition
Is there a way to fix that? What did I miss?
Thanks for taking a look, -Julian