Add some singleton type arguments

This commit is contained in:
Dale Wijnand 2016-10-05 10:33:33 -05:00
parent 2f84e05282
commit f3a6e9d0c1
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
1 changed files with 15 additions and 15 deletions

View File

@ -10,9 +10,9 @@ import sbt.internal.util.appmacro.{ Convert, Converted }
object InputInitConvert extends Convert {
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
nme match {
case InputWrapper.WrapInitName => Converted.Success(in)
case InputWrapper.WrapInitTaskName => Converted.Failure(in.pos, initTaskErrorMessage)
case _ => Converted.NotApplicable
case InputWrapper.WrapInitName => Converted.Success[c.type](in)
case InputWrapper.WrapInitTaskName => Converted.Failure[c.type](in.pos, initTaskErrorMessage)
case _ => Converted.NotApplicable[c.type]
}
private def initTaskErrorMessage = "Internal sbt error: initialize+task wrapper not split"
@ -22,9 +22,9 @@ object InputInitConvert extends Convert {
object ParserConvert extends Convert {
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
nme match {
case ParserInput.WrapName => Converted.Success(in)
case ParserInput.WrapInitName => Converted.Failure(in.pos, initParserErrorMessage)
case _ => Converted.NotApplicable
case ParserInput.WrapName => Converted.Success[c.type](in)
case ParserInput.WrapInitName => Converted.Failure[c.type](in.pos, initParserErrorMessage)
case _ => Converted.NotApplicable[c.type]
}
private def initParserErrorMessage = "Internal sbt error: initialize+parser wrapper not split"
@ -33,7 +33,7 @@ object ParserConvert extends Convert {
/** Convert instance for plain `Task`s not within the settings system. */
object TaskConvert extends Convert {
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
if (nme == InputWrapper.WrapTaskName) Converted.Success(in) else Converted.NotApplicable
if (nme == InputWrapper.WrapTaskName) Converted.Success[c.type](in) else Converted.NotApplicable[c.type]
}
/** Converts an input `Tree` of type `Initialize[T]`, `Initialize[Task[T]]`, or `Task[T]` into a `Tree` of type `Initialize[Task[T]]`.*/
@ -41,23 +41,23 @@ object FullConvert extends Convert {
import InputWrapper._
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
nme match {
case WrapInitTaskName => Converted.Success(in)
case WrapPreviousName => Converted.Success(in)
case WrapInitTaskName => Converted.Success[c.type](in)
case WrapPreviousName => Converted.Success[c.type](in)
case WrapInitName => wrapInit[T](c)(in)
case WrapTaskName => wrapTask[T](c)(in)
case _ => Converted.NotApplicable
case _ => Converted.NotApplicable[c.type]
}
private def wrapInit[T](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(t)
Converted.Success[c.type](t)
}
private def wrapTask[T](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(t)
Converted.Success[c.type](t)
}
}
@ -69,13 +69,13 @@ object InitParserConvert extends Convert {
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
nme match {
case ParserInput.WrapName => wrap[T](c)(in)
case ParserInput.WrapInitName => Converted.Success(in)
case _ => Converted.NotApplicable
case ParserInput.WrapInitName => Converted.Success[c.type](in)
case _ => Converted.NotApplicable[c.type]
}
private def wrap[T](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(t.tree)
Converted.Success[c.type](t.tree)
}
}