mirror of https://github.com/sbt/sbt.git
Merge 887c65620b into b3b1a3477e
This commit is contained in:
commit
750c57541a
|
|
@ -664,6 +664,10 @@ lazy val coreMacrosProj = (project in file("core-macros"))
|
|||
name := "Core Macros",
|
||||
SettingKey[Boolean]("exportPipelining") := false,
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Seq(
|
||||
exclude[ReversedMissingMethodProblem]("sbt.internal.util.appmacro.ContextUtil.*"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.internal.util.appmacro.ContextUtil#Input.*"),
|
||||
),
|
||||
)
|
||||
|
||||
// Fixes scope=Scope for Setting (core defined in collectionProj) to define the settings system used in build definitions
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ trait Cont:
|
|||
.asExprOf[BuildWideCacheConfiguration]
|
||||
inputs.foreach: input =>
|
||||
if !input.isCacheInput then
|
||||
if !Cont.transientAllowSet(input.sym.name) then
|
||||
if !Cont.transientAllowSet(input.sym.name) && !input.isWarnSuppressed then
|
||||
report.warning(
|
||||
s"transient key ${input.sym.name} is excluded from the cache input"
|
||||
)
|
||||
|
|
@ -430,6 +430,7 @@ trait Cont:
|
|||
|
||||
val WrapOutputName = "wrapOutput_\u2603\u2603"
|
||||
val WrapOutputDirectoryName = "wrapOutputDirectory_\u2603\u2603"
|
||||
var nowarnQuals: Set[String] = Set.empty
|
||||
// Called when transforming the tree to add an input.
|
||||
// For `qual` of type F[A], and a `selection` qual.value.
|
||||
val record = [a] =>
|
||||
|
|
@ -470,12 +471,18 @@ trait Cont:
|
|||
}.asTerm)
|
||||
case None => oldTree
|
||||
case _ =>
|
||||
// todo cache opt-out attribute
|
||||
inputBuf += Input(TypeRepr.of[a], qual, replacement, freshName("q"))
|
||||
inputBuf += Input(
|
||||
TypeRepr.of[a],
|
||||
qual,
|
||||
replacement,
|
||||
freshName("q"),
|
||||
isWarnSuppressed = nowarnQuals.contains(qual.show),
|
||||
)
|
||||
oldTree
|
||||
}
|
||||
val exprWithConfig =
|
||||
cacheConfigExprOpt.map(config => '{ $config; $expr }).getOrElse(expr)
|
||||
nowarnQuals = collectNowarnQuals(exprWithConfig.asTerm)
|
||||
val body = transformWrappers(exprWithConfig.asTerm, record, Symbol.spliceOwner)
|
||||
val r = inputBuf.toList match
|
||||
case Nil => pure(body)
|
||||
|
|
|
|||
|
|
@ -76,11 +76,13 @@ trait ContextUtil[C <: Quotes & scala.Singleton](val valStart: Int):
|
|||
|
||||
private val cacheLevelSym = Symbol.requiredClass("sbt.util.cacheLevel")
|
||||
private val transientSym = Symbol.requiredClass("scala.transient")
|
||||
private val nowarnAnnotSym = Symbol.requiredClass("scala.annotation.nowarn")
|
||||
final class Input(
|
||||
val tpe: TypeRepr,
|
||||
val qual: Term,
|
||||
val term: Term,
|
||||
val name: String,
|
||||
val isWarnSuppressed: Boolean,
|
||||
):
|
||||
override def toString: String =
|
||||
s"Input($tpe, $qual, $term, $name, $tags)"
|
||||
|
|
@ -194,6 +196,28 @@ trait ContextUtil[C <: Quotes & scala.Singleton](val valStart: Int):
|
|||
|
||||
def idTransform[F[_]]: TermTransform[F] = in => in
|
||||
|
||||
/** Collects `qual.show` for each `.value` call wrapped in `@nowarn`, e.g. `(state.value: @nowarn)`. */
|
||||
def collectNowarnQuals(tree: Term): Set[String] =
|
||||
val result = mutable.HashSet[String]()
|
||||
@tailrec def extractQual(t: Term): Unit = t match
|
||||
case Inlined(_, _, inner) => extractQual(inner)
|
||||
case Typed(inner, _) => extractQual(inner)
|
||||
case Apply(TypeApply(Select(_, _), _ :: Nil), qual :: Nil) => result += qual.show
|
||||
case Apply(TypeApply(Ident(_), _ :: Nil), qual :: Nil) => result += qual.show
|
||||
case _ => ()
|
||||
object scanner extends TreeTraverser:
|
||||
override def traverseTree(t: Tree)(owner: Symbol): Unit = t match
|
||||
case Typed(inner, tpt) =>
|
||||
tpt.tpe match
|
||||
case AnnotatedType(_, annot) if annot.tpe.typeSymbol == nowarnAnnotSym =>
|
||||
extractQual(inner)
|
||||
case _ =>
|
||||
super.traverseTree(t)(owner)
|
||||
case _ => super.traverseTree(t)(owner)
|
||||
end scanner
|
||||
scanner.traverseTree(tree)(Symbol.spliceOwner)
|
||||
result.toSet
|
||||
|
||||
def collectDefs(tree: Term, isWrapper: (String, TypeRepr, Term) => Boolean): Set[Symbol] =
|
||||
val defs = mutable.HashSet[Symbol]()
|
||||
object traverser extends TreeTraverser:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
import scala.annotation.nowarn
|
||||
|
||||
lazy val check = taskKey[Unit]("")
|
||||
check := {
|
||||
val s = (state.value: @nowarn)
|
||||
println("hi")
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Compile / scalacOptions += "-Werror"
|
||||
|
|
@ -0,0 +1 @@
|
|||
> about
|
||||
Loading…
Reference in New Issue