Skip to content

Commit

Permalink
update scala 3 version (#271)
Browse files Browse the repository at this point in the history
- also update sclafmt
  • Loading branch information
mlachkar committed Oct 14, 2021
1 parent 8ac3190 commit b300f0d
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
- run: sbt test
# - run: sbt compileScalafixOutputinScala3
- run: sbt compileScalafixOutputinScala3
jdk11:
name: test jdk11
runs-on: ubuntu-latest
Expand All @@ -26,7 +26,7 @@ jobs:
with:
java-version: adopt@1.11
- run: sbt test
# - run: sbt compileScalafixOutputinScala3
- run: sbt compileScalafixOutputinScala3
windows_213:
name: Windows tests
runs-on: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ align.preset = most
align.multiline = false
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
docstrings = JavaDoc
docstrings.style = Asterisk
lineEndings = preserve
includeCurlyBraceInSelectChains = false
danglingParentheses.preset = true
Expand Down
Binary file modified bin/scalafmt
Binary file not shown.
36 changes: 18 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import sbt.Keys.libraryDependencies

inThisBuild(
List(
scalaVersion := V.scala213,
semanticdbEnabled := true,
semanticdbVersion := V.scalameta,
scalaVersion := V.scala213,
semanticdbEnabled := true,
semanticdbVersion := V.scalameta,
scalafixScalaBinaryVersion := V.scala213BinaryVersion,
scalafixDependencies ++= List("com.github.liancheng" %% "organize-imports" % V.organizeImports),
organization := "ch.epfl.scala",
homepage := Some(url("https://github.com/scalacenter/scala3-migrate")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := Developers.list,
homepage := Some(url("https://github.com/scalacenter/scala3-migrate")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := Developers.list,
version ~= { dynVer =>
if (isCI) dynVer
else V.localSnapshotVersion // only for local publishing
Expand All @@ -24,19 +24,19 @@ lazy val `compiler-interfaces` = project
.settings(
scalaVersion := V.scala3,
libraryDependencies ++= Seq("org.scala-lang" %% "scala3-compiler" % V.scala3),
crossPaths := false,
crossPaths := false,
autoScalaLibrary := false,
moduleName := "migrate-compiler-interfaces"
moduleName := "migrate-compiler-interfaces"
)
.dependsOn(`migrate-interfaces`)

lazy val `migrate-interfaces` = project
.in(file("interfaces/migrate"))
.settings(
libraryDependencies ++= Seq("io.get-coursier" % "interface" % V.coursierInterface),
crossPaths := false,
crossPaths := false,
autoScalaLibrary := false,
moduleName := "migrate-core-interfaces"
moduleName := "migrate-core-interfaces"
)

lazy val migrate = project
Expand All @@ -53,8 +53,8 @@ lazy val migrate = project
"org.scalatest" %% "scalatest" % V.scalatest % Test,
"ch.epfl.scala" % "scalafix-testkit" % V.scalafix % Test cross CrossVersion.full
),
Test / test := (Test / test).dependsOn(`scalafix-rules` / publishLocal).value,
Test / testOnly := (Test / testOnly).dependsOn(`scalafix-rules` / publishLocal).evaluated,
Test / test := (Test / test).dependsOn(`scalafix-rules` / publishLocal).value,
Test / testOnly := (Test / testOnly).dependsOn(`scalafix-rules` / publishLocal).evaluated,
Test / buildInfoPackage := "migrate.test",
Test / buildInfoKeys := Seq(
"version" -> version.value,
Expand Down Expand Up @@ -92,7 +92,7 @@ lazy val `sbt-plugin` = project
.enablePlugins(SbtPlugin)
.settings(
scalaVersion := V.scala212,
name := "sbt-scala3-migrate",
name := "sbt-scala3-migrate",
scriptedLaunchOpts ++= Seq(s"-Dplugin.version=${version.value}"),
scriptedDependencies := {
scriptedDependencies
Expand All @@ -104,7 +104,7 @@ lazy val `sbt-plugin` = project
)
.value
},
buildInfoPackage := "migrate",
buildInfoPackage := "migrate",
scriptedBufferLog := false,
buildInfoKeys := Seq[BuildInfoKey](
name,
Expand All @@ -122,8 +122,8 @@ lazy val output = project
.in(file("output"))
.settings(
publish / skip := true,
scalaVersion := V.scala3,
scalacOptions := Seq("-Ykind-projector"),
scalaVersion := V.scala3,
scalacOptions := Seq("-Ykind-projector"),
libraryDependencies ++= Seq("org.typelevel" % "cats-core_2.13" % V.catsCore)
)
.disablePlugins(ScalafixPlugin)
Expand Down Expand Up @@ -157,7 +157,7 @@ lazy val `scalafix-input` = project
lazy val `scalafix-output` = project
.in(file("scalafix/output"))
.settings(
publish / skip := true,
publish / skip := true,
crossScalaVersions := List(V.scala213, V.scala3),
scalacOptions ++= (if (scalaVersion.value.startsWith("3")) Seq("-Ykind-projector") else Seq()),
libraryDependencies ++= {
Expand Down Expand Up @@ -208,7 +208,7 @@ lazy val V = new {
val scala213BinaryVersion = "2.13"
val scala212 = "2.12.14"
val scalatest = "3.2.10"
val scala3 = "3.0.0"
val scala3 = "3.0.2"
val scalafix = "0.9.31"
val scribe = "3.6.0"
val organizeImports = "0.4.3"
Expand Down
19 changes: 12 additions & 7 deletions migrate/src/main/scala/migrate/internal/FileMigration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import migrate.utils.Timer._
import scalafix.interfaces.ScalafixPatch

/**
* Given a [[FileMigrationState]] and a [[Scala3Compiler]], the [[FileMigration]] class
* tries to find the minimum set of patches that makes the code compile
* Given a [[FileMigrationState]] and a [[Scala3Compiler]], the [[FileMigration]] class tries to find the minimum set of
* patches that makes the code compile
*/
private[migrate] class FileMigration(fileToMigrate: FileMigrationState.Initial, compiler: Scala3Compiler) {

Expand Down Expand Up @@ -43,8 +43,10 @@ private[migrate] class FileMigration(fileToMigrate: FileMigrationState.Initial,
/**
* A instance of [[CompilingState]] is a set of patches that are sufficient to make the code compiles.
*
* @param candidates A set of patches that may or may not be necessary
* @param necessaryPatches A set of necessary patches
* @param candidates
* A set of patches that may or may not be necessary
* @param necessaryPatches
* A set of necessary patches
*/
private case class CompilingState(candidates: Seq[ScalafixPatch], necessaryPatches: Seq[ScalafixPatch]) {

Expand Down Expand Up @@ -78,9 +80,12 @@ private[migrate] class FileMigration(fileToMigrate: FileMigrationState.Initial,
/**
* A [[CompilationStep]] is an intermediate step at which we try to compile the code
*
* @param kept The patches that we keep to make the code compile
* @param removed The patches that we try to remove
* @param necessary Some patch that is necessary or none
* @param kept
* The patches that we keep to make the code compile
* @param removed
* The patches that we try to remove
* @param necessary
* Some patch that is necessary or none
*/
private case class CompilationStep(
kept: Seq[ScalafixPatch],
Expand Down
2 changes: 1 addition & 1 deletion output/src/main/scala/migrate/Incompat1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ object Incompat1 {

def inner(foo: Foo): foo.Inner = ???

def bar(f: String => Int): Option[Int] = Some.apply[String](inner(foo)).map(f)
def bar(f: String => Int): Option[Int] = Some(inner(foo)).map(f)
}
}
27 changes: 13 additions & 14 deletions plugin/src/main/scala/migrate/ScalaMigratePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ object ScalaMigratePlugin extends AutoPlugin {
if (actual > migrateScalametaVersion) actual else migrateScalametaVersion
} else semanticdbVersion.value
},
migrationConfigs := migrationConfigsImpl.value,
migrationConfigs / aggregate := false,
storeScala2Inputs := storeScala2InputsImpl.value,
storeScala2Inputs / aggregate := false,
internalMigrateScalacOptions := ScalacOptionsMigration.internalImpl.value,
migrationConfigs := migrationConfigsImpl.value,
migrationConfigs / aggregate := false,
storeScala2Inputs := storeScala2InputsImpl.value,
storeScala2Inputs / aggregate := false,
internalMigrateScalacOptions := ScalacOptionsMigration.internalImpl.value,
internalMigrateScalacOptions / aggregate := false,
internalMigrateSyntax := SyntaxMigration.internalImpl.value,
internalMigrateSyntax / aggregate := false,
internalMigrate := TypeInferenceMigration.internalImpl.value,
internalMigrate / aggregate := false,
internalMigrateLibs := LibsMigration.internalImpl.value,
internalMigrateLibs / aggregate := false,
internalMigrateSyntax := SyntaxMigration.internalImpl.value,
internalMigrateSyntax / aggregate := false,
internalMigrate := TypeInferenceMigration.internalImpl.value,
internalMigrate / aggregate := false,
internalMigrateLibs := LibsMigration.internalImpl.value,
internalMigrateLibs / aggregate := false,
commands ++= Seq(migrateSyntax, migrateScalacOptions, migrateLibDependencies, migrate, fallback),
inConfig(Compile)(configSettings),
inConfig(Test)(configSettings)
Expand Down Expand Up @@ -154,9 +154,8 @@ object ScalaMigratePlugin extends AutoPlugin {
}

/**
* Return all configurations that can be migrated in a project.
* If config A extends config B then B appears first
* ex: List(Compile, Test) because Test extends Runtime which extends Compile
* Return all configurations that can be migrated in a project. If config A extends config B then B appears first ex:
* List(Compile, Test) because Test extends Runtime which extends Compile
*/
private def migrationConfigsImpl = Def.setting {
val project = thisProject.value
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/scala/migrate/SyntaxMigration.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package migrate

import migrate.ScalaMigratePlugin.Keys._
import migrate.ScalaMigratePlugin.{ scala3Version }
import migrate.ScalaMigratePlugin.scala3Version
import ScalaMigratePlugin.migrateAPI

import sbt.Keys._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lazy val subproject = project
lazy val `aggregate-project` = project
.in(file("."))
.settings(TaskKey[Unit]("checkMigration") := {
assert(scalaVersion.value == "3.0.0")
assert(scalaVersion.value == "3.0.2", s"Wrong scala version ${scalaVersion.value}. Expected 3.0.2")
(Compile / compile).value
})
.aggregate(subproject)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.5.3
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % sys.props("plugin.version"))
//addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.1.0-SNAPSHOT")
//addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.4.0-SNAPSHOT")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lazy val `integration-test` = project
// Enable migration on IntegrationTest config
inConfig(IntegrationTest)(Defaults.itSettings ++ ScalaMigratePlugin.configSettings),
TaskKey[Unit]("checkMigration") := {
assert(scalaVersion.value == "3.0.0")
assert(scalaVersion.value == "3.0.2")
(IntegrationTest / compile).value
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lazy val `library-dependencies` = project
else Seq(compilerPlugin("org.typelevel" % "kind-projector" % V.kindProjector cross CrossVersion.full))
},
TaskKey[Unit]("checkMigration") := {
assert(scalaVersion.value == "3.0.0")
assert(scalaVersion.value == "3.0.2", s"Wrong scala version ${scalaVersion.value}. Expected 3.0.2")
(Compile / compile).value
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ lazy val `managed-sources` = project
.settings(
scalaVersion := "2.13.5",
Compile / sourceGenerators += Def.task {
val file = (Compile / sourceManaged).value / "buildinfo" / "BuildInfo.scala"
val file = (Compile / sourceManaged).value / "buildinfo" / "BuildInfo.scala"
val buildInfo = s"""|
|package buildinfo
|
Expand All @@ -15,7 +15,7 @@ lazy val `managed-sources` = project
Seq(file)
},
TaskKey[Unit]("checkMigration") := {
assert(scalaVersion.value == "3.0.0")
assert(scalaVersion.value == "3.0.2", s"Wrong scala version ${scalaVersion.value}. Expected 3.0.2")
(Compile / compile).value
}
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
> migrate-syntax syntax-migration

# check scalaVersion is Scala 3 and compilation succeeds
> set `syntax-migration` / scalaVersion := "3.0.0-RC1"
> set `syntax-migration` / scalaVersion := "3.0.2"
> syntax-migration / Test / compile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ lazy val `type-inference-migration` = project
.settings(
scalaVersion := "2.13.5",
TaskKey[Unit]("checkMigration") := {
assert(scalaVersion.value == "3.0.0")
assert(scalaVersion.value == "3.0.2", s"Wrong scala version ${scalaVersion.value}. Expected 3.0.2")
(Test / compile).value
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ lazy val `unresolved-dependencies` = project
compilerPlugin("org.typelevel" % "kind-projector" % V.kindProjector cross CrossVersion.full)
),
TaskKey[Unit]("checkFallback") := {
assert(scalaVersion.value == V.scala213)
assert(scalaVersion.value == V.scala213, s"Wrong scala version ${scalaVersion.value}. Expected ${V.scala213}")
}
)

Expand Down
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.9")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.9")

0 comments on commit b300f0d

Please sign in to comment.