Skip to content

Commit

Permalink
Scala 2.13 support (#77)
Browse files Browse the repository at this point in the history
* initial port to 2.13.0-M4

* rebase, bump to 2.13.0-M5

* -Ywarn-accessible removed from 2.13 build

* -Ywarn-infer-any removed from 2.13 build

* adjust compiler flags to support cross compilation between 2.11 - 2.13

* bump sbt-scoverage to 1.6.0-M5 support Scala 2.13
  • Loading branch information
krzemin authored Nov 21, 2018
1 parent 3b627cd commit 046e4fc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: scala
scala:
- 2.11.12
- 2.12.6
- 2.12.7
- 2.13.0-M5
jdk:
- openjdk8
- openjdk11
Expand Down
36 changes: 19 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,19 @@ val versions = new {
val settings = Seq(
version := "0.2.1",
scalaVersion := versions.scalaVersion,
crossScalaVersions := Seq("2.11.12", "2.12.7"),
crossScalaVersions := Seq("2.11.12", "2.12.7", "2.13.0-M5"),
scalacOptions ++= Seq(
"-target:jvm-1.8",
"-encoding",
"UTF-8",
"-encoding", "UTF-8",
"-unchecked",
"-deprecation",
"-explaintypes",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
"-Ywarn-numeric-widen",
"-Xfatal-warnings",
// "-Xfatal-warnings",
"-Xfuture",
"-Xlint:adapted-args",
"-Xlint:by-name-right-associative",
"-Xlint:delayedinit-select",
"-Xlint:doc-detached",
"-Xlint:inaccessible",
Expand All @@ -42,10 +32,22 @@ val settings = Seq(
"-Xlint:poly-implicit-overload",
"-Xlint:private-shadow",
"-Xlint:stars-align",
"-Xlint:type-parameter-shadow",
"-Xlint:unsound-match",
"-Xexperimental"
),
"-Xlint:type-parameter-shadow"
) ++ (
if (scalaVersion.value >= "2.13")
Nil
else
Seq(
"-Xexperimental",
"-Yno-adapted-args",
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
"-Xlint:by-name-right-associative",
"-Xlint:unsound-match"
)
),
scalacOptions in (Compile, console) --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings")
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait DerivationGuards {
}

def bothOfTraversableOrArray(from: Type, to: Type): Boolean = {
traversableOrArray(from) && traversableOrArray(to)
iterableOrArray(from) && iterableOrArray(to)
}

def destinationCaseClass(to: Type): Boolean = {
Expand All @@ -57,8 +57,8 @@ trait DerivationGuards {
bothSealedClasses(from, to)
}

def traversableOrArray(t: Type): Boolean = {
t <:< traversableTpe || t <:< arrayTpe
def iterableOrArray(t: Type): Boolean = {
t <:< iterableTpe || t <:< arrayTpe
}

val optionTpe: Type = typeOf[Option[_]]
Expand All @@ -68,6 +68,6 @@ trait DerivationGuards {
val leftTpe: Type = typeOf[Left[_, _]]
val rightTpe: Type = typeOf[Right[_, _]]
val mapTpe: Type = typeOf[scala.collection.Map[_, _]]
val traversableTpe: Type = typeOf[Traversable[_]]
val iterableTpe: Type = typeOf[Iterable[_]]
val arrayTpe: Type = typeOf[Array[_]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,19 @@ trait TransformerMacros {
if (fn == innerTransformerTree) {
if (sameCollectionTypes) {
srcPrefixTree
} else if (scala.util.Properties.versionNumberString >= "2.13") {
val ToCompanionRef = patchedCompanionRef(c)(To)
q"$srcPrefixTree.to($ToCompanionRef)"
} else {
q"$srcPrefixTree.to[${To.typeConstructor}]"
}
} else {
val f = q"($fn: $FromCollectionT) => $innerTransformerTree"
if (sameCollectionTypes) {
q"$srcPrefixTree.map($f)"
} else if (scala.util.Properties.versionNumberString >= "2.13") {
val ToCompanionRef = patchedCompanionRef(c)(To)
q"$srcPrefixTree.map($f).to($ToCompanionRef)"
} else {
q"$srcPrefixTree.map($f).to[${To.typeConstructor}]"
}
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0-M5")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.25")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")

Expand Down

0 comments on commit 046e4fc

Please sign in to comment.