Make `f(await(completedFuture))` execute `f` synchronously

A worthy optimization, suggested by @danarmak.

Closes #73
Then LGTM!

-- 
Cheers,
√
On 17 Dec 2014 01:39, "Jason Zaugg" <notifications@github.com> wrote:

> In src/main/scala/scala/async/internal/ExprBuilder.scala
> <https://github.com/scala/async/pull/98#discussion-diff-21945036>:
>
> >                                    val awaitable: Awaitable, symLookup: SymLookup)
> >      extends AsyncState {
> >
> >      def nextStates: List[Int] =
> >        List(nextState)
> >
> > -    override def mkHandlerCaseForState: CaseDef = {
> > -      val callOnComplete = futureSystemOps.onComplete(Expr(awaitable.expr),
> > -        Expr(This(tpnme.EMPTY)), Expr(Ident(name.execContext))).tree
> > -      mkHandlerCase(state, stats :+ callOnComplete)
> > +    override def mkHandlerCaseForState[T: WeakTypeTag]: CaseDef = {
> > +      val fun = This(tpnme.EMPTY)
> > +      val callOnComplete = futureSystemOps.onComplete[Any, Unit](Expr[futureSystem.Fut[Any]](awaitable.expr),
> > +        Expr[futureSystem.Tryy[Any] => Unit](fun), Expr[futureSystem.ExecContext](Ident(name.execContext))).tree
> > +      val tryGetOrCallOnComplete =
> > +        if (futureSystemOps.continueCompletedFutureOnSameThread)
>
> someEC is used throughout.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/scala/async/pull/98/files#r21945036>.
>