Skip to content

Commit 743f616

Browse files
committed
WIP 38 - Target.worker macro
1 parent ef697b4 commit 743f616

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

main/define/src/mill/define/Task.scala

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
319319
def worker[T](t: Task[T])(implicit ctx: mill.define.Ctx): Worker[T] =
320320
??? // macro Internal.workerImpl1[T]
321321

322-
def worker[T](t: Result[T])(implicit ctx: mill.define.Ctx): Worker[T] =
323-
??? // macro Internal.workerImpl2[T]
322+
inline def worker[T](inline t: Result[T])(implicit ctx: mill.define.Ctx): Worker[T] =
323+
${ Internal.workerImpl2[T]('t)('ctx, 'this) }
324324

325325
/**
326326
* Creates an anonymous `Task`. These depend on other tasks and
@@ -617,21 +617,23 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
617617

618618
def workerImpl2[T: Type](using
619619
Quotes
620-
)(t: Expr[T])(ctx: Expr[mill.define.Ctx]): Expr[Worker[T]] = {
621-
// import c.universe._
620+
)(t: Expr[Result[T]])(
621+
ctx: Expr[mill.define.Ctx],
622+
caller: Expr[Applicative.Applyer[Task, Task, Result, mill.api.Ctx]]
623+
): Expr[Worker[T]] = {
624+
val taskIsPrivate = isPrivateTargetOption()
622625

623-
// val taskIsPrivate = isPrivateTargetOption(c)
626+
val lhs = Applicative.impl[Task, Task, Result, T, mill.api.Ctx](caller, t)
624627

625-
// mill.moduledefs.Cacher.impl0[Worker[T]](
626-
// '{
627-
// new Worker[T](
628-
// Applicative.impl[Task, Task, Result, T, mill.api.Ctx](c)(t).splice,
629-
// ctx.splice,
630-
// taskIsPrivate.splice
631-
// )
632-
// }
633-
// )
634-
???
628+
mill.moduledefs.Cacher.impl0[Worker[T]](
629+
'{
630+
new Worker[T](
631+
$lhs,
632+
$ctx,
633+
$taskIsPrivate
634+
)
635+
}
636+
)
635637
}
636638

637639
def persistentImpl[T: Type](using Quotes)(t: Expr[Result[T]])(

0 commit comments

Comments
 (0)