Skip to content

Commit

Permalink
Preparations for Scala 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKubuszok committed Oct 4, 2018
1 parent cee2a35 commit f53b9b8
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: scala
scala:
- 2.12.6
- 2.11.12
- 2.12.7
jdk:
- openjdk8
- oraclejdk8
Expand Down
4 changes: 1 addition & 3 deletions catnip.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ lazy val catnip = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure
.setInitialImport("cats.implicits._")
.configureModule
.publish
.settings(addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross sbt.CrossVersion.patch))

lazy val catnipJVM = catnip.jvm
.settings(Compile / unmanagedResourceDirectories += baseDirectory.value / "../src/main/resources")
Expand All @@ -32,8 +31,7 @@ lazy val catnipTests = crossProject(JVMPlatform, JSPlatform).crossType(CrossType
.noPublish
.settings(libraryDependencies ++= Seq(
"org.specs2" %%% "specs2-core" % Dependencies.specs2Version % "test",
"org.specs2" %%% "specs2-scalacheck" % Dependencies.specs2Version % "test",
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross sbt.CrossVersion.patch)
"org.specs2" %%% "specs2-scalacheck" % Dependencies.specs2Version % "test"
))

lazy val catnipTestsJVM = catnipTests.jvm
Expand Down
2 changes: 1 addition & 1 deletion lock.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
dependencyOverrides ++= Seq(

)
// LIBRARY_DEPENDENCIES_HASH 0c1ecb84eefded81e31012edb83a33973e7edae4
// LIBRARY_DEPENDENCIES_HASH fdc28634c6c339ea10ce9da391ecaee94ec774d2
2 changes: 1 addition & 1 deletion modules/catnip-tests/.js/lock.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ dependencyOverrides ++= Seq(
"org.typelevel" % "machinist_sjs0.6_2.12" % "0.6.5",
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
)
// LIBRARY_DEPENDENCIES_HASH 53a6369e0770c15ad470d90546a57e0825f8e5a2
// LIBRARY_DEPENDENCIES_HASH a920cfdde255319e948d05199b843902b066cec3
2 changes: 1 addition & 1 deletion modules/catnip-tests/.jvm/lock.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dependencyOverrides ++= Seq(
"org.typelevel" % "machinist_2.12" % "0.6.5",
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
)
// LIBRARY_DEPENDENCIES_HASH c17086026af918499dae1c57e5536983dced8f39
// LIBRARY_DEPENDENCIES_HASH 05d734ce988c78042c9d3924eee3e08f8404af49
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ class SemiSpec extends Specification {
result1 must not(beEqualTo(result2))
}

@Semi(cats.Functor) final case class TestFunctor[A](a: A, b: A)
"generate for cats.Functor" in {
// given
@Semi(cats.Functor) final case class TestFunctor[A](a: A, b: A)
// test class moved outside as a workaround for error in 2.11:
// can't existentially abstract over parameterized type TestFunctor[String]

// when
val result1 = TestFunctor("1", "3").map(_.toInt)
Expand Down Expand Up @@ -181,9 +183,11 @@ class SemiSpec extends Specification {
result2 must beEqualTo(2)
}

@Semi(cats.Traverse) final case class TestTraverse[A](a: A)
"generate for cats.Traverse" in {
// given
@Semi(cats.Traverse) final case class TestTraverse[A](a: A)
// test class moved outside as a workaround for error in 2.11:
// can't existentially abstract over parameterized type TestTraverse[Int]

// when
val result1 = TestTraverse(Option("1")).sequence
Expand Down Expand Up @@ -264,9 +268,11 @@ class SemiSpec extends Specification {
result2 must beEqualTo(TestSemi("ba"))
}

@Semi(cats.SemigroupK, cats.Eq) final case class TestSemiK[A](a: List[A])
"generate for cats.SemigroupK" in {
// given
@Semi(cats.SemigroupK, cats.Eq) final case class TestSemiK[A](a: List[A])
// test class moved outside as a workaround for error in 2.11:
// can't existentially abstract over parameterized type TestSemiK[String]

// when
implicit val a = cats.SemigroupK[TestSemiK].algebra[String]
Expand All @@ -278,9 +284,11 @@ class SemiSpec extends Specification {
result2 must beEqualTo(TestSemiK(List("b", "a")))
}

@Semi(alleycats.Empty) final case class TestEmpty[A](a: A)
"generate for alleycats.Empty" in {
// given
@Semi(alleycats.Empty) final case class TestEmpty[A](a: A)
// test class moved outside as a workaround for error in 2.11:
// can't existentially abstract over parameterized type TestEmpty[String]

// when
val result = alleycats.Empty[TestEmpty[String]].empty
Expand Down
2 changes: 1 addition & 1 deletion modules/catnip/.js/lock.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ dependencyOverrides ++= Seq(
"org.typelevel" % "machinist_sjs0.6_2.12" % "0.6.5",
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
)
// LIBRARY_DEPENDENCIES_HASH 3c6d978973e31cf767d13efdc069b2682bf4808f
// LIBRARY_DEPENDENCIES_HASH 00c53c6e5d924d4cad98ded5d91dd811f6880dc2
2 changes: 1 addition & 1 deletion modules/catnip/.jvm/lock.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dependencyOverrides ++= Seq(
"org.typelevel" % "machinist_2.12" % "0.6.5",
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
)
// LIBRARY_DEPENDENCIES_HASH 034fe611c66be1cd21d62f3d943e26ff345738b7
// LIBRARY_DEPENDENCIES_HASH 79ffe92df636aa1d6c286e671daf2fe2f4fa8d65
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.scalaland.catnip.internals

import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
import scala.util.Try
import scala.util.{ Failure, Success, Try }

private[catnip] class DerivedImpl(config: Map[String, (String, List[String])])(val c: Context)(annottees: Seq[Any])
extends Loggers {
Expand Down Expand Up @@ -105,9 +105,8 @@ private[catnip] class DerivedImpl(config: Map[String, (String, List[String])])(v

private[catnip] object DerivedImpl {

private def loadConfig(name: String) =
private def loadConfig(name: String): Either[String, Map[String, (String, List[String])]] =
Try {

scala.io.Source
.fromURL(getClass.getClassLoader.getResources(name).nextElement)
.getLines
Expand All @@ -122,11 +121,11 @@ private[catnip] object DerivedImpl {
typeClass.trim -> (generator -> otherRequiredTC)
}
.toMap
}.toEither.left.map {
case _: java.util.NoSuchElementException =>
s"Unable to load $name using ${getClass.getClassLoader}"
case err: Throwable =>
err.getMessage
} match {
case Success(value) => Right(value)
case Failure(_: java.util.NoSuchElementException) =>
Left(s"Unable to load $name using ${getClass.getClassLoader}")
case Failure(err: Throwable) => Left(err.getMessage)
}

private val mappingsE: Either[String, Map[String, (String, List[String])]] = loadConfig("derive.semi.conf")
Expand Down
5 changes: 2 additions & 3 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ object Dependencies {

// scala version
val scalaOrganization = "org.scala-lang" // "org.typelevel"
val scalaVersion = "2.12.6" // "2.12.4-bin-typelevel-4"
val crossScalaVersions = Seq("2.12.6")
val scalaVersion = "2.12.7" // "2.12.4-bin-typelevel-4"
val crossScalaVersions = Seq("2.11.12", "2.12.7", "2.13.0-M4")

// build tools version
val scalaFmtVersion = "1.5.1"

// libraries versions
val catsVersion = "1.3.1"
val monixVersion = "3.0.0-RC1"
val specs2Version = "4.3.4"

// resolvers
Expand Down
39 changes: 33 additions & 6 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ object Settings extends Dependencies {
"-language:implicitConversions",
"-language:postfixOps",
// private options
"-Xexperimental",
"-Ymacro-annotations",
"-Yno-adapted-args",
"-Ypartial-unification",
// warnings
Expand Down Expand Up @@ -75,6 +77,29 @@ object Settings extends Dependencies {
"-Xlint:stars-align",
"-Xlint:type-parameter-shadow",
"-Xlint:unsound-match"
).filterNot(
(if (scalaVersion.value.startsWith("2.13")) Set(
// removed in 2.13.x
"-Yno-adapted-args",
"-Ypartial-unification",
// only for 2.11.x
"-Xexperimental"
) else if (scalaVersion.value.startsWith("2.12")) Set(
// added in 2.13.x
"-Ymacro-annotations",
// only for 2.11.x
"-Xexperimental"
) else if (scalaVersion.value.startsWith("2.11")) Set(
// added in 2.13.x
"-Ymacro-annotations",
// added in 2.12.x
"-Ywarn-extra-implicit",
"-Ywarn-macros:after",
"-Ywarn-unused:implicits",
"-Ywarn-unused:patvars",
"-Ywarn-unused:privates",
"-Xlint:constant"
) else Set.empty[String]).contains _
),
console / scalacOptions --= Seq(
// warnings
Expand Down Expand Up @@ -111,10 +136,13 @@ object Settings extends Dependencies {
Wart.Nothing,
Wart.ToString
)
) ++ mainDeps
) ++ mainDeps ++ Seq(libraryDependencies ++= (if (!scalaVersion.value.startsWith("2.13")) {
Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross sbt.CrossVersion.patch))
} else {
Nil
}))

private val publishSettings = Seq(
organization := "io.scalaland",
homepage := Some(url("https://scalaland.io")),
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
scmInfo := Some(
Expand All @@ -132,20 +160,19 @@ object Settings extends Dependencies {
pomIncludeRepository := { _ =>
false
},
pomExtra := (
pomExtra :=
<developers>
<developer>
<id>krzemin</id>
<name>Piotr Krzemiński</name>
<url>http://github.com/krzemin</url>
<url>https://github.com/krzemin</url>
</developer>
<developer>
<id>MateuszKubuszok</id>
<name>Mateusz Kubuszok</name>
<url>http://github.com/MateuszKubuszok</url>
<url>https://github.com/MateuszKubuszok</url>
</developer>
</developers>
)
)

private val noPublishSettings =
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.1
sbt.version=1.2.3
6 changes: 3 additions & 3 deletions scripts/sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set -o pipefail
declare -r sbt_release_version="0.13.17"
declare -r sbt_unreleased_version="0.13.17"

declare -r latest_213="2.13.0-M4"
declare -r latest_212="2.12.6"
declare -r latest_213="2.13.0-M5"
declare -r latest_212="2.12.7"
declare -r latest_211="2.11.12"
declare -r latest_210="2.10.7"
declare -r latest_29="2.9.3"
Expand All @@ -23,7 +23,7 @@ declare -r sbt_launch_ivy_snapshot_repo="https://repo.scala-sbt.org/scalasbt/ivy
declare -r sbt_launch_mvn_release_repo="http://repo.scala-sbt.org/scalasbt/maven-releases"
declare -r sbt_launch_mvn_snapshot_repo="http://repo.scala-sbt.org/scalasbt/maven-snapshots"

declare -r default_jvm_opts_common="-Xms512m -Xmx1536m -Xss2m"
declare -r default_jvm_opts_common="-Xms512m -Xss2m"
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"

declare sbt_jar sbt_dir sbt_create sbt_version sbt_script sbt_new
Expand Down

0 comments on commit f53b9b8

Please sign in to comment.