diff --git a/core-macros/src/main/scala/sbt/internal/util/appmacro/Instance.scala b/core-macros/src/main/scala/sbt/internal/util/appmacro/Instance.scala index f077ed5ab..5c15a3346 100644 --- a/core-macros/src/main/scala/sbt/internal/util/appmacro/Instance.scala +++ b/core-macros/src/main/scala/sbt/internal/util/appmacro/Instance.scala @@ -187,7 +187,9 @@ object Instance { qual.foreach(checkQual) val vd = util.freshValDef(tpe, qual.pos, functionSym) inputs ::= new Input(tpe, qual, vd) - util.refVal(selection, vd) + // try to workaround https://github.com/scala/bug/issues/12112 by calling Predef.identity(...) + val rv = util.refVal(selection, vd) + q"scala.Predef.identity[$tpe]($rv: $tpe)" } def sub(name: String, tpe: Type, qual: Tree, replace: Tree): Converted[c.type] = { val tag = c.WeakTypeTag[T](tpe) diff --git a/sbt/src/sbt-test/project/setting-macro/project/PureExpressionPlugin.scala b/sbt/src/sbt-test/project/setting-macro/project/PureExpressionPlugin.scala new file mode 100644 index 000000000..f0eea984b --- /dev/null +++ b/sbt/src/sbt-test/project/setting-macro/project/PureExpressionPlugin.scala @@ -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 + } + } +} diff --git a/sbt/src/sbt-test/project/setting-macro/project/plugins.sbt b/sbt/src/sbt-test/project/setting-macro/project/plugins.sbt new file mode 100644 index 000000000..9674e9d5f --- /dev/null +++ b/sbt/src/sbt-test/project/setting-macro/project/plugins.sbt @@ -0,0 +1 @@ +Compile / scalacOptions += "-Xfatal-warnings"