I need to generate:
case class Foo(param: Bar = BarEnum.SomeCaseObject)
But this code:
val term = TermName("BarEnum.SomeCaseObject")
showCode(q"""case class Foo(val param : Bar = ${term})""")
outputs the parameter default surrounded by backticks, which doesn't compile:
case class Foo(param: Bar = `BarEnum.SomeCaseObject`)
How can I get the default parameter value output without the backticks?
You are trying to create value with name "BarEnum.SomeCaseObject", that's illegal identifier, thus in backticks.
You can use
Select(Ident(TermName("BarEnum")), TermName("SomeCaseObject"))
or (better)q"BarEnum.SomeCaseObject"
(assuming thatSomeCaseObject
is a term).