mirror of https://github.com/sbt/sbt.git
inline parameter removes let binding
This commit is contained in:
parent
b1818b446b
commit
9f5525c989
|
|
@ -261,8 +261,7 @@ trait Cont:
|
||||||
inputBuf += Input(TypeRepr.of[a], qual, replacement, freshName("q"))
|
inputBuf += Input(TypeRepr.of[a], qual, replacement, freshName("q"))
|
||||||
oldTree
|
oldTree
|
||||||
}
|
}
|
||||||
val inlined = inlineExtensionProxy(expr.asTerm)
|
val tx = transformWrappers(expr.asTerm, record, Symbol.spliceOwner)
|
||||||
val tx = transformWrappers(inlined, record, Symbol.spliceOwner)
|
|
||||||
val tr = makeApp(tx, inputBuf.toList)
|
val tr = makeApp(tx, inputBuf.toList)
|
||||||
tr
|
tr
|
||||||
end Cont
|
end Cont
|
||||||
|
|
|
||||||
|
|
@ -67,33 +67,6 @@ trait ContextUtil[C <: Quotes & scala.Singleton](val qctx: C, val valStart: Int)
|
||||||
|
|
||||||
def idTransform[F[_]]: TermTransform[F] = in => in
|
def idTransform[F[_]]: TermTransform[F] = in => in
|
||||||
|
|
||||||
/**
|
|
||||||
* {
|
|
||||||
* val in$proxy264: sbt.Def.Initialize[sbt.Task[sbt.ForkOptions]] = sbt.Defaults.forkOptionsTask
|
|
||||||
* (foo.bar[sbt.ForkOptions](in$proxy264): sbt.ForkOptions)
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @param tree
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
def inlineExtensionProxy(tree: Term): Term =
|
|
||||||
val rhss: mutable.Map[String, Term] = mutable.Map.empty
|
|
||||||
object refTransformer extends TreeMap:
|
|
||||||
override def transformStatement(tree: Statement)(owner: Symbol): Statement =
|
|
||||||
tree match
|
|
||||||
case ValDef(name, tpe, Some(body)) if name.contains("$proxy") =>
|
|
||||||
rhss(name) = body
|
|
||||||
ValDef.copy(tree)(name, tpe, None)
|
|
||||||
case _ =>
|
|
||||||
super.transformStatement(tree)(owner)
|
|
||||||
|
|
||||||
override def transformTerm(tree: Term)(owner: Symbol): Term =
|
|
||||||
tree match
|
|
||||||
case Ident(name) if rhss.contains(name) => rhss(name)
|
|
||||||
case _ => super.transformTerm(tree)(owner)
|
|
||||||
end refTransformer
|
|
||||||
refTransformer.transformTerm(tree)(Symbol.spliceOwner)
|
|
||||||
|
|
||||||
def collectDefs(tree: Term, isWrapper: (String, TypeRepr, Term) => Boolean): Set[Symbol] =
|
def collectDefs(tree: Term, isWrapper: (String, TypeRepr, Term) => Boolean): Set[Symbol] =
|
||||||
val defs = mutable.HashSet[Symbol]()
|
val defs = mutable.HashSet[Symbol]()
|
||||||
object traverser extends TreeTraverser:
|
object traverser extends TreeTraverser:
|
||||||
|
|
|
||||||
|
|
@ -294,10 +294,10 @@ object Def extends Init[Scope] with TaskMacroExtra with InitializeImplicits:
|
||||||
|
|
||||||
// implicit def macroValueI[T](@deprecated("unused", "") in: Initialize[T]): MacroValue[T] = ???
|
// implicit def macroValueI[T](@deprecated("unused", "") in: Initialize[T]): MacroValue[T] = ???
|
||||||
|
|
||||||
extension [A1](in: Initialize[A1])
|
extension [A1](inline in: Initialize[A1])
|
||||||
inline def value: A1 = InputWrapper.`wrapInit_\u2603\u2603`[A1](in)
|
inline def value: A1 = InputWrapper.`wrapInit_\u2603\u2603`[A1](in)
|
||||||
|
|
||||||
extension [A1](in: Initialize[Task[A1]])
|
extension [A1](inline in: Initialize[Task[A1]])
|
||||||
@targetName("valueIA1")
|
@targetName("valueIA1")
|
||||||
inline def value: A1 = InputWrapper.`wrapInitTask_\u2603\u2603`[A1](in)
|
inline def value: A1 = InputWrapper.`wrapInitTask_\u2603\u2603`[A1](in)
|
||||||
|
|
||||||
|
|
@ -314,7 +314,7 @@ object Def extends Init[Scope] with TaskMacroExtra with InitializeImplicits:
|
||||||
inline def flatMapTask[A2](f: A1 => Initialize[Task[A2]]): Initialize[Task[A2]] =
|
inline def flatMapTask[A2](f: A1 => Initialize[Task[A2]]): Initialize[Task[A2]] =
|
||||||
std.FullInstance.initializeTaskMonad.flatMap(in)(f)
|
std.FullInstance.initializeTaskMonad.flatMap(in)(f)
|
||||||
|
|
||||||
extension [A1](in: TaskKey[A1])
|
extension [A1](inline in: TaskKey[A1])
|
||||||
// implicit def macroPrevious[T](@deprecated("unused", "") in: TaskKey[T]): MacroPrevious[T] = ???
|
// implicit def macroPrevious[T](@deprecated("unused", "") in: TaskKey[T]): MacroPrevious[T] = ???
|
||||||
inline def previous(using JsonFormat[A1]): Option[A1] =
|
inline def previous(using JsonFormat[A1]): Option[A1] =
|
||||||
${ TaskMacro.previousImpl[A1]('in) }
|
${ TaskMacro.previousImpl[A1]('in) }
|
||||||
|
|
@ -323,20 +323,20 @@ object Def extends Init[Scope] with TaskMacroExtra with InitializeImplicits:
|
||||||
// Initialize[State => Parser[T]] to be used in the inputTask macro as an input with an ultimate
|
// Initialize[State => Parser[T]] to be used in the inputTask macro as an input with an ultimate
|
||||||
// result of type A1, previously implemented using ParserInput.parsedMacroImpl[A1].
|
// result of type A1, previously implemented using ParserInput.parsedMacroImpl[A1].
|
||||||
|
|
||||||
extension [A1](in: Initialize[Parser[A1]])
|
extension [A1](inline in: Initialize[Parser[A1]])
|
||||||
inline def parsed: A1 = ParserInput.`initParser_\u2603\u2603`[A1](Def.toISParser(in))
|
inline def parsed: A1 = ParserInput.`initParser_\u2603\u2603`[A1](Def.toISParser(in))
|
||||||
|
|
||||||
extension [A1](in: Initialize[State => Parser[A1]])
|
extension [A1](inline in: Initialize[State => Parser[A1]])
|
||||||
@targetName("parsedISPA1")
|
@targetName("parsedISPA1")
|
||||||
inline def parsed: A1 = ParserInput.`initParser_\u2603\u2603`[A1](in)
|
inline def parsed: A1 = ParserInput.`initParser_\u2603\u2603`[A1](in)
|
||||||
|
|
||||||
extension [A1](in: Def.Initialize[InputTask[A1]])
|
extension [A1](inline in: Def.Initialize[InputTask[A1]])
|
||||||
inline def parsed: Task[A1] =
|
inline def parsed: Task[A1] =
|
||||||
ParserInput.`initParser_\u2603\u2603`[Task[A1]](Def.toIParser[A1](in))
|
ParserInput.`initParser_\u2603\u2603`[Task[A1]](Def.toIParser[A1](in))
|
||||||
|
|
||||||
inline def evaluated: A1 = InputWrapper.`wrapInitInputTask_\u2603\u2603`[A1](in)
|
inline def evaluated: A1 = InputWrapper.`wrapInitInputTask_\u2603\u2603`[A1](in)
|
||||||
|
|
||||||
def toTask(arg: String): Initialize[Task[A1]] =
|
inline def toTask(arg: String): Initialize[Task[A1]] =
|
||||||
import TaskExtra.singleInputTask
|
import TaskExtra.singleInputTask
|
||||||
FullInstance.flatten(
|
FullInstance.flatten(
|
||||||
(Def.stateKey zipWith in)((sTask, it) =>
|
(Def.stateKey zipWith in)((sTask, it) =>
|
||||||
|
|
@ -415,16 +415,16 @@ end Def
|
||||||
// because the target doesn't involve Initialize or anything in Def
|
// because the target doesn't involve Initialize or anything in Def
|
||||||
trait TaskMacroExtra:
|
trait TaskMacroExtra:
|
||||||
import sbt.std.ParserInput
|
import sbt.std.ParserInput
|
||||||
extension [A1](in: Task[A1])
|
extension [A1](inline in: Task[A1])
|
||||||
inline def value: A1 = std.InputWrapper.`wrapTask_\u2603\u2603`[A1](in)
|
inline def value: A1 = std.InputWrapper.`wrapTask_\u2603\u2603`[A1](in)
|
||||||
|
|
||||||
// implicit def macroValueIn[T](@deprecated("unused", "") in: InputTask[T]): std.InputEvaluated[T] =
|
// implicit def macroValueIn[T](@deprecated("unused", "") in: InputTask[T]): std.InputEvaluated[T] =
|
||||||
// ???
|
// ???
|
||||||
|
|
||||||
extension [A1](in: Parser[A1])
|
extension [A1](inline in: Parser[A1])
|
||||||
inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](Def.toSParser(in))
|
inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](Def.toSParser(in))
|
||||||
|
|
||||||
extension [A1](in: State => Parser[A1])
|
extension [A1](inline in: State => Parser[A1])
|
||||||
inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](in)
|
inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](in)
|
||||||
end TaskMacroExtra
|
end TaskMacroExtra
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,7 @@ object InputTaskMacro:
|
||||||
)
|
)
|
||||||
|
|
||||||
val inner: convert1.TermTransform[F1] = (in: Term) => f(in.asExprOf[A1]).asTerm
|
val inner: convert1.TermTransform[F1] = (in: Term) => f(in.asExprOf[A1]).asTerm
|
||||||
val inlined = convert1.inlineExtensionProxy(tree.asTerm)
|
val cond = conditionInputTaskTree(tree.asTerm).asExprOf[A1]
|
||||||
val cond = conditionInputTaskTree(inlined).asExprOf[A1]
|
|
||||||
convert1.contMapN[A1, Def.Initialize, F1](cond, convert1.appExpr, inner)
|
convert1.contMapN[A1, Def.Initialize, F1](cond, convert1.appExpr, inner)
|
||||||
|
|
||||||
private[this] def iParserMacro[F1[_]: Type, A1: Type](tree: Expr[A1])(
|
private[this] def iParserMacro[F1[_]: Type, A1: Type](tree: Expr[A1])(
|
||||||
|
|
@ -184,9 +183,8 @@ object InputTaskMacro:
|
||||||
subWrapper(tpe, tree, oldTree)
|
subWrapper(tpe, tree, oldTree)
|
||||||
}
|
}
|
||||||
|
|
||||||
val inlined = convert1.inlineExtensionProxy(expr.asTerm)
|
|
||||||
val tx =
|
val tx =
|
||||||
convert1.transformWrappers(inlined, sub, Symbol.spliceOwner)
|
convert1.transformWrappers(expr.asTerm, sub, Symbol.spliceOwner)
|
||||||
result match {
|
result match {
|
||||||
case Some((p, tpe, param)) =>
|
case Some((p, tpe, param)) =>
|
||||||
val fCore = util.createFunction(param :: Nil, tx, functionSym)
|
val fCore = util.createFunction(param :: Nil, tx, functionSym)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ object Dependencies {
|
||||||
// WARNING: Please Scala update versions in PluginCross.scala too
|
// WARNING: Please Scala update versions in PluginCross.scala too
|
||||||
val scala212 = "2.12.17"
|
val scala212 = "2.12.17"
|
||||||
val scala213 = "2.13.8"
|
val scala213 = "2.13.8"
|
||||||
val scala3 = "3.2.0"
|
val scala3 = "3.2.1"
|
||||||
val checkPluginCross = settingKey[Unit]("Make sure scalaVersion match up")
|
val checkPluginCross = settingKey[Unit]("Make sure scalaVersion match up")
|
||||||
val baseScalaVersion = scala3
|
val baseScalaVersion = scala3
|
||||||
def nightlyVersion: Option[String] =
|
def nightlyVersion: Option[String] =
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
sbt.version=1.7.2
|
sbt.version=1.8.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue