@@ -93,12 +93,15 @@ trait ExprBuilder {
9393 val fun = This (tpnme.EMPTY )
9494 val callOnComplete = futureSystemOps.onComplete[Any , Unit ](c.Expr [futureSystem.Fut [Any ]](awaitable.expr),
9595 c.Expr [futureSystem.Tryy [Any ] => Unit ](fun), c.Expr [futureSystem.ExecContext ](Ident (name.execContext))).tree
96- val tryGetOrCallOnComplete =
97- if (futureSystemOps.continueCompletedFutureOnSameThread)
98- If (futureSystemOps.isCompleted(c.Expr [futureSystem.Fut [_]](awaitable.expr)).tree,
99- adaptToUnit(ifIsFailureTree[T ](futureSystemOps.getCompleted[Any ](c.Expr [futureSystem.Fut [Any ]](awaitable.expr)).tree) :: Nil ),
100- Block (toList(callOnComplete), Return (literalUnit))) :: Nil
101- else
96+ val tryGetOrCallOnComplete : List [Tree ] =
97+ if (futureSystemOps.continueCompletedFutureOnSameThread) {
98+ val tempName = name.fresh(name.completed)
99+ val initTemp = ValDef (NoMods , tempName, TypeTree (futureSystemOps.tryType[Any ]), futureSystemOps.getCompleted[Any ](c.Expr [futureSystem.Fut [Any ]](awaitable.expr)).tree)
100+ val ifTree = If (Apply (Select (Literal (Constant (null )), TermName (" ne" )), Ident (tempName) :: Nil ),
101+ adaptToUnit(ifIsFailureTree[T ](Ident (tempName)) :: Nil ),
102+ Block (toList(callOnComplete), Return (literalUnit)))
103+ initTemp :: ifTree :: Nil
104+ } else
102105 toList(callOnComplete) ::: Return (literalUnit) :: Nil
103106 mkHandlerCase(state, stats ++ List (mkStateTree(onCompleteState, symLookup)) ++ tryGetOrCallOnComplete)
104107 }
0 commit comments