summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-11 20:49:39 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-11 20:49:39 -0800
commit033b247f742fee487996ced80c9daaf8eb10d5f1 (patch)
tree5ec2b6cff7717a35db7de702101b8ac3aa12ddf5 /core/src/main
parent37fd5e9de133dc157cdaa6d432700b93324680fe (diff)
downloadmill-033b247f742fee487996ced80c9daaf8eb10d5f1.tar.gz
mill-033b247f742fee487996ced80c9daaf8eb10d5f1.tar.bz2
mill-033b247f742fee487996ced80c9daaf8eb10d5f1.zip
`T{}` blocks can now be implicit
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/scala/mill/define/Task.scala14
-rw-r--r--core/src/main/scala/mill/eval/PathRef.scala1
-rw-r--r--core/src/main/scala/mill/modules/Jvm.scala2
3 files changed, 14 insertions, 3 deletions
diff --git a/core/src/main/scala/mill/define/Task.scala b/core/src/main/scala/mill/define/Task.scala
index ad6248d9..c1568a8f 100644
--- a/core/src/main/scala/mill/define/Task.scala
+++ b/core/src/main/scala/mill/define/Task.scala
@@ -47,7 +47,8 @@ object Task extends Applicative.Applyer[Task, Task, Args]{
def evaluate(args: Args) = t0
}
- def apply[T](t: T): Target[T] = macro targetCachedImpl[T]
+ implicit def apply[T](t: T): Target[T] = macro targetCachedImpl[T]
+
def apply[T](t: Task[T]): Target[T] = macro Cacher.impl0[Task, T]
def command[T](t: T): Command[T] = macro targetCommandImpl[T]
@@ -71,6 +72,17 @@ object Task extends Applicative.Applyer[Task, Task, Args]{
)
)
}
+ def targetCachedImpl2[T: c.WeakTypeTag, V: c.WeakTypeTag]
+ (c: Context)
+ (t: c.Expr[T])
+ (f: c.Expr[T => V]): c.Expr[Target[V]] = {
+ import c.universe._
+ c.Expr[Target[V]](
+ mill.define.Cacher.wrapCached(c)(
+ q"""${Applicative.impl[Task, T, Args](c)(t).tree}.map($f)"""
+ )
+ )
+ }
abstract class Ops[+T]{ this: Task[T] =>
def map[V](f: T => V) = new Task.Mapped(this, f)
diff --git a/core/src/main/scala/mill/eval/PathRef.scala b/core/src/main/scala/mill/eval/PathRef.scala
index 6d99ad91..5f7efe89 100644
--- a/core/src/main/scala/mill/eval/PathRef.scala
+++ b/core/src/main/scala/mill/eval/PathRef.scala
@@ -55,7 +55,6 @@ case class PathRef(path: ammonite.ops.Path){
}
object PathRef{
- implicit def make(p: ammonite.ops.Path): PathRef = PathRef(p)
private implicit val pathFormat: Format[Path] = JsonFormatters.pathFormat
implicit def jsonFormatter: Format[PathRef] = Json.format
}
diff --git a/core/src/main/scala/mill/modules/Jvm.scala b/core/src/main/scala/mill/modules/Jvm.scala
index bbaf1474..bfb7defe 100644
--- a/core/src/main/scala/mill/modules/Jvm.scala
+++ b/core/src/main/scala/mill/modules/Jvm.scala
@@ -64,7 +64,7 @@ object Jvm {
val inputs = roots
def evaluate(args: Args): PathRef = {
createJar(args.dest, args.args.map(_.asInstanceOf[PathRef].path))
- args.dest
+ PathRef(args.dest)
}
}
}