InputWrapper can be inline method

This commit is contained in:
Eugene Yokota 2022-05-15 21:07:22 -04:00
parent 340721c4a1
commit 6662dbad26
19 changed files with 147 additions and 121 deletions

View File

@ -224,6 +224,7 @@ trait Cont:
replace
}
val tx = transformWrappers(expr.asTerm, record, Symbol.spliceOwner)
// println("tx: " + tx.show)
val tr = makeApp(inner(tx), inputBuf.toList)
tr
end Cont

View File

@ -19,7 +19,6 @@ import scala.quoted.*
* single term param like `X.wrapInit[A](...)`.
*/
trait Convert[C <: Quotes & Singleton](override val qctx: C) extends ContextUtil[C]:
// with TupleBuilder[C]:
import qctx.reflect.*
def convert[A: Type](nme: String, in: Term): Converted

View File

@ -10,7 +10,9 @@ package sbt
import java.io.File
import java.net.URI
import scala.annotation.compileTimeOnly
import scala.annotation.tailrec
import scala.annotation.targetName
import sbt.KeyRanks.{ DTask, Invisible }
import sbt.Scope.{ GlobalScope, ThisScope }
import sbt.internal.util.Types.const
@ -281,8 +283,12 @@ object Def extends Init[Scope] with TaskMacroExtra with InitializeImplicits:
// implicit def macroValueI[T](@deprecated("unused", "") in: Initialize[T]): MacroValue[T] = ???
// implicit def macroValueIT[T](@deprecated("unused", "") in: Initialize[Task[T]]): MacroValue[T] =
// ???
extension [A1](in: Initialize[A1])
inline def value: A1 = InputWrapper.`wrapInit_\u2603\u2603`[A1](in)
extension [A1](in: Initialize[Task[A1]])
@targetName("valueIA1")
inline def value: A1 = InputWrapper.`wrapInitTask_\u2603\u2603`[A1](in)
// implicit def macroValueIInT[T](
// @deprecated("unused", "") in: Initialize[InputTask[T]]

View File

