mirror of https://github.com/sbt/sbt.git
Forward type to the conditional tasks to fix Seq[Nothing]
Fixes https://github.com/sbt/sbt/issues/5625
This commit is contained in:
parent
c07de68cf5
commit
9821b83048
|
|
@ -109,7 +109,7 @@ object TaskMacro {
|
|||
t.tree match {
|
||||
// the tree matches `if` and only `if`
|
||||
case If(cond, thenp, elsep) =>
|
||||
c.Expr[Initialize[Task[T]]](mkIfS(c)(cond, thenp, elsep))
|
||||
c.Expr[Initialize[Task[T]]](mkIfS[T](c)(cond, thenp, elsep))
|
||||
case _ =>
|
||||
Instance.contImpl[T, Id](c, FullInstance, FullConvert, MixedBuilder, TaskLinterDSL)(
|
||||
Left(t),
|
||||
|
|
@ -118,11 +118,12 @@ object TaskMacro {
|
|||
}
|
||||
}
|
||||
|
||||
def mkIfS(
|
||||
def mkIfS[A: c.WeakTypeTag](
|
||||
c: blackbox.Context
|
||||
)(cond: c.Tree, thenp: c.Tree, elsep: c.Tree): c.Tree = {
|
||||
import c.universe._
|
||||
q"""Def.ifS(Def.task($cond))(Def.task($thenp))(Def.task($elsep))"""
|
||||
val AA = implicitly[c.WeakTypeTag[A]].tpe
|
||||
q"""_root_.sbt.Def.ifS[$AA](_root_.sbt.Def.task($cond))(_root_.sbt.Def.task[$AA]($thenp: $AA))(_root_.sbt.Def.task[$AA]($elsep: $AA))"""
|
||||
}
|
||||
|
||||
def taskDynMacroImpl[T: c.WeakTypeTag](
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ val output = settingKey[File]("")
|
|||
|
||||
lazy val root = (project in file("."))
|
||||
.settings(
|
||||
name := "ifs",
|
||||
name := "conditional",
|
||||
output := baseDirectory.value / "output.txt",
|
||||
condition := true,
|
||||
number := -1,
|
||||
|
|
@ -39,6 +39,12 @@ lazy val root = (project in file("."))
|
|||
TaskKey[Unit]("checkFalse") := checkLines("false"),
|
||||
TaskKey[Unit]("checkNeg") := checkLines("neg"),
|
||||
TaskKey[Unit]("checkZero") := checkLines("zero"),
|
||||
|
||||
// https://github.com/sbt/sbt/issues/5625
|
||||
javacOptions ++= (
|
||||
if (true) Seq.empty
|
||||
else Seq("--release", "8")
|
||||
),
|
||||
)
|
||||
|
||||
def checkLines(content: String) = Def.task {
|
||||
Loading…
Reference in New Issue