Skip to content

Commit

Permalink
support parsing scala 2.13.6 -Xsource:3 dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
github-brice-jaglin committed May 18, 2021
1 parent 806f649 commit 1b0b73c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ object ScalafixPlugin extends AutoPlugin {
Arg.Config(scalafixConf),
Arg.Rules(shell.rules),
Arg.ScalaVersion(scalaVersion.value),
Arg.ScalacOptions(scalacOptions.in(config, compile).value),
Arg.ParsedArgs(shell.extra)
)
val rulesThatWillRun = mainInterface.rulesThatWillRun()
Expand Down Expand Up @@ -427,17 +428,16 @@ object ScalafixPlugin extends AutoPlugin {
val dependencies = allDependencies.in(config).value
val files = filesToFix(shellArgs, config).value
val scalacOpts = scalacOptions.in(config, compile).value
val withScalaInterface = mainArgs.withArgs(Arg.ScalacOptions(scalacOpts))
val errors = new SemanticRuleValidator(
new SemanticdbNotFound(ruleNames, scalaVersion.value)
).findErrors(files, dependencies, scalacOpts, withScalaInterface)
).findErrors(files, dependencies, scalacOpts, mainArgs)
if (errors.isEmpty) {
val task = Def.task {
// don't use fullClasspath as it results in a cyclic dependency via compile when scalafixOnCompile := true
val classpath =
dependencyClasspath.in(config).value.map(_.data.toPath) :+
classDirectory.in(config).value.toPath
val semanticInterface = withScalaInterface.withArgs(
val semanticInterface = mainArgs.withArgs(
Arg.Paths(files),
Arg.Classpath(classpath)
)
Expand Down
4 changes: 3 additions & 1 deletion src/sbt-test/sbt-1.5/testkit/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ lazy val tests = projectMatrix
.customRow(
scalaVersions = Seq(V.scala213),
axisValues = Seq(InputAxis(V.scala213), VirtualAxis.jvm),
settings = Seq()
settings = Seq(
scalacOptions += "-Xsource:3"
)
)
.customRow(
scalaVersions = Seq(V.scala212),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
rules = [ SemanticRule ]
*/
package fix

open class Source3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package fix

open class Source3
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-1.5/testkit/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-> tests/test
> testsInput3/test:run --save-expect
> testsInput2_13/test:run --save-expect
> tests/test
3 changes: 3 additions & 0 deletions src/sbt-test/sbt-scalafix/cross-build/213.scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules = [
ProcedureSyntax
]
12 changes: 11 additions & 1 deletion src/sbt-test/sbt-scalafix/cross-build/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ lazy val root = project
javaProject,
scala211,
scala210,
scala212
scala212,
scala213
)

lazy val scala210 = project.settings(
Expand All @@ -42,6 +43,15 @@ lazy val scala212 = project
)
.settings(scalafixConfigSettings(IntegrationTest): _*)

lazy val scala213 = project.settings(
scalaVersion := Versions.scala213,
scalacOptions += "-Xsource:3",
scalafixSettings,
// NoAutoTupling is not supported
scalacOptions -= "-Ywarn-adapted-args",
scalafixConfig := Some(file("213.scalafix.conf"))
)

lazy val javaProject = project.settings(
scalaVersion := Versions.scala212,
scalafixSettings
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open class Source3

0 comments on commit 1b0b73c

Please sign in to comment.