I keep getting
Forward reference extends over definition of value a
error while trying to compile my application (inside SBT).
a is just val a = "", the error is triggered by accessing a particular parameter (of the function) right before a definition. The parameter is of a simple case class type with all three fields of Option[...] type (2 of Option[org.joda.time.DateTime] and 1 of Option of an enumeration value).
What can “Forward reference extends over definition of value” mean at all and what can be the ways to fight it?
Depending on your scalac version, there have been bugs where synthetic methods cause this error.
https://issues.scala-lang.org/browse/SI-6278
Illustration, imagine f is generated:
Case classes, default arguments and implicit classes involve synthetics.
In the example code from that ticket (which has been fixed), you can break the ok method by moving the implicit to the end of the function:
As implied by the comment in the code, making the definition lazy is a workaround.
Illustration 2, imagine the function is so long that you don’t notice the naming problem: