mirror of https://github.com/sbt/sbt.git
Merge pull request #5981 from eed3si9n/wip/pure-expression
Work around "a pure expression does nothing" warning
This commit is contained in:
commit
8bea523aea
|
|
@ -312,6 +312,17 @@ final class ContextUtil[C <: blackbox.Context](val ctx: C) {
|
|||
case Converted.Failure(p, m) => ctx.abort(p, m)
|
||||
case _: Converted.NotApplicable[_] => super.transform(tree)
|
||||
}
|
||||
// try to workaround https://github.com/scala/bug/issues/12112 by removing raw Ident(_) in blocks
|
||||
case Block(stats0, expr0) =>
|
||||
val stats = stats0 flatMap { stat0 =>
|
||||
val stat = super.transform(stat0)
|
||||
stat match {
|
||||
case Typed(ident @ Ident(_), _) if ident.symbol.isSynthetic => None
|
||||
case _ => Some(stat)
|
||||
}
|
||||
}
|
||||
val expr = super.transform(expr0)
|
||||
Block(stats, expr).setType(expr.tpe)
|
||||
case _ => super.transform(tree)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package pkgtest
|
||||
|
||||
import sbt._, Keys._
|
||||
|
||||
// https://github.com/scala/bug/issues/12112
|
||||
object PureExpressionPlugin extends AutoPlugin {
|
||||
lazy val testPureExpression = taskKey[Unit]("")
|
||||
override def projectSettings: Seq[Setting[_]] = {
|
||||
testPureExpression := {
|
||||
updateFull.value
|
||||
(Compile / compile).value
|
||||
(Test / test).value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Compile / scalacOptions += "-Xfatal-warnings"
|
||||
Loading…
Reference in New Issue