-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Scala
-
None
I'm following up on this issue. After updating the minimal github repo with Ross' suggestion, compilation still failed with the same error.
So I dug into the macro, and the way default args are handled caught my eye:
def defaultClassArgs = { val terms = mainType.decl(termNames.CONSTRUCTOR).asMethod.paramLists match { case h :: _ => h.map(_.asTerm) case _ => List.empty } val params = terms.zipWithIndex.collect { case (s, i) if s.isParamWithDefault => { val getterName = TermName("apply$default$" + (i + 1)) q"${s.name.toString} -> ${mainType.typeSymbol.companion}.$getterName" } } c.Expr[Map[String, Any]](q"Map[String, Any](..$params)") } ... val classFieldDefaultArgsMap = $defaultClassArgs
Looks like default args are being stored as vals. This approach seems like it would work for simple defaults, like strings or ints. But would it work for lambda-based defaults, like ObjectId.get?
- related to
-
JAVA-3551 Support default args in the CaseClassCodec
- Backlog