Let's say a I have a class:
case class Foo(id: Int, name: String, note: Option[String] = None)
Both the constructor and the apply method in the automatically generated companion object take three parameters. When viewed via reflection, the third parameter (note) is flagged:
p.isParamWithDefault = true
Also, by inspection I can find the method that produces the value in the companion object:
method <init>$default$3
and
method apply$default$3
Which both also have:
m.isParamWithDefault = true
However, I can neither find anything on the TermSymbol for the notes parameter that actually points me at the right methods to obtain the default value nor anything on the above MethodSymbols that point back to the TermSymbol for the parameter.
Is there a straight forward way to link TermSymbol for the parameter with the method that generates its default value? Or do I need to do something kludgey like inspect the names of the methods on the companion object?
I'm interested in this both for the case class constructor example I have here and for regular methods.
See Question&Answers more detail:os