Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 2.13.6 & -Xsource:3 support #221

Merged
merged 2 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._

object Dependencies {
val x = List(1) // scalafix:ok
def scalafixVersion: String = "0.9.27+78-f41dec8f-SNAPSHOT"
def scalafixVersion: String = "0.9.27+84-22626c72-SNAPSHOT"

val all = List(
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.11.1.202105131744-r",
Expand Down
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
7 changes: 4 additions & 3 deletions src/sbt-test/sbt-1.5/testkit/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ lazy val rules = projectMatrix

lazy val input = projectMatrix
.defaultAxes(VirtualAxis.jvm)
.jvmPlatform(scalaVersions = Seq(scala3Version))
.jvmPlatform(
scalaVersions = rulesCrossVersions,
scalaVersions = Seq(V.scala213),
settings = Seq(
scalacOptions += "-P:semanticdb:synthetics:on"
Copy link
Collaborator Author

@bjaglin bjaglin May 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force-pushed: this was not used!

scalacOptions += "-Xsource:3"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shows how nice sbt-projectmatrix can be!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. The only thing I am worried about, is if we are the only project that use it. It introduces some new syntax to understand/learn, especially that sbt is usually not something that people master correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule authors shouldn't have to touch anything in projects bootstrapped by scalacenter/scalafix.g8#19 unless they need to disable scala3 testing (which I enabled on purpose). Maybe that's something to discuss on the PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe they want to write only for scala 3. I think it should be easy to remove axes that the authors don't want?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss this on the PR.

)
)
.jvmPlatform(scalaVersions = Seq(scala3Version))
.jvmPlatform(scalaVersions = Seq(V.scala212, V.scala211))

lazy val output = projectMatrix
.defaultAxes(VirtualAxis.jvm)
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
> testsTarget3/test:run --save-expect
> testsTarget2_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 = [
LeakingImplicitClassVal # check that scalacOptions are passed for syntactic rules
]
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,7 @@
open class Source3

object Source3 {
implicit class XtensionVal(val str: String) extends AnyVal {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just amended the last commit yo move this inside an object to avoid

[info] [error] /tmp/sbt_5a68d1e4/cross-build/scala213/src/main/scala/Source3.scala:3:16: XtensionVal is already defined as (compiler-generated) method XtensionVal

def doubled: String = str + str
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class SbtCompletionsSuite extends AnyFunSuite {
|DisableSyntax
| Reports an error for disabled features such as var or XML literals.
|ExplicitResultTypes
| Inserts type annotations for inferred public members. Only compatible with Scala 2.11.12, 2.12.11, 2.12.12, 2.12.13, 2.13.3, 2.13.4, 2.13.5.
| Inserts type annotations for inferred public members. Only compatible with Scala 2.11.12, 2.12.11, 2.12.12, 2.12.13, 2.13.4, 2.13.5, 2.13.6.
|LeakingImplicitClassVal
| Adds 'private' to val parameters of implicit value classes
|NoAutoTupling
Expand Down