mirror of https://github.com/sbt/sbt.git
Fix inputTaskDyn not working
This fixes the following error when trying to use inputTaskDyn in a build:
[error] /tmp/sbt_8316130f/input-task-dyn/build.sbt:11: error: Macro
expansion contains free type variable T defined by wrap in
InputConvert.scala:76:20. Have you forgotten to use c.WeakTypeTag
annotation for this type parameter? If you
have troubles tracking free type variables, consider using -Xlog-free-types (out-1)
[error] runFoo := Def.inputTaskDyn { (out-1)
[error] ^ (out-1)
[info] [error] sbt.compiler.EvalException: Type error in expression (out-3) (out-1)
I have no idea what the error means, I just implemented the suggested fix.
This commit is contained in:
parent
317085a458
commit
747aa48c9c
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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