mirror of https://github.com/sbt/sbt.git
Fix "-Yrangepos" disappearing from Test / scalacOptions
Fixes https://github.com/sbt/sbt/issues/5934 In #5886 adpi2 reported that Test / scalacOptions could have unwanted duplicated flags from Compile / scalacOptions. So #5887 added ```diff + // remove duplicated semanticdbOptions + scalacOptions --= (Compile / semanticdbOptions).value ``` Notice that it's subtracting (Compile / semanticdbOptions).value regardless of the semanticdbEnabled value. If semanticdbEnabled is set to true I am guessing that it would all work out, but when it's false, it's just subtracting "-Yrangepos". This fixes that by checking for semanticdbEnabled.
This commit is contained in:
parent
6c6df88d1e
commit
5495524e60
|
|
@ -70,9 +70,11 @@ object SemanticdbPlugin extends AutoPlugin {
|
||||||
targetRootOptions(scalaVersion.value, semanticdbTargetRoot.value),
|
targetRootOptions(scalaVersion.value, semanticdbTargetRoot.value),
|
||||||
scalacOptions --= Def.settingDyn {
|
scalacOptions --= Def.settingDyn {
|
||||||
val config = configuration.value
|
val config = configuration.value
|
||||||
Def.setting {
|
val enabled = semanticdbEnabled.value
|
||||||
semanticdbOptions.?.all(ancestorConfigs(config)).value.flatten.flatten
|
if (enabled)
|
||||||
}
|
Def.setting {
|
||||||
|
semanticdbOptions.?.all(ancestorConfigs(config)).value.flatten.flatten
|
||||||
|
} else Def.setting { Nil }
|
||||||
}.value,
|
}.value,
|
||||||
scalacOptions ++= {
|
scalacOptions ++= {
|
||||||
if (semanticdbEnabled.value)
|
if (semanticdbEnabled.value)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
ThisBuild / scalaVersion := "2.12.12"
|
||||||
|
|
||||||
|
lazy val munit = "org.scalameta" %% "munit" % "0.7.22"
|
||||||
|
|
||||||
|
lazy val root = (project in file("."))
|
||||||
|
.settings(
|
||||||
|
Compile / scalacOptions += "-Yrangepos",
|
||||||
|
libraryDependencies += munit % Test,
|
||||||
|
testFrameworks += new TestFramework("munit.Framework"),
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package testpkg
|
||||||
|
|
||||||
|
import munit._
|
||||||
|
|
||||||
|
class ClueSuite extends FunSuite {
|
||||||
|
val x = 42
|
||||||
|
val y = 32
|
||||||
|
checkPrint(
|
||||||
|
"clues",
|
||||||
|
clues(x, y),
|
||||||
|
"""|Clues {
|
||||||
|
| x: Int = 42
|
||||||
|
| y: Int = 32
|
||||||
|
|}
|
||||||
|
|""".stripMargin
|
||||||
|
)
|
||||||
|
|
||||||
|
val z: List[Int] = List(1)
|
||||||
|
checkPrint(
|
||||||
|
"list",
|
||||||
|
clues(z),
|
||||||
|
"""|Clues {
|
||||||
|
| z: List[Int] = List(
|
||||||
|
| 1
|
||||||
|
| )
|
||||||
|
|}
|
||||||
|
|""".stripMargin
|
||||||
|
)
|
||||||
|
|
||||||
|
def checkPrint(
|
||||||
|
options: TestOptions,
|
||||||
|
clues: Clues,
|
||||||
|
expected: String
|
||||||
|
)(implicit loc: Location): Unit = {
|
||||||
|
test(options) {
|
||||||
|
val obtained = munitPrint(clues)
|
||||||
|
assertNoDiff(obtained, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> test
|
||||||
Loading…
Reference in New Issue