Skip to content

Commit 2eba82f

Browse files
committed
Add a hook for post-ANF transformation
For use by custom implementations of the async macro.
1 parent 5ed6a1d commit 2eba82f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/scala/scala/async/internal/AsyncTransform.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ trait AsyncTransform {
2020
// Transform to A-normal form:
2121
// - no await calls in qualifiers or arguments,
2222
// - if/match only used in statement position.
23-
val anfTree: Block = anfTransform(body)
23+
val anfTree0: Block = anfTransform(body)
24+
25+
val anfTree = futureSystemOps.postAnfTransform(anfTree0)
2426

2527
val resumeFunTreeDummyBody = DefDef(Modifiers(), name.resume, Nil, List(Nil), Ident(definitions.UnitClass), Literal(Constant(())))
2628

src/main/scala/scala/async/internal/FutureSystem.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ trait FutureSystem {
5151

5252
def spawn(tree: Tree, execContext: Tree): Tree =
5353
future(Expr[Unit](tree))(Expr[ExecContext](execContext)).tree
54+
55+
/** A hook for custom macros to transform the tree post-ANF transform */
56+
def postAnfTransform(tree: Block): Block = tree
5457
}
5558

5659
def mkOps(c: SymbolTable): Ops { val universe: c.type }

0 commit comments

Comments
 (0)