@ -543,46 +543,55 @@ object Scoped:
def identityMap = map(mkTuple2)
protected def convert[M[_], R](f: (M[A], M[B]) => R) = f.tupled
}
final class RichTaskable3[A, B, C](t3: (ST[A], ST[B], ST[C])) extends RichTaskables[AList.Tuple3K[A, B, C]](t3)(AList.tuple3[A, B, C]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C]) => Ret
def identityMap = map(mkTuple3)
protected def convert[M[_], R](f: Fun[M, R]) = f.tupled
}
final class RichTaskable4[A, B, C, D](t4: (ST[A], ST[B], ST[C], ST[D])) extends RichTaskables[AList.Tuple4K[A, B, C, D]](t4)(AList.tuple4[A, B, C, D]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D]) => Ret
def identityMap = map(mkTuple4)
protected def convert[M[_], R](f: Fun[M, R]) = f.tupled
}
final class RichTaskable5[A, B, C, D, E](t5: (ST[A], ST[B], ST[C], ST[D], ST[E])) extends RichTaskables[AList.Tuple5K[A, B, C, D, E]](t5)(AList.tuple5[A, B, C, D, E]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D], M[E]) => Ret
def identityMap = map(mkTuple5)
protected def convert[M[_], R](f: Fun[M, R]) = f.tupled
}
final class RichTaskable6[A, B, C, D, E, F](t6: (ST[A], ST[B], ST[C], ST[D], ST[E], ST[F])) extends RichTaskables[AList.Tuple6K[A, B, C, D, E, F]](t6)(AList.tuple6[A, B, C, D, E, F]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D], M[E], M[F]) => Ret
def identityMap = map(mkTuple6)
protected def convert[M[_], R](z: Fun[M, R]) = z.tupled
}
final class RichTaskable7[A, B, C, D, E, F, G](t7: (ST[A], ST[B], ST[C], ST[D], ST[E], ST[F], ST[G])) extends RichTaskables[AList.Tuple7K[A, B, C, D, E, F, G]](t7)(AList.tuple7[A, B, C, D, E, F, G]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D], M[E], M[F], M[G]) => Ret
def identityMap = map(mkTuple7)
protected def convert[M[_], R](z: Fun[M, R]) = z.tupled
}
final class RichTaskable8[A, B, C, D, E, F, G, H](t8: (ST[A], ST[B], ST[C], ST[D], ST[E], ST[F], ST[G], ST[H])) extends RichTaskables[AList.Tuple8K[A, B, C, D, E, F, G, H]](t8)(AList.tuple8[A, B, C, D, E, F, G, H]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D], M[E], M[F], M[G], M[H]) => Ret
def identityMap = map(mkTuple8)
protected def convert[M[_], R](z: Fun[M, R]) = z.tupled
}
final class RichTaskable9[A, B, C, D, E, F, G, H, I](t9: (ST[A], ST[B], ST[C], ST[D], ST[E], ST[F], ST[G], ST[H], ST[I])) extends RichTaskables[AList.Tuple9K[A, B, C, D, E, F, G, H, I]](t9)(AList.tuple9[A, B, C, D, E, F, G, H, I]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D], M[E], M[F], M[G], M[H], M[I]) => Ret
def identityMap = map(mkTuple9)
protected def convert[M[_], R](z: Fun[M, R]) = z.tupled
}
final class RichTaskable10[A, B, C, D, E, F, G, H, I, J](t10: ((ST[A], ST[B], ST[C], ST[D], ST[E], ST[F], ST[G], ST[H], ST[I], ST[J]))) extends RichTaskables[AList.Tuple10K[A, B, C, D, E, F, G, H, I, J]](t10)(AList.tuple10[A, B, C, D, E, F, G, H, I, J]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D], M[E], M[F], M[G], M[H], M[I], M[J]) => Ret
def identityMap = map(mkTuple10)
protected def convert[M[_], R](z: Fun[M, R]) = z.tupled
}
final class RichTaskable11[A, B, C, D, E, F, G, H, I, J, K](t11: ((ST[A], ST[B], ST[C], ST[D], ST[E], ST[F], ST[G], ST[H], ST[I], ST[J], ST[K]))) extends RichTaskables[AList.Tuple11K[A, B, C, D, E, F, G, H, I, J, K]](t11)(AList.tuple11[A, B, C, D, E, F, G, H, I, J, K]) {
type Fun[M[_], Ret] = (M[A], M[B], M[C], M[D], M[E], M[F], M[G], M[H], M[I], M[J], M[K]) => Ret
def identityMap = map(mkTuple11)

View File

@ -70,9 +70,9 @@ class FullConvert[C <: Quotes & scala.Singleton](override val qctx: C)
case _ => Converted.NotApplicable()
private def wrapInit[A: Type](tree: Term): Converted =
val i = tree.asExprOf[Initialize[A]]
val expr = tree.asExprOf[Initialize[A]]
val t = '{
Def.toITask($i)
Def.toITask($expr)
}
Converted.success(t.asTerm)

View File

