diff --git a/main/settings/src/main/scala/sbt/Def.scala b/main/settings/src/main/scala/sbt/Def.scala index 3e984c030..31c3eac88 100644 --- a/main/settings/src/main/scala/sbt/Def.scala +++ b/main/settings/src/main/scala/sbt/Def.scala @@ -50,7 +50,7 @@ object Def extends Init[Scope] with TaskMacroExtra import language.experimental.macros import std.TaskMacro.{inputTaskMacroImpl, inputTaskDynMacroImpl, taskDynMacroImpl, taskMacroImpl} import std.SettingMacro.{settingDynMacroImpl,settingMacroImpl} - import std.{MacroValue, ParserInput} + import std.{InputEvaluated, MacroValue, ParserInput} def task[T](t: T): Def.Initialize[Task[T]] = macro taskMacroImpl[T] def taskDyn[T](t: Def.Initialize[Task[T]]): Def.Initialize[Task[T]] = macro taskDynMacroImpl[T] @@ -64,7 +64,7 @@ object Def extends Init[Scope] with TaskMacroExtra implicit def macroValueI[T](in: Initialize[T]): MacroValue[T] = ??? implicit def macroValueIT[T](in: Initialize[Task[T]]): MacroValue[T] = ??? - implicit def macroValueIInT[T](in: Initialize[InputTask[T]]): MacroValue[T] = ??? + implicit def macroValueIInT[T](in: Initialize[InputTask[T]]): InputEvaluated[T] = ??? // The following conversions enable the types Parser[T], Initialize[Parser[T]], and Initialize[State => Parser[T]] to // be used in the inputTask macro as an input with an ultimate result of type T @@ -80,7 +80,7 @@ object Def extends Init[Scope] with TaskMacroExtra trait TaskMacroExtra { implicit def macroValueT[T](in: Task[T]): std.MacroValue[T] = ??? - implicit def macroValueIn[T](in: InputTask[T]): std.MacroValue[T] = ??? + implicit def macroValueIn[T](in: InputTask[T]): std.InputEvaluated[T] = ??? implicit def parserToInput[T](in: Parser[T]): std.ParserInput[T] = ??? implicit def stateParserToInput[T](in: State => Parser[T]): std.ParserInput[T] = ??? } \ No newline at end of file diff --git a/main/settings/src/main/scala/sbt/std/InputWrapper.scala b/main/settings/src/main/scala/sbt/std/InputWrapper.scala index c1629e6b7..7644d3f2a 100644 --- a/main/settings/src/main/scala/sbt/std/InputWrapper.scala +++ b/main/settings/src/main/scala/sbt/std/InputWrapper.scala @@ -98,6 +98,10 @@ sealed abstract class ParserInput[T] { @compileTimeOnly("`parsed` can only be used within an input task macro, such as := or Def.inputTask.") def parsed: T = macro ParserInput.parsedMacroImpl[T] } +sealed abstract class InputEvaluated[T] { + @compileTimeOnly("`evaluated` can only be used within an input task macro, such as := or Def.inputTask.") + def evaluated: T = macro InputWrapper.valueMacroImpl[T] +} sealed abstract class ParserInputTask[T] { @compileTimeOnly("`parsed` can only be used within an input task macro, such as := or Def.inputTask.") def parsed: Task[T] = macro ParserInput.parsedInputMacroImpl[T] diff --git a/src/sphinx/Extending/Input-Tasks.rst b/src/sphinx/Extending/Input-Tasks.rst index 037bf1421..7dc68efb1 100644 --- a/src/sphinx/Extending/Input-Tasks.rst +++ b/src/sphinx/Extending/Input-Tasks.rst @@ -151,13 +151,13 @@ Using other input tasks ======================= The types involved in an input task are composable, so it is possible to reuse input tasks. -The ``.parsed`` and ``.value`` methods are defined on InputTasks to make this more convenient in common situations: +The ``.parsed`` and ``.`` methods are defined on InputTasks to make this more convenient in common situations: - * Call ``.parsed`` on an ``InputTask[T]`` or ``Initialize[InputTask[T]]`` to get the ``Task[T]`` created by that input task - * Call ``.value`` on an ``InputTask[T]`` or ``Initialize[InputTask[T]]`` to get the final value of type ``T`` for that input task + * Call ``.parsed`` on an ``InputTask[T]`` or ``Initialize[InputTask[T]]`` to get the ``Task[T]`` created after parsing the command line + * Call ``.evaluated`` on an ``InputTask[T]`` or ``Initialize[InputTask[T]]`` to get the value of type ``T`` from evaluating that task In both situations, the underlying ``Parser`` is sequenced with other parsers in the input task definition. -In the case of ``.value``, the generated task is evaluated. +In the case of ``.evaluated``, the generated task is evaluated. The following example applies the ``run`` input task, a literal separator parser ``--``, and ``run`` again. The parsers are sequenced in order of syntactic appearance, @@ -171,9 +171,9 @@ so that the arguments before ``--`` are passed to the first ``run`` and the ones val separator: Parser[String] = "--" run2 := { - val one = (run in Compile).value + val one = (run in Compile).evaluated val sep = separator.parsed - val two = (run in Compile).value + val two = (run in Compile).evaluated } For a main class Demo that echoes its arguments, this looks like: @@ -226,8 +226,8 @@ NOTE: the current implementation of ``:=`` doesn't actually support applying inp val separator: Parser[String] = "--" run2 := { - val one = (run in Compile).fullInput(firstInput.value).value - val two = (run in Compile).partialInput(secondInput).value + val one = (run in Compile).fullInput(firstInput.value).evaluated + val two = (run in Compile).partialInput(secondInput).evaluated } For a main class Demo that echoes its arguments, this looks like: