Skip to content

Commit f53b9b8

Browse files
Preparations for Scala 2.13
1 parent cee2a35 commit f53b9b8

File tree

13 files changed

+66
-34
lines changed

13 files changed

+66
-34
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: scala
22
scala:
3-
- 2.12.6
3+
- 2.11.12
4+
- 2.12.7
45
jdk:
56
- openjdk8
67
- oraclejdk8

catnip.sbt

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ lazy val catnip = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure
1515
.setInitialImport("cats.implicits._")
1616
.configureModule
1717
.publish
18-
.settings(addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross sbt.CrossVersion.patch))
1918

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

3937
lazy val catnipTestsJVM = catnipTests.jvm

lock.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
dependencyOverrides ++= Seq(
55

66
)
7-
// LIBRARY_DEPENDENCIES_HASH 0c1ecb84eefded81e31012edb83a33973e7edae4
7+
// LIBRARY_DEPENDENCIES_HASH fdc28634c6c339ea10ce9da391ecaee94ec774d2

modules/catnip-tests/.js/lock.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ dependencyOverrides ++= Seq(
2020
"org.typelevel" % "machinist_sjs0.6_2.12" % "0.6.5",
2121
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
2222
)
23-
// LIBRARY_DEPENDENCIES_HASH 53a6369e0770c15ad470d90546a57e0825f8e5a2
23+
// LIBRARY_DEPENDENCIES_HASH a920cfdde255319e948d05199b843902b066cec3

modules/catnip-tests/.jvm/lock.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ dependencyOverrides ++= Seq(
1313
"org.typelevel" % "machinist_2.12" % "0.6.5",
1414
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
1515
)
16-
// LIBRARY_DEPENDENCIES_HASH c17086026af918499dae1c57e5536983dced8f39
16+
// LIBRARY_DEPENDENCIES_HASH 05d734ce988c78042c9d3924eee3e08f8404af49

modules/catnip-tests/src/test/scala/io/scalaland/catnip/SemiSpec.scala

+12-4
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ class SemiSpec extends Specification {
151151
result1 must not(beEqualTo(result2))
152152
}
153153

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

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

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

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

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

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

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

285293
// when
286294
val result = alleycats.Empty[TestEmpty[String]].empty

modules/catnip/.js/lock.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ dependencyOverrides ++= Seq(
2020
"org.typelevel" % "machinist_sjs0.6_2.12" % "0.6.5",
2121
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
2222
)
23-
// LIBRARY_DEPENDENCIES_HASH 3c6d978973e31cf767d13efdc069b2682bf4808f
23+
// LIBRARY_DEPENDENCIES_HASH 00c53c6e5d924d4cad98ded5d91dd811f6880dc2

modules/catnip/.jvm/lock.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ dependencyOverrides ++= Seq(
1313
"org.typelevel" % "machinist_2.12" % "0.6.5",
1414
"org.typelevel" % "macro-compat_2.12" % "1.1.1"
1515
)
16-
// LIBRARY_DEPENDENCIES_HASH 034fe611c66be1cd21d62f3d943e26ff345738b7
16+
// LIBRARY_DEPENDENCIES_HASH 79ffe92df636aa1d6c286e671daf2fe2f4fa8d65

modules/catnip/src/main/scala/io/scalaland/catnip/internals/DerivedImpl.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.scalaland.catnip.internals
22

33
import scala.language.experimental.macros
44
import scala.reflect.macros.whitebox.Context
5-
import scala.util.Try
5+
import scala.util.{ Failure, Success, Try }
66

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

106106
private[catnip] object DerivedImpl {
107107

108-
private def loadConfig(name: String) =
108+
private def loadConfig(name: String): Either[String, Map[String, (String, List[String])]] =
109109
Try {
110-
111110
scala.io.Source
112111
.fromURL(getClass.getClassLoader.getResources(name).nextElement)
113112
.getLines
@@ -122,11 +121,11 @@ private[catnip] object DerivedImpl {
122121
typeClass.trim -> (generator -> otherRequiredTC)
123122
}
124123
.toMap
125-
}.toEither.left.map {
126-
case _: java.util.NoSuchElementException =>
127-
s"Unable to load $name using ${getClass.getClassLoader}"
128-
case err: Throwable =>
129-
err.getMessage
124+
} match {
125+
case Success(value) => Right(value)
126+
case Failure(_: java.util.NoSuchElementException) =>
127+
Left(s"Unable to load $name using ${getClass.getClassLoader}")
128+
case Failure(err: Throwable) => Left(err.getMessage)
130129
}
131130

132131
private val mappingsE: Either[String, Map[String, (String, List[String])]] = loadConfig("derive.semi.conf")

project/Dependencies.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ object Dependencies {
99

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

1515
// build tools version
1616
val scalaFmtVersion = "1.5.1"
1717

1818
// libraries versions
1919
val catsVersion = "1.3.1"
20-
val monixVersion = "3.0.0-RC1"
2120
val specs2Version = "4.3.4"
2221

2322
// resolvers

project/Settings.scala

+33-6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ object Settings extends Dependencies {
3838
"-language:implicitConversions",
3939
"-language:postfixOps",
4040
// private options
41+
"-Xexperimental",
42+
"-Ymacro-annotations",
4143
"-Yno-adapted-args",
4244
"-Ypartial-unification",
4345
// warnings
@@ -75,6 +77,29 @@ object Settings extends Dependencies {
7577
"-Xlint:stars-align",
7678
"-Xlint:type-parameter-shadow",
7779
"-Xlint:unsound-match"
80+
).filterNot(
81+
(if (scalaVersion.value.startsWith("2.13")) Set(
82+
// removed in 2.13.x
83+
"-Yno-adapted-args",
84+
"-Ypartial-unification",
85+
// only for 2.11.x
86+
"-Xexperimental"
87+
) else if (scalaVersion.value.startsWith("2.12")) Set(
88+
// added in 2.13.x
89+
"-Ymacro-annotations",
90+
// only for 2.11.x
91+
"-Xexperimental"
92+
) else if (scalaVersion.value.startsWith("2.11")) Set(
93+
// added in 2.13.x
94+
"-Ymacro-annotations",
95+
// added in 2.12.x
96+
"-Ywarn-extra-implicit",
97+
"-Ywarn-macros:after",
98+
"-Ywarn-unused:implicits",
99+
"-Ywarn-unused:patvars",
100+
"-Ywarn-unused:privates",
101+
"-Xlint:constant"
102+
) else Set.empty[String]).contains _
78103
),
79104
console / scalacOptions --= Seq(
80105
// warnings
@@ -111,10 +136,13 @@ object Settings extends Dependencies {
111136
Wart.Nothing,
112137
Wart.ToString
113138
)
114-
) ++ mainDeps
139+
) ++ mainDeps ++ Seq(libraryDependencies ++= (if (!scalaVersion.value.startsWith("2.13")) {
140+
Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross sbt.CrossVersion.patch))
141+
} else {
142+
Nil
143+
}))
115144

116145
private val publishSettings = Seq(
117-
organization := "io.scalaland",
118146
homepage := Some(url("https://scalaland.io")),
119147
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
120148
scmInfo := Some(
@@ -132,20 +160,19 @@ object Settings extends Dependencies {
132160
pomIncludeRepository := { _ =>
133161
false
134162
},
135-
pomExtra := (
163+
pomExtra :=
136164
<developers>
137165
<developer>
138166
<id>krzemin</id>
139167
<name>Piotr Krzemiński</name>
140-
<url>http://github.com/krzemin</url>
168+
<url>https://github.com/krzemin</url>
141169
</developer>
142170
<developer>
143171
<id>MateuszKubuszok</id>
144172
<name>Mateusz Kubuszok</name>
145-
<url>http://github.com/MateuszKubuszok</url>
173+
<url>https://github.com/MateuszKubuszok</url>
146174
</developer>
147175
</developers>
148-
)
149176
)
150177

151178
private val noPublishSettings =

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.1
1+
sbt.version=1.2.3

scripts/sbt

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ set -o pipefail
99
declare -r sbt_release_version="0.13.17"
1010
declare -r sbt_unreleased_version="0.13.17"
1111

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

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

2929
declare sbt_jar sbt_dir sbt_create sbt_version sbt_script sbt_new

0 commit comments

Comments
 (0)