@ -11,7 +11,8 @@ package std
import scala.language.experimental.macros
import scala.annotation.compileTimeOnly
import scala.reflect.macros._
import scala.quoted.*
// import scala.reflect.macros._
import Def.Initialize
import sbt.internal.util.appmacro.ContextUtil
@ -62,51 +63,34 @@ object InputWrapper:
private[this] def implDetailError =
sys.error("This method is an implementation detail and should not be referenced.")
/*
private[std] def wrapTask[T: c.WeakTypeTag](c: blackbox.Context)(
ts: c.Expr[Any],
pos: c.Position
): c.Expr[T] =
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapTaskName)(ts, pos)
private[std] def wrapInit[T: c.WeakTypeTag](c: blackbox.Context)(
ts: c.Expr[Any],
pos: c.Position
): c.Expr[T] =
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitName)(ts, pos)
private[std] def wrapInitTask[T: c.WeakTypeTag](c: blackbox.Context)(
ts: c.Expr[Any],
pos: c.Position
): c.Expr[T] =
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitTaskName)(ts, pos)
private[std] def wrapInitInputTask[T: c.WeakTypeTag](c: blackbox.Context)(
/*
private[std] def wrapInitInputTask[T: c.WeakTypeTag](using qctx: Quotes)(
ts: c.Expr[Any],
pos: c.Position
): c.Expr[T] =
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitInputName)(ts, pos)
private[std] def wrapInputTask[T: c.WeakTypeTag](c: blackbox.Context)(
private[std] def wrapInputTask[T: c.WeakTypeTag](using qctx: Quotes)(
ts: c.Expr[Any],
pos: c.Position
): c.Expr[T] =
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInputName)(ts, pos)
private[std] def wrapPrevious[T: c.WeakTypeTag](c: blackbox.Context)(
private[std] def wrapPrevious[T: c.WeakTypeTag](using qctx: Quotes)(
ts: c.Expr[Any],
pos: c.Position
): c.Expr[Option[T]] =
wrapImpl[Option[T], InputWrapper.type](c, InputWrapper, WrapPreviousName)(ts, pos)
/**
* Wraps an arbitrary Tree in a call to the `<s>.<wrapName>` method of this module for later processing by an enclosing macro.
* The resulting Tree is the manually constructed version of:
*
* `c.universe.reify { <s>.<wrapName>[T](ts.splice) }`
*/
* Wraps an arbitrary Tree in a call to the `<s>.<wrapName>` method of this module for later processing by an enclosing macro.
* The resulting Tree is the manually constructed version of:
*
* `c.universe.reify { <s>.<wrapName>[T](ts.splice) }`
*/
def wrapImpl[T: c.WeakTypeTag, S <: AnyRef with Singleton](
c: blackbox.Context,
using qctx: Quotes,
s: S,
wrapName: String
)(ts: c.Expr[Any], pos: c.Position)(implicit it: c.TypeTag[s.type]): c.Expr[T] = {
@ -134,8 +118,8 @@ object InputWrapper:
c.Expr[T](typedTree)
}
def valueMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[T] =
ContextUtil.selectMacroImpl[T](c) { (ts, pos) =>
def valueMacroImpl[A1: Type](using qctx: Quotes): Expr[A1] =
ContextUtil.selectMacroImpl[A1](c) { (ts, pos) =>
ts.tree.tpe match {
case tpe if tpe <:< c.weakTypeOf[Initialize[T]] =>
if (c.weakTypeOf[T] <:< c.weakTypeOf[InputTask[_]]) {
@ -145,21 +129,22 @@ object InputWrapper:
|See https://www.scala-sbt.org/1.0/docs/Input-Tasks.html for more details.""".stripMargin
)
}
InputWrapper.wrapInit[T](c)(ts, pos)
InputWrapper.wrapInit[A1](c)(ts, pos)
case tpe if tpe <:< c.weakTypeOf[Initialize[Task[T]]] =>
InputWrapper.wrapInitTask[T](c)(ts, pos)
InputWrapper.wrapInitTask[A1](c)(ts, pos)
case tpe if tpe <:< c.weakTypeOf[Task[T]] => InputWrapper.wrapTask[T](c)(ts, pos)
case tpe if tpe <:< c.weakTypeOf[InputTask[T]] => InputWrapper.wrapInputTask[T](c)(ts, pos)
case tpe if tpe <:< c.weakTypeOf[Initialize[InputTask[T]]] =>
InputWrapper.wrapInitInputTask[T](c)(ts, pos)
InputWrapper.wrapInitInputTask[A1](c)(ts, pos)
case tpe => unexpectedType(c)(pos, tpe)
}
}
def inputTaskValueMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[InputTask[T]] =
def inputTaskValueMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[InputTask[T]] =
ContextUtil.selectMacroImpl[InputTask[T]](c) { (ts, pos) =>
InputWrapper.wrapInit[InputTask[T]](c)(ts, pos)
}
def taskValueMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[Task[T]] =
def taskValueMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[Task[T]] =
ContextUtil.selectMacroImpl[Task[T]](c) { (ts, pos) =>
val tpe = ts.tree.tpe
if (tpe <:< c.weakTypeOf[Initialize[Task[T]]])
@ -170,7 +155,7 @@ object InputWrapper:
/** Translates <task: TaskKey[T]>.previous(format) to Previous.runtime(<task>)(format).value */
def previousMacroImpl[T: c.WeakTypeTag](
c: blackbox.Context
using qctx: Quotes
)(format: c.Expr[sjsonnew.JsonFormat[T]]): c.Expr[Option[T]] = {
import c.universe._
c.macroApplication match {
@ -184,9 +169,9 @@ object InputWrapper:
}
}
private def unexpectedType(c: blackbox.Context)(pos: c.Position, tpe: c.Type) =
private def unexpectedType(using qctx: Quotes)(pos: c.Position, tpe: c.Type) =
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.widen}")
*/
*/
end InputWrapper
/*
@ -196,12 +181,14 @@ sealed abstract class MacroTaskValue[T] {
)
def taskValue: Task[T] = macro InputWrapper.taskValueMacroImpl[T]
}
sealed abstract class MacroValue[T] {
sealed abstract class MacroValue[A1] {
@compileTimeOnly(
"`value` can only be used within a task or setting macro, such as :=, +=, ++=, Def.task, or Def.setting."
)
def value: T = macro InputWrapper.valueMacroImpl[T]
def value: A1 = macro InputWrapper.valueMacroImpl[A1]
}
sealed abstract class ParserInput[T] {
@compileTimeOnly(
"`parsed` can only be used within an input task macro, such as := or Def.inputTask."
@ -254,20 +241,20 @@ object ParserInput:
sys.error("This method is an implementation detail and should not be referenced.")
/*
private[std] def wrap[T: c.WeakTypeTag](
c: blackbox.Context
using qctx: Quotes
)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
InputWrapper.wrapImpl[T, ParserInput.type](c, ParserInput, WrapName)(ts, pos)
private[std] def wrapInit[T: c.WeakTypeTag](
c: blackbox.Context
using qctx: Quotes
)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
InputWrapper.wrapImpl[T, ParserInput.type](c, ParserInput, WrapInitName)(ts, pos)
private[std] def inputParser[T: c.WeakTypeTag](
c: blackbox.Context
using qctx: Quotes
)(t: c.Expr[InputTask[T]]): c.Expr[State => Parser[Task[T]]] =
c.universe.reify(t.splice.parser)
def parsedInputMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[Task[T]] =
def parsedInputMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[Task[T]] =
ContextUtil.selectMacroImpl[Task[T]](c) { (p, pos) =>
p.tree.tpe match {
case tpe if tpe <:< c.weakTypeOf[InputTask[T]] => wrapInputTask[T](c)(p.tree, pos)
@ -278,21 +265,21 @@ object ParserInput:
}
private def wrapInputTask[T: c.WeakTypeTag](
c: blackbox.Context
using qctx: Quotes
)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[InputTask[T]](tree)
wrap[Task[T]](c)(inputParser(c)(e), pos)
}
private def wrapInitInputTask[T: c.WeakTypeTag](
c: blackbox.Context
using qctx: Quotes
)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[Initialize[InputTask[T]]](tree)
wrapInit[Task[T]](c)(c.universe.reify { Def.toIParser(e.splice) }, pos)
}
/** Implements `Parser[T].parsed` by wrapping the Parser with the ParserInput wrapper. */
def parsedMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[T] =
def parsedMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[T] =
ContextUtil.selectMacroImpl[T](c) { (p, pos) =>
p.tree.tpe match {
case tpe if tpe <:< c.weakTypeOf[Parser[T]] => wrapParser[T](c)(p.tree, pos)
@ -304,20 +291,20 @@ object ParserInput:
}
}
private def wrapParser[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
private def wrapParser[T: c.WeakTypeTag](using qctx: Quotes)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[Parser[T]](tree)
wrap[T](c)(c.universe.reify { Def.toSParser(e.splice) }, pos)
}
private def wrapInitParser[T: c.WeakTypeTag](
c: blackbox.Context
using qctx: Quotes
)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[Initialize[Parser[T]]](tree)
val es = c.universe.reify { Def.toISParser(e.splice) }
wrapInit[T](c)(es, pos)
}
private def unexpectedType(c: blackbox.Context)(pos: c.Position, tpe: c.Type, label: String) =
private def unexpectedType(using qctx: Quotes)(pos: c.Position, tpe: c.Type, label: String) =
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.dealias} in $label.")
*/

