På onsdag 24. mai 2017 kl. 16:39:08, skrev Oliver Ruebenacker <
cur...@gmail.com>:
Would be nice to have something self-contained.
What happened if you replace the argument expression with ???:
val stateParam: Option[ExtendedStatusState] = ExtendedStatusStateVar.get
var criteria = stateParam.map(state =>
state.criteria.copy(endLocalDate = ???).getOrElse{...
Best, Oliver
Here's a test-case:
import org.joda.time.LocalDate
case class Criteria(endLocalDate: LocalDate)
class TestFisk {
var criteria = Some(Criteria(LocalDate.now())).map(crit =>
crit.copy(endLocalDate = crit.endLocalDate)
).getOrElse(Criteria(LocalDate.now))
def endLocalDate = criteria.endLocalDate.plusYears(1).monthOfYear().withMaximumValue()
}
Error:(10, 28) not found: value crit
crit.copy(endLocalDate = crit.endLocalDate)
It seems it's the
def endLocalDate
which is causing the trouble. I think this is a bug because the named parameter endLocalDate in copy() should be unambiguous regardless if there's a def with the same name in scope.
If I annotate the return-type of def endLoalDate it compiles fine:
var criteria = Some(Criteria(LocalDate.now())).map(crit =>
crit.copy(endLocalDate = crit.endLocalDate)
).getOrElse(Criteria(LocalDate.now))
def endLocalDate: LocalDate = criteria.endLocalDate.plusYears(1).monthOfYear().withMaximumValue()