On Jan 9, 1:33 am, Trond Olsen <
tr...@steinbit.org> wrote:
> Changed nomatchMatcher and messageMatcher to defs but still same exception.
>
> The highlighted line in AbstractPartialFunction is where the exception is
> thrown. I read the error as this.fallBackField somehow has not been set
> (null is its initial value). It is set in fallback, which in turn is only
> called from missingCase and isDefinedAt (conditionally).
>
> abstract class AbstractPartialFunction[-T1, +R]
> extends AbstractFunction1[T1, R]
> with PartialFunction[T1, R]
> with Cloneable {
>
> private var fallBackField: PartialFunction[T1 @uncheckedVariance, R
> @uncheckedVariance] = _
>
> def fallBack: PartialFunction[T1, R] = synchronized {
> if (fallBackField == null) fallBackField = PartialFunction.empty
> fallBackField
> }
>
> override protected def missingCase(x: T1): R = fallBack(x)
>
> // Question: Need to ensure that fallBack is overwritten before any access
> // Is the `synchronized` here the right thing to achieve this?
> // Is there a cheaper way?
> override def orElse[A1 <: T1, B1 >: R](that: PartialFunction[A1, B1]) :
> PartialFunction[A1, B1] = {
> val result = this.clone.asInstanceOf[AbstractPartialFunction[A1, B1]]
> result.synchronized {
>
>
>
>
>
>
>
> > Avoid using abstract vals unless you're very comfortable with
> > initialization order. Either use abstract def or lazy val.
>
> > Cheers,
> > V
> > On Jan 8, 2012 6:00 PM, "Trond Olsen" <
tr...@steinbit.org> wrote:
>
> >> In the classes that mixin the Resumable trait ala:
>
> >> class A
> >> extends Some
> >> with Actor with Resumable {
> >> protected val messageMatcher: PartialFunction[Any, Unit] = {
> >> case msg =>
> >> }
> >> }
>