Skip to content

Commit f175357

Browse files
committed
WIP 36 - Target.apply (targetResultImpl) macro
1 parent e525faa commit f175357

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
203203
implicit inline def apply[T](inline t: T)(implicit rw: RW[T], ctx: mill.define.Ctx): Target[T] =
204204
${ Internal.targetImpl[T]('t)('rw, 'ctx, 'this) }
205205

206-
implicit def apply[T](t: Result[T])(implicit rw: RW[T], ctx: mill.define.Ctx): Target[T] =
207-
??? // macro Internal.targetResultImpl[T]
206+
implicit inline def apply[T](inline t: Result[T])(implicit
207+
rw: RW[T],
208+
ctx: mill.define.Ctx
209+
): Target[T] =
210+
${ Internal.targetResultImpl[T]('t)('rw, 'ctx, 'this) }
208211

209212
def apply[T](t: Task[T])(implicit rw: RW[T], ctx: mill.define.Ctx): Target[T] =
210213
??? // macro Internal.targetTaskImpl[T]
@@ -398,25 +401,25 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
398401
)
399402
}
400403

401-
def targetResultImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[Result[T]])(
402-
rw: c.Expr[RW[T]],
403-
ctx: c.Expr[mill.define.Ctx]
404-
): c.Expr[Target[T]] = {
405-
// import c.universe._
404+
def targetResultImpl[T: Type](using Quotes)(t: Expr[Result[T]])(
405+
rw: Expr[RW[T]],
406+
ctx: Expr[mill.define.Ctx],
407+
caller: Expr[Applicative.Applyer[Task, Task, Result, mill.api.Ctx]]
408+
): Expr[Target[T]] = {
409+
val taskIsPrivate = isPrivateTargetOption()
406410

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

409-
// mill.moduledefs.Cacher.impl0[Target[T]](c)(
410-
// reify(
411-
// new TargetImpl[T](
412-
// Applicative.impl0[Task, T, mill.api.Ctx](c)(t.tree).splice,
413-
// ctx.splice,
414-
// rw.splice,
415-
// taskIsPrivate.splice
416-
// )
417-
// )
418-
// )
419-
???
413+
mill.moduledefs.Cacher.impl0[Target[T]](
414+
'{
415+
new TargetImpl[T](
416+
$lhs,
417+
$ctx,
418+
$rw,
419+
$taskIsPrivate
420+
)
421+
}
422+
)
420423
}
421424

422425
def targetTaskImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[Task[T]])(

0 commit comments

Comments
 (0)