@@ -93,12 +93,15 @@ trait ExprBuilder {
93
93
val fun = This (tpnme.EMPTY )
94
94
val callOnComplete = futureSystemOps.onComplete[Any , Unit ](c.Expr [futureSystem.Fut [Any ]](awaitable.expr),
95
95
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
102
105
toList(callOnComplete) ::: Return (literalUnit) :: Nil
103
106
mkHandlerCase(state, stats ++ List (mkStateTree(onCompleteState, symLookup)) ++ tryGetOrCallOnComplete)
104
107
}
0 commit comments