mirror of https://github.com/sbt/sbt.git
Merge pull request #3044 from dwijnand/propagate-weak-type-tags
Fix inputTaskDyn not working
This commit is contained in:
commit
cb8acb2150
|
|
@ -48,13 +48,13 @@ object FullConvert extends Convert {
|
|||
case _ => Converted.NotApplicable[c.type]
|
||||
}
|
||||
|
||||
private def wrapInit[T](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||
private def wrapInit[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||
val i = c.Expr[Initialize[T]](tree)
|
||||
val t = c.universe.reify(Def.toITask(i.splice)).tree
|
||||
Converted.Success[c.type](t)
|
||||
}
|
||||
|
||||
private def wrapTask[T](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||
private def wrapTask[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||
val i = c.Expr[Task[T]](tree)
|
||||
val t = c.universe.reify(Def.valueStrict[Task[T]](i.splice)).tree
|
||||
Converted.Success[c.type](t)
|
||||
|
|
@ -73,7 +73,7 @@ object InitParserConvert extends Convert {
|
|||
case _ => Converted.NotApplicable[c.type]
|
||||
}
|
||||
|
||||
private def wrap[T](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||
private def wrap[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||
val e = c.Expr[State => Parser[T]](tree)
|
||||
val t = c.universe.reify { Def.valueStrict[State => Parser[T]](e.splice) }
|
||||
Converted.Success[c.type](t.tree)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ object InitializeConvert extends Convert {
|
|||
case _ => Converted.NotApplicable
|
||||
}
|
||||
|
||||
private def convert[T](c: blackbox.Context)(in: c.Tree): Converted[c.type] =
|
||||
private def convert[T: c.WeakTypeTag](c: blackbox.Context)(in: c.Tree): Converted[c.type] =
|
||||
{
|
||||
val i = c.Expr[Initialize[T]](in)
|
||||
val t = c.universe.reify(i.splice).tree
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
object Bar {
|
||||
def main(args: Array[String]): Unit = {
|
||||
println("Bar: " + args.toList.toString)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
object Foo {
|
||||
def main(args: Array[String]): Unit = {
|
||||
println("Foo: " + args.toList.toString)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import complete.Parser
|
||||
|
||||
// http://www.scala-sbt.org/0.13/docs/Input-Tasks.html
|
||||
|
||||
val runFoo = inputKey[Unit]("Runs Foo with passed arguments")
|
||||
val check = taskKey[Unit]("")
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
name := "run-test",
|
||||
runFoo := Def.inputTaskDyn {
|
||||
val args = Def.spaceDelimited().parsed
|
||||
(runMain in Compile).toTask(s" Foo " + args.mkString(" "))
|
||||
}.evaluated,
|
||||
check := {
|
||||
val x = runFoo.toTask(" hi ho").value
|
||||
}
|
||||
)
|
||||
|
|
@ -0,0 +1 @@
|
|||
> check
|
||||
Loading…
Reference in New Issue