View File

@ -73,16 +73,11 @@ object TaskMacro:
// import LinterDSL.{ Empty => EmptyLinter }
def taskMacroImpl[A1: Type](t: Expr[A1])(using qctx: Quotes): Expr[Initialize[Task[A1]]] =
// import qctx.reflect.*
t match
case '{ if ($cond) then $thenp else $elsep } => mkIfS[A1](t)
case _ =>
val convert1: Convert[qctx.type] = new FullConvert(qctx)
convert1.contMapN[A1, F, Id](t, convert1.idTransform)
// Instance.contImpl[A1, Id](c, FullInstance, FullConvert, MixedBuilder, TaskLinterDSL)(
// Left(t),
// Instance.idTransform[c.type]
// )
def mkIfS[A1: Type](using
qctx: Quotes

View File

@ -7,6 +7,7 @@
package sbt
/*
object AppendSpec {
val onLoad = SettingKey[State => State]("onLoad")
@ -29,3 +30,4 @@ object AppendSpec {
Global / onLoad += (() => doSideEffect())
Global / onLoad += (() => println("foo"))
}
*/

View File

@ -7,6 +7,7 @@
package sbt.test
/*
import org.scalacheck.{ Test => _, _ }, Arbitrary.arbitrary, Gen._
import java.io.File
@ -133,3 +134,4 @@ object BuildSettingsInstances {
implicit def arbScoped[A: Manifest]: Arbitrary[Scoped] = Arbitrary(arbitrary[Key])
}
*/

View File

@ -7,6 +7,7 @@
package sbt
/*
import org.scalatest.flatspec.AnyFlatSpec
import sbt.internal.util.{ AttributeKey, AttributeMap }
import sbt.io.syntax.file
@ -75,3 +76,4 @@ class ScopeDisplaySpec extends AnyFlatSpec {
it should "LocalRootProject" in assert(disp(LocalRootProject) == "<root> /")
it should "ThisProject" in assert(disp(ThisProject) == "<this> /")
}
*/

View File

@ -7,6 +7,7 @@
package sbt.test
/*
import org.scalacheck._, Prop._, util.Pretty
import sbt.internal.util.AttributeKey
@ -143,3 +144,4 @@ object ScopedSpec extends Properties("Scoped") {
s"Expected $act to NOT be equal to $exp"
}
}
*/

View File

@ -7,6 +7,7 @@
package sbt.test
/*
import org.scalacheck.{ Test => _, _ }, Prop._
import sbt.SlashSyntax
@ -109,3 +110,4 @@ object SlashSyntaxSpec extends Properties("SlashSyntax") with SlashSyntax {
if (equals) proved else falsified :| s"Expected $expected but got $x"
}
}
*/

View File

@ -7,6 +7,7 @@
package sbt.test
/*
import java.io.File
import sjsonnew._, BasicJsonProtocol._
import sbt.Def.{ Setting, inputKey, settingKey, taskKey }
@ -62,3 +63,4 @@ object SlashSyntaxTest extends sbt.SlashSyntax {
libraryDependencies += uTest % Test,
)
}
*/

View File

@ -7,6 +7,7 @@
package sbt.test
/*
import sbt._
import sbt.Def.Initialize
import sbt.TupleSyntax._
@ -16,3 +17,4 @@ object TupleSyntaxTest {
(a, b, c.toTaskable, d.toTaskable).map((x: T, y: T, z: T, w: T) => "" + x + y + z + w)
}
}
*/

View File

@ -7,6 +7,7 @@
package sbt.std
/*
import org.scalatest.{ TestData, fixture, funsuite }
import sbt.std.TestUtil._
@ -75,3 +76,4 @@ class TaskConfigSpec extends funsuite.FixtureAnyFunSuite with fixture.TestDataFi
assert(toolbox.infos.isEmpty)
}
}
*/

View File

@ -7,6 +7,7 @@
package sbt.std
/*
class TaskPosSpec {
// Starting sbt 1.4.0, Def.task can have task value lookups inside
// if branches since tasks with single if-expressions are automatically
@ -204,3 +205,4 @@ class TaskPosSpec {
withKey(bar)
}
}
*/

View File

@ -7,6 +7,7 @@
package sbt.std
/*
import org.scalatest.TestData
import scala.tools.reflect.ToolBox
@ -29,3 +30,4 @@ object TestUtil {
case _ => throw new IllegalStateException("No classpath specified.")
}
}
*/

View File

@ -28,7 +28,14 @@ import sbt.{ Def, InputTask, Task }
object Assign {
import java.io.File
import Def.{ Initialize, inputKey, macroValueT, parserToInput, settingKey, taskKey }
import sbt.std.FullInstance.given
import Def.{
Initialize,
inputKey,
// macroValueT, parserToInput,
settingKey,
taskKey
}
// import UseTask.{x,y,z,a,set,plain}
val ak = taskKey[Int]("a")
@ -51,74 +58,74 @@ object Assign {
/* def azy = sk.value
def azy2 = appmacro.Debug.checkWild(Def.task{ sk.value.size })
def azy2 = appmacro.Debug.checkWild(Def.task{ sk.value.size })
val settings = Seq(
ak += z.value + (if(y.value) set.value else plain.value),
ck := new File(ck.value, "asdf"),
ak := sk.value.size,
bk ++= Seq(z.value)
)*/
val settings = Seq(
ak += z.value + (if(y.value) set.value else plain.value),
ck := new File(ck.value, "asdf"),
ak := sk.value.size,
bk ++= Seq(z.value)
)*/
val zz = Def.task {
mk.value + tk.value + mk.value + tk.value + mk.value + tk.value + mk.value + tk.value + mk.value + tk.value + mk.value + tk.value
}
import DefaultParsers._
val p = Def.setting { name.value ~> Space ~> ID }
val is = Seq(
mk := 3,
name := "asdf",
tk := (math.random() * 1000).toInt,
isk := dummys.value.parsed // should not compile: cannot use a task to define the parser
// ik := { if( tsk.parsed.value == "blue") tk.value else mk.value }
)
// import DefaultParsers._
// val p = Def.setting { name.value ~> Space ~> ID }
// val is = Seq(
// mk := 3,
// name := "asdf",
// tk := (math.random() * 1000).toInt,
// isk := dummys.value.parsed // should not compile: cannot use a task to define the parser
// // ik := { if( tsk.parsed.value == "blue") tk.value else mk.value }
// )
val it1 = Def.inputTask {
tsk.parsed // "as" //dummy.value.parsed
}
val it2 = Def.inputTask {
"lit"
}
// val it1 = Def.inputTask {
// tsk.parsed // "as" //dummy.value.parsed
// }
// val it2 = Def.inputTask {
// "lit"
// }
val it3: Initialize[InputTask[String]] = Def.inputTask[String] {
tsk.parsed.value + itsk.parsed.value.toString + isk.evaluated
}
// should not compile: cannot use a task to define the parser
/* val it4 = Def.inputTask {
dummyt.value.parsed
}*/
// should compile: can use a setting to define the parser
val it5 = Def.inputTask {
dummys.parsed
}
val it6 = Def.inputTaskDyn {
val d3 = dummy3.parsed
val i = d3._2
Def.task { tk.value + i }
}
// val it3: Initialize[InputTask[String]] = Def.inputTask[String] {
// tsk.parsed.value + itsk.parsed.value.toString + isk.evaluated
// }
// // should not compile: cannot use a task to define the parser
// /* val it4 = Def.inputTask {
// dummyt.value.parsed
// }*/
// // should compile: can use a setting to define the parser
// val it5 = Def.inputTask {
// dummys.parsed
// }
// val it6 = Def.inputTaskDyn {
// val d3 = dummy3.parsed
// val i = d3._2
// Def.task { tk.value + i }
// }
val it7 = Def.inputTask {
it5.parsed
}
// val it7 = Def.inputTask {
// it5.parsed
// }
def bool: Initialize[Boolean] = Def.setting { true }
def enabledOnly[T](key: Initialize[T]): Initialize[Seq[T]] = Def.setting {
val keys: Seq[T] = forallIn(key).value
val enabled: Seq[Boolean] = forallIn(bool).value
(keys zip enabled) collect { case (a, true) => a }
}
def forallIn[T](key: Initialize[T]): Initialize[Seq[T]] = Def.setting {
key.value :: Nil
}
// def bool: Initialize[Boolean] = Def.setting { true }
// def enabledOnly[T](key: Initialize[T]): Initialize[Seq[T]] = Def.setting {
// val keys: Seq[T] = forallIn(key).value
// val enabled: Seq[Boolean] = forallIn(bool).value
// (keys zip enabled) collect { case (a, true) => a }
// }
// def forallIn[T](key: Initialize[T]): Initialize[Seq[T]] = Def.setting {
// key.value :: Nil
// }
// Test that Append.Sequence instances for Seq/List work and don't mess up with each other
seqSetting := Seq("test1")
seqSetting ++= Seq("test2")
seqSetting ++= List("test3")
seqSetting += "test4"
// // Test that Append.Sequence instances for Seq/List work and don't mess up with each other
// seqSetting := Seq("test1")
// seqSetting ++= Seq("test2")
// seqSetting ++= List("test3")
// seqSetting += "test4"
listSetting := List("test1")
listSetting ++= List("test2")
listSetting += "test4"
// listSetting := List("test1")
// listSetting ++= List("test2")
// listSetting += "test4"
}

View File

@ -7,6 +7,7 @@
package sbt.std.neg
/*
import scala.tools.reflect.ToolBoxError
import org.scalatest.{ TestData, fixture, funsuite }
import sbt.std.{ TaskLinterDSLFeedback, TestUtil }
@ -305,7 +306,7 @@ class TaskNegSpec extends funsuite.FixtureAnyFunSuite with fixture.TestDataFixtu
""".stripMargin
}
}
*/
*/
test("Detect a missing `.value` inside an inner method of a task") { implicit td =>
expectError(TaskLinterDSLFeedback.missingValueForKey("fooNeg3")) {
@ -380,5 +381,6 @@ class TaskNegSpec extends funsuite.FixtureAnyFunSuite with fixture.TestDataFixtu
""".stripMargin
}
}
*/
*/
}
*/