Skip to content

Commit

Permalink
Merge pull request #2 from japgolly/topic/scala3
Browse files Browse the repository at this point in the history
Add Scala 3 support
  • Loading branch information
japgolly authored Jul 30, 2021
2 parents b4de283 + e6b4461 commit 05d6fd7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
fail-fast: false
matrix:
include:
- java: 11
scala: 2.13.6
- java: 16
scala: 2.13.6
- java: 11
scala: 3.0.1

steps:
- name: Git checkout
Expand Down
21 changes: 16 additions & 5 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ object Build {
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-target:11",
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
)

def scalac2Flags = Seq(
"-target:11",
"-Wconf:msg=may.not.be.exhaustive:e", // Make non-exhaustive matches errors instead of warnings
"-Wdead-code", // Warn when dead code is identified.
"-Wunused:explicits", // Warn if an explicit parameter is unused.
Expand Down Expand Up @@ -57,16 +60,24 @@ object Build {
"-Ypatmat-exhaust-depth", "off"
)

def scalac3Flags = Seq(
"-source:3.0-migration",
"-Ykind-projector",
)

val commonSettings = ConfigureBoth(
_.settings(
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseTagComment := s"v${(ThisBuild / version).value}",
releaseVcsSign := true,
scalacOptions ++= scalacCommonFlags,
scalaVersion := Ver.scala2,
crossScalaVersions := Seq(Ver.scala2, Ver.scala3),
scalacOptions ++= scalacCommonFlags,
scalacOptions ++= scalac2Flags.filter(_ => scalaVersion.value.startsWith("2")),
scalacOptions ++= scalac3Flags.filter(_ => scalaVersion.value.startsWith("3")),
Test / scalacOptions --= Seq("-Ywarn-dead-code"),
testFrameworks := Nil,
updateOptions := updateOptions.value.withCachedResolution(true),
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseTagComment := s"v${(ThisBuild / version).value}",
releaseVcsSign := true,
))

def testSettings = ConfigureBoth(
Expand Down
3 changes: 2 additions & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ object Dependencies {
def microlibs = "3.0"
def nyaya = "0.11.0"
def scala2 = "2.13.6"
def scala3 = "3.0.1"
def scalaJsDom = "1.1.0"
def scalaJsReact = "2.0.0-RC2"
def univEq = "1.5.0"
Expand All @@ -33,7 +34,7 @@ object Dependencies {
val nyayaGen = Def.setting("com.github.japgolly.nyaya" %%% "nyaya-gen" % Ver.nyaya)
val nyayaProp = Def.setting("com.github.japgolly.nyaya" %%% "nyaya-prop" % Ver.nyaya)
val nyayaTest = Def.setting("com.github.japgolly.nyaya" %%% "nyaya-test" % Ver.nyaya)
val scalaJsDom = Def.setting("org.scala-js" %%% "scalajs-dom" % Ver.scalaJsDom)
val scalaJsDom = Def.setting("org.scala-js" %%% "scalajs-dom" % Ver.scalaJsDom cross CrossVersion.for3Use2_13)
val scalaJsReactCore = Def.setting("com.github.japgolly.scalajs-react" %%% "core" % Ver.scalaJsReact)
val scalaJsReactExtra = Def.setting("com.github.japgolly.scalajs-react" %%% "extra" % Ver.scalaJsReact)
val scalaJsReactTest = Def.setting("com.github.japgolly.scalajs-react" %%% "test" % Ver.scalaJsReact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ object AjaxProtocol {
res: Protocol.Of[F, _Res]) extends AjaxProtocol[F] {
type Req = _Req
type Res = _Res
override val protocol = Protocol.RequestResponse.simple[F, Req, Res](res)
override val prepReq = req
override val protocol: Protocol.RequestResponse.Simple[F, Req, Res] = Protocol.RequestResponse.simple(res)
override val prepReq = req
override def responseProtocol(req: Req) = res
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ object Protocol {

def apply[F[_], Req, Res](req: Req, res: Protocol.Of[F, Res]): Of[F, Req, Res] =
new PreparedSend[F, Req] {
override val request = req
override val response = res
override val request = req
override val response: Protocol.Of[F, Res] = res
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ object Url {
}

// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
final case class Absolute private[Absolute](absoluteUrl: String) extends AnyVal {
final case class Absolute(absoluteUrl: String) extends AnyVal {
def relativeUrl: Relative =
Relative(absoluteUrl.replaceFirst("^.*?//.+?(?:/|$)", ""))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object EscapeUtilTest extends TestSuite {
val chars = (127 to 255).map(_.toChar).toVector
test(Gen.shuffle(chars).sample().mkString)
}
"unicode" - test(Gen.unicode.map(c => (if (c < 256) c + 1000 else c).toChar).string(128).sample())
"unicode" - test(Gen.unicode.map(c => (if (c < 256) (c + 1000).toChar else c)).string(128).sample())
}
}

Expand Down
11 changes: 8 additions & 3 deletions scalafix.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
if (Lib.scalafixEnabled)
Seq(
ThisBuild / scalacOptions += "-P:semanticdb:synthetics:on",
ThisBuild / scalacOptions += "-Yrangepos",
ThisBuild / semanticdbEnabled := true,
ThisBuild / scalafixScalaBinaryVersion := "2.13",
ThisBuild / semanticdbVersion := "4.4.23",
ThisBuild / semanticdbVersion := "4.4.24",

ThisBuild / scalacOptions ++= {
if (scalaVersion.value startsWith "2")
"-Yrangepos" :: "-P:semanticdb:synthetics:on" :: Nil
else
Nil
},

ThisBuild / scalafixDependencies ++= Seq(
"com.github.liancheng" %% "organize-imports" % "0.5.0"
Expand Down

0 comments on commit 05d6fd7

Please sign in to comment.