Skip to content

Commit ddfa757

Browse files
committed
WIP 34 - Target.inputs macro
1 parent 6409c58 commit ddfa757

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

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

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
270270
* The most common case of [[InputImpl]] is [[SourceImpl]] and [[SourcesImpl]],
271271
* used for detecting changes to source files.
272272
*/
273-
def input[T](value: Result[T])(implicit
273+
inline def input[T](inline value: Result[T])(implicit
274274
w: upickle.default.Writer[T],
275275
ctx: mill.define.Ctx
276276
): Target[T] =
277-
??? // macro Internal.inputImpl[T]
277+
${ Internal.inputImpl[T]('value)('w, 'ctx, 'this) }
278278

279279
/**
280280
* [[Command]]s are only [[NamedTask]]s defined using
@@ -526,25 +526,27 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
526526
???
527527
}
528528

529-
def inputImpl[T: c.WeakTypeTag](c: Context)(value: c.Expr[T])(
530-
w: c.Expr[upickle.default.Writer[T]],
531-
ctx: c.Expr[mill.define.Ctx]
532-
): c.Expr[Target[T]] = {
533-
// import c.universe._
529+
def inputImpl[T: Type](using Quotes)(value: Expr[Result[T]])(
530+
w: Expr[upickle.default.Writer[T]],
531+
ctx: Expr[mill.define.Ctx],
532+
caller: Expr[Applicative.Applyer[Task, Task, Result, mill.api.Ctx]]
533+
): Expr[Target[T]] = {
534+
import quotes.reflect.*
534535

535-
// val taskIsPrivate = isPrivateTargetOption(c)
536+
val taskIsPrivate = isPrivateTargetOption()
536537

537-
// mill.moduledefs.Cacher.impl0[InputImpl[T]](c)(
538-
// reify(
539-
// new InputImpl[T](
540-
// Applicative.impl[Task, T, mill.api.Ctx](c)(value).splice,
541-
// ctx.splice,
542-
// w.splice,
543-
// taskIsPrivate.splice
544-
// )
545-
// )
546-
// )
547-
???
538+
val lhs = Applicative.impl[Task, Task, Result, T, mill.api.Ctx](caller, value)
539+
540+
mill.moduledefs.Cacher.impl0[InputImpl[T]](
541+
'{
542+
new InputImpl[T](
543+
$lhs,
544+
$ctx,
545+
$w,
546+
$taskIsPrivate
547+
)
548+
}
549+
)
548550
}
549551

550552
def commandFromTask[T: c.WeakTypeTag](c: Context)(t: c.Expr[Task[T]])(

0 commit comments

Comments
 (0)