mirror of https://github.com/sbt/sbt.git
Shorten fake task macro impl
This commit is contained in:
parent
cabf08e5f0
commit
ea4b38d1b1
|
|
@ -92,15 +92,12 @@ sealed abstract class SettingKey[A1]
|
|||
final inline def ++=[A2](inline vs: A2)(using Append.Values[A1, A2]): Setting[A1] =
|
||||
appendN(settingMacro[A2](vs))
|
||||
|
||||
final def appendN[V](vs: Initialize[V])(using
|
||||
ev: Append.Values[A1, V]
|
||||
): Setting[A1] = make(vs)(ev.appendValues)
|
||||
final def appendN[V](vs: Initialize[V])(using ev: Append.Values[A1, V]): Setting[A1] =
|
||||
make(vs)(ev.appendValues)
|
||||
|
||||
final inline def <+=[A2](inline v: Initialize[A2]): Setting[A1] =
|
||||
${ TaskMacro.fakeSettingAppend1Position[A1, A2]('v) }
|
||||
final inline def <+=[A2](v: Initialize[A2]): Setting[A1] = ${ TaskMacro.fakeAppend1Impl }
|
||||
|
||||
final inline def <++=[A2](inline vs: Initialize[A2]): Setting[A1] =
|
||||
${ TaskMacro.fakeSettingAppendNPosition[A1, A2]('vs) }
|
||||
final inline def <++=[A2](vs: Initialize[A2]): Setting[A1] = ${ TaskMacro.fakeAppendNImpl }
|
||||
|
||||
final inline def -=[A2](inline v: A2)(using Remove.Value[A1, A2]): Setting[A1] =
|
||||
remove1(settingMacro[A2](v))
|
||||
|
|
@ -172,11 +169,11 @@ sealed abstract class TaskKey[A1]
|
|||
ev: Append.Values[A1, A2]
|
||||
): Setting[Task[A1]] = make(vs)(ev.appendValues)
|
||||
|
||||
inline def <+=[A2](inline v: Initialize[Task[A2]]): Setting[Task[A1]] =
|
||||
${ TaskMacro.fakeTaskAppend1Position[A1, A2]('v) }
|
||||
inline def <+=[A2](v: Initialize[Task[A2]]): Setting[Task[A1]] =
|
||||
${ TaskMacro.fakeAppend1Impl }
|
||||
|
||||
inline def <++=[A2](inline vs: Initialize[Task[A2]]): Setting[Task[A1]] =
|
||||
${ TaskMacro.fakeTaskAppendNPosition[A1, A2]('vs) }
|
||||
inline def <++=[A2](vs: Initialize[Task[A2]]): Setting[Task[A1]] =
|
||||
${ TaskMacro.fakeAppendNImpl }
|
||||
|
||||
final inline def -=[A2](v: A2)(using Remove.Value[A1, A2]): Setting[Task[A1]] =
|
||||
remove1[A2](taskMacro[A2](v))
|
||||
|
|
@ -334,8 +331,7 @@ object Scoped:
|
|||
private[sbt] final inline def :==(inline app: A1): Setting[A1] =
|
||||
set(Def.valueStrict(app))
|
||||
|
||||
inline def <<=(inline app: Initialize[A1]): Setting[A1] =
|
||||
${ TaskMacro.fakeSettingAssignImpl('app) }
|
||||
inline def <<=(app: Initialize[A1]): Setting[A1] = ${ TaskMacro.fakeAssignImpl }
|
||||
|
||||
/** In addition to creating Def.setting(...), this captures the source position. */
|
||||
inline def set(inline app: Initialize[A1]): Setting[A1] =
|
||||
|
|
@ -479,8 +475,7 @@ object Scoped:
|
|||
inline def :=(inline a: A1): Setting[Task[A1]] =
|
||||
set(taskMacro(a))
|
||||
|
||||
inline def <<=(inline app: Initialize[Task[A1]]): Setting[Task[A1]] =
|
||||
${ TaskMacro.fakeItaskAssignPosition[A1]('app) }
|
||||
inline def <<=(app: Initialize[Task[A1]]): Setting[Task[A1]] = ${ TaskMacro.fakeAssignImpl }
|
||||
|
||||
/** In addition to creating Def.setting(...), this captures the source position. */
|
||||
inline def set(inline app: Initialize[Task[A1]]): Setting[Task[A1]] =
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ object TaskMacro:
|
|||
final val appendNMigration =
|
||||
"`<++=` operator is removed. Try `lhs ++= { x.value }`\n or see https://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html."
|
||||
final val assignMigration =
|
||||
"""`<<=` operator is removed. Use `key := { x.value }` or `key ~= (old => { newValue })`.
|
||||
"""`<<=` operator is removed. Use `key := { x.value }` or `key ~= {old => newValue }`.
|
||||
|See https://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html""".stripMargin
|
||||
|
||||
type F[x] = Initialize[Task[x]]
|
||||
|
|
@ -105,49 +105,17 @@ object TaskMacro:
|
|||
// Error macros (Restligeist)
|
||||
// These macros are there just so we can fail old operators like `<<=` and provide useful migration information.
|
||||
|
||||
def fakeSettingAssignImpl[A1: Type](app: Expr[Initialize[A1]])(using
|
||||
qctx: Quotes
|
||||
): Expr[Setting[A1]] =
|
||||
import qctx.reflect.*
|
||||
report.errorAndAbort(TaskMacro.assignMigration)
|
||||
def errorAndAbort(message: String)(using quotes: Quotes): Nothing =
|
||||
quotes.reflect.report.errorAndAbort(message)
|
||||
|
||||
def fakeSettingAppend1Position[A1: Type, A2: Type](
|
||||
@deprecated("unused", "") v: Expr[Initialize[A2]]
|
||||
)(using
|
||||
qctx: Quotes
|
||||
): Expr[Setting[A1]] =
|
||||
import qctx.reflect.*
|
||||
report.errorAndAbort(TaskMacro.append1Migration)
|
||||
def fakeAssignImpl(using qctx: Quotes): Nothing =
|
||||
qctx.reflect.report.errorAndAbort(assignMigration)
|
||||
|
||||
def fakeSettingAppendNPosition[A1: Type, A2: Type](
|
||||
@deprecated("unused", "") vs: Expr[Initialize[A2]]
|
||||
)(using
|
||||
qctx: Quotes
|
||||
): Expr[Setting[A1]] =
|
||||
import qctx.reflect.*
|
||||
report.errorAndAbort(TaskMacro.appendNMigration)
|
||||
def fakeAppend1Impl(using qctx: Quotes): Nothing =
|
||||
qctx.reflect.report.errorAndAbort(append1Migration)
|
||||
|
||||
def fakeItaskAssignPosition[A1: Type](
|
||||
@deprecated("unused", "") app: Expr[Initialize[Task[A1]]]
|
||||
)(using qctx: Quotes): Expr[Setting[Task[A1]]] =
|
||||
import qctx.reflect.*
|
||||
report.errorAndAbort(TaskMacro.assignMigration)
|
||||
|
||||
def fakeTaskAppend1Position[A1: Type, A2: Type](
|
||||
@deprecated("unused", "") v: Expr[Initialize[Task[A2]]]
|
||||
)(using
|
||||
qctx: Quotes
|
||||
): Expr[Setting[Task[A1]]] =
|
||||
import qctx.reflect.*
|
||||
report.errorAndAbort(TaskMacro.append1Migration)
|
||||
|
||||
def fakeTaskAppendNPosition[A1: Type, A2: Type](
|
||||
@deprecated("unused", "") vs: Expr[Initialize[Task[A2]]]
|
||||
)(using
|
||||
qctx: Quotes
|
||||
): Expr[Setting[Task[A1]]] =
|
||||
import qctx.reflect.*
|
||||
report.errorAndAbort(TaskMacro.appendNMigration)
|
||||
def fakeAppendNImpl(using qctx: Quotes): Nothing =
|
||||
qctx.reflect.report.errorAndAbort(appendNMigration)
|
||||
|
||||
// Implementations of <<= macro variations for tasks and settings.
|
||||
// These just get the source position of the call site.
|
||||
|
|
|
|||
Loading…
Reference in New Issue