Skip to content

Commit

Permalink
ScalafmtDynamic: download even current build
Browse files Browse the repository at this point in the history
Because the -dynamic module doesn't include the necessary -core.

This is follow-up to scalameta#2839; prior to that change, current had been used
for CliTest with "core" option but that was fixed in scalameta#2873 to detect the
current build and use the core runner.
  • Loading branch information
kitbellew committed Nov 11, 2021
1 parent 2778b8c commit 599a293
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,8 @@ final case class ScalafmtDynamic(
): FormatEval[ScalafmtReflectConfig] = {
for {
version <- readVersion(configPath)
current = ScalafmtReflect.current
fmtReflect <-
if (version == current.version) Right(current)
else resolveFormatter(configPath, version)
// can't use current build directly, -dynamic doesn't include -core
fmtReflect <- resolveFormatter(configPath, version)
config <- fmtReflect.parseConfig(configPath).toEither.left.map {
case ex: ScalafmtDynamicError => ex
case ex => new UnknownConfigError(configPath, ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,3 @@ case class ScalafmtReflect(
module.get(null)
}
}

object ScalafmtReflect {

lazy val current = ScalafmtReflect(
getClass.getClassLoader,
ScalafmtVersion.parse(BuildInfo.stable).get
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -439,19 +439,6 @@ class DynamicSuite extends FunSuite {
assert(!configWithoutRewrites.hasRewriteRules)
}

check("invalid config in current") { f =>
f.setConfig(
s"""|version=${BuildInfo.stable}
|align=does-not-exist
|""".stripMargin
)
val thrown = f.assertThrows[ScalafmtDynamicError.ConfigParseError]()
assert(thrown.getMessage.startsWith("Invalid config:"))
assert(
thrown.getMessage.contains(".scalafmt.conf:2:0 error: Type mismatch;")
)
}

check("invalid config in 3.0.0-RC6") { f =>
f.setConfig(
s"""|version=3.0.0-RC6
Expand Down

0 comments on commit 599a293

Please sign in to comment.