Skip to content

Commit 332b465

Browse files
authored
Update Scala to 2.13 and other dependencies (#1354)
1 parent d969cd2 commit 332b465

30 files changed

+241
-226
lines changed

.github/workflows/ci.yml

+15-11
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
os: [ubuntu-latest]
27-
scala: [2.11.12, 2.12.15, 2.13.8]
28-
java: [adopt@1.8]
27+
scala: [2.11.12, 2.12.17, 2.13.11]
28+
java: [temurin@8]
2929
platform: [jvm, js, native]
3030
runs-on: ${{ matrix.os }}
3131
steps:
@@ -34,10 +34,12 @@ jobs:
3434
with:
3535
fetch-depth: 0
3636

37-
- name: Setup Java and Scala
38-
uses: olafurpg/setup-scala@v10
37+
- name: Setup Java (temurin@8)
38+
if: matrix.java == 'temurin@8'
39+
uses: actions/setup-java@v2
3940
with:
40-
java-version: ${{ matrix.java }}
41+
distribution: temurin
42+
java-version: 8
4143

4244
- name: Cache sbt
4345
uses: actions/cache@v2
@@ -75,19 +77,21 @@ jobs:
7577
strategy:
7678
matrix:
7779
os: [ubuntu-latest]
78-
scala: [2.13.8]
79-
java: [adopt@1.8]
80+
scala: [2.13.11]
81+
java: [temurin@8]
8082
runs-on: ${{ matrix.os }}
8183
steps:
8284
- name: Checkout current branch (full)
8385
uses: actions/checkout@v2
8486
with:
8587
fetch-depth: 0
8688

87-
- name: Setup Java and Scala
88-
uses: olafurpg/setup-scala@v10
89+
- name: Setup Java (temurin@8)
90+
if: matrix.java == 'temurin@8'
91+
uses: actions/setup-java@v2
8992
with:
90-
java-version: ${{ matrix.java }}
93+
distribution: temurin
94+
java-version: 8
9195

9296
- name: Cache sbt
9397
uses: actions/cache@v2
@@ -108,4 +112,4 @@ jobs:
108112
PGP_SECRET: ${{ secrets.PGP_SECRET }}
109113
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
110114
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
111-
run: sbt ++${{ matrix.scala }} ci-release
115+
run: sbt ++${{ matrix.scala }} ci-release

.github/workflows/clean.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ jobs:
5656
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
5757
ghapi -X DELETE $REPO/actions/artifacts/$id
5858
done
59-
done
59+
done

build.sbt

+31-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import com.typesafe.sbt.SbtGit.GitKeys._
2-
import com.typesafe.tools.mima.core._
1+
import com.typesafe.sbt.SbtGit.GitKeys.*
2+
import com.typesafe.tools.mima.core.*
33
import sbtcrossproject.CrossPlugin.autoImport.crossProject
44
import sbtcrossproject.CrossProject
55

66
val Scala211 = "2.11.12"
7-
val Scala212 = "2.12.15"
8-
val Scala213 = "2.13.8"
7+
val Scala212 = "2.12.17"
8+
val Scala213 = "2.13.11"
99

1010
commonSettings
1111
noPublishSettings
@@ -20,7 +20,7 @@ ThisBuild / versionScheme := Some("pvp")
2020
// GHA configuration
2121

2222
ThisBuild / githubWorkflowBuildPreamble := Seq(WorkflowStep.Run(List("sudo apt install clang libunwind-dev libgc-dev libre2-dev")))
23-
ThisBuild / githubWorkflowJavaVersions := Seq("[email protected]")
23+
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"))
2424
ThisBuild / githubWorkflowArtifactUpload := false
2525
ThisBuild / githubWorkflowBuildMatrixAdditions += "platform" -> List("jvm", "js", "native")
2626
ThisBuild / githubWorkflowBuildMatrixFailFast := Some(false)
@@ -71,27 +71,38 @@ val scalacOptionsAll = Seq(
7171
"-unchecked",
7272
)
7373

74-
val scalacOptions212 = Seq(
75-
"-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,_",
76-
"-Ywarn-unused:-implicits"
74+
val scalacCompileOptions = Map(
75+
"2.12" -> Seq(
76+
"-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,_",
77+
"-Ywarn-unused:-implicits",
78+
),
79+
"2.13" -> Seq(
80+
"-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,-byname-implicit,_",
81+
"-Wunused:-implicits",
82+
"-Wconf:msg=shadowing a nested class of a parent is deprecated:s",
83+
),
7784
)
7885

79-
val scalacOptions213 = Seq(
80-
"-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,-byname-implicit,_",
81-
"-Ywarn-unused:-implicits",
82-
"-Wconf:msg=shadowing a nested class of a parent is deprecated:s"
86+
val scalacTestOptions = Map(
87+
"2.12" -> Seq(
88+
"-Xlint:-infer-any",
89+
"-Ywarn-unused:-locals,-privates",
90+
),
91+
"2.13" -> Seq(
92+
"-Xlint:-infer-any",
93+
"-Wunused:-locals,-privates",
94+
// Symbol.unapply returns Option
95+
"-Wconf:cat=other-implicit-type:s,cat=other-match-analysis&src=*/lazy.scala:s",
96+
),
8397
)
8498

8599
lazy val commonSettings = crossVersionSharedSources ++ Seq(
86100
resolvers ++= Resolver.sonatypeOssRepos("releases"),
87101
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
88102
incOptions := incOptions.value.withLogRecompileOnMacro(false),
89103
scalacOptions := scalacOptionsAll,
90-
Compile / compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
91-
case Some((2, 12)) => scalacOptions212
92-
case Some((2, 13)) => scalacOptions213
93-
case _ => Nil
94-
}),
104+
Compile / scalacOptions ++= scalacCompileOptions.getOrElse(scalaBinaryVersion.value, Nil),
105+
Test / scalacOptions ++= scalacTestOptions.getOrElse(scalaBinaryVersion.value, Nil),
95106
Compile / console / scalacOptions -= "-Xfatal-warnings",
96107
Test / console / scalacOptions -= "-Xfatal-warnings",
97108
console / initialCommands := """import shapeless._""",
@@ -182,17 +193,18 @@ lazy val examples = crossProject(JSPlatform, JVMPlatform, NativePlatform)
182193
.configureCross(configureJUnit)
183194
.dependsOn(core)
184195
.settings(moduleName := "examples")
185-
.settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.1.1")
196+
.settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.2.0")
186197
.settings(runAllIn(Compile))
187198
.settings(commonSettings)
188199
.settings(noPublishSettings)
200+
.settings(scalacOptions ++= scalacTestOptions.getOrElse(scalaBinaryVersion.value, Nil))
189201
.nativeSettings(Compile / sources ~= (_.filterNot(_.getName == "sexp.scala")))
190202

191203
lazy val examplesJVM = examples.jvm
192204
lazy val examplesJS = examples.js
193205
lazy val examplesNative = examples.native
194206

195-
lazy val crossVersionSharedSources: Seq[Setting[_]] =
207+
lazy val crossVersionSharedSources: Seq[Setting[?]] =
196208
Seq(Compile, Test).map { sc =>
197209
(sc / unmanagedSourceDirectories) ++= {
198210
(sc / unmanagedSourceDirectories).value.flatMap { dir: File =>

core/jvm/src/test/scala/shapeless/lazy.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616

1717
package shapeless
1818

19-
import scala.language.reflectiveCalls
20-
2119
import org.junit.Test
22-
import org.junit.Assert._
20+
21+
import scala.language.reflectiveCalls
2322

2423
class LazyStrictTestsJVM {
2524

core/jvm/src/test/scala/shapeless/serialization.scala

+15-17
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,23 @@
1616

1717
package shapeless
1818

19-
import java.io._
20-
21-
import org.junit.Test
2219
import org.junit.Assert._
20+
import org.junit.Test
21+
import shapeless.labelled._
22+
import shapeless.nat._
23+
import shapeless.ops.function._
24+
import shapeless.ops.nat._
25+
import shapeless.ops.traversable._
26+
import shapeless.poly.~>>
27+
import shapeless.record._
28+
import shapeless.serializationtestutils._
29+
import shapeless.syntax.singleton._
30+
import shapeless.syntax.std.TupleOps
31+
import shapeless.syntax.zipper._
32+
import shapeless.syntax._
33+
import shapeless.union._
2334

24-
import labelled._
25-
import nat._
26-
import ops.function._
27-
import ops.nat._
28-
import ops.traversable._
29-
import poly.{ ~>> }
30-
import record._
31-
import syntax.{ CoproductOps, GenericZipperOps, HListOps, HListZipperOps, NatOps, RecordOps, TypeableOps, UnionOps }
32-
import syntax.std.TupleOps
33-
import syntax.singleton._
34-
import syntax.zipper._
35-
import test._
36-
import serializationtestutils._
37-
import union._
35+
import java.io._
3836

3937
object SerializationTestDefns {
4038

core/shared/src/main/scala/shapeless/generic.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ trait CaseClassMacros extends ReprTypes with CaseClassMacrosVersionSpecifics {
959959
val repWCard = Star(wildcard)
960960

961961
def narrow(tree: Tree, tpe: Type): Tree = tpe match {
962-
case ConstantType(c) => q"$c.asInstanceOf[$tpe]"
962+
case ConstantType(const) => q"$const.asInstanceOf[$tpe]"
963963
case _ => tree
964964
}
965965

core/shared/src/main/scala/shapeless/generic1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class Generic1Macros(val c: whitebox.Context) extends CaseClassMacros {
207207
def mkGeneric1Impl[T[_], FR[_[_]]](implicit tTag: WeakTypeTag[T[_]], frTag: WeakTypeTag[FR[Any]]): Tree = {
208208
val tpe = tTag.tpe.etaExpand
209209
val frTpe = c.openImplicits.headOption match {
210-
case Some(ImplicitCandidate(_, _, TypeRef(_, _, List(_, tpe)), _)) => tpe
210+
case Some(ImplicitCandidate(_, _, TypeRef(_, _, List(_, frTpe)), _)) => frTpe
211211
case _ => frTag.tpe.typeConstructor
212212
}
213213

core/shared/src/main/scala/shapeless/hlistconstraints.scala

+44-15
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ object BasisConstraint {
7272
type λ[L <: HList] = BasisConstraint[L, M]
7373
}
7474

75-
implicit def hnilBasis[M <: HList] = new BasisConstraint[HNil, M] {}
76-
implicit def hlistBasis[H, T <: HList, M <: HList](implicit bct : BasisConstraint[T, M], sel : Selector[M, H]) =
75+
implicit def hnilBasis[M <: HList]: BasisConstraint[HNil, M] =
76+
new BasisConstraint[HNil, M] {}
77+
78+
implicit def hlistBasis[H, T <: HList, M <: HList](implicit
79+
bct: BasisConstraint[T, M],
80+
sel: Selector[M, H]
81+
): BasisConstraint[H :: T, M] =
7782
new BasisConstraint[H :: T, M] {}
7883
}
7984

@@ -89,8 +94,13 @@ object LUBConstraint {
8994
type λ[L <: HList] = LUBConstraint[L, B]
9095
}
9196

92-
implicit def hnilLUB[T] = new LUBConstraint[HNil, T] {}
93-
implicit def hlistLUB[H, T <: HList, B](implicit bct : LUBConstraint[T, B], ev: H <:< B) =
97+
implicit def hnilLUB[T]: LUBConstraint[HNil, T] =
98+
new LUBConstraint[HNil, T] {}
99+
100+
implicit def hlistLUB[H, T <: HList, B](implicit
101+
bct: LUBConstraint[T, B],
102+
ev: H <:< B
103+
): LUBConstraint[H :: T, B] =
94104
new LUBConstraint[H :: T, B] {}
95105
}
96106

@@ -108,9 +118,14 @@ object KeyConstraint {
108118
type λ[L <: HList] = KeyConstraint[L, M]
109119
}
110120

111-
implicit def hnilKeys[M <: HList] = new KeyConstraint[HNil, M] {}
112-
implicit def hlistKeys[K, V, T <: HList, M <: HList]
113-
(implicit bct : KeyConstraint[T, M], sel : Selector[M, K]) = new KeyConstraint[FieldType[K, V] :: T, M] {}
121+
implicit def hnilKeys[M <: HList]: KeyConstraint[HNil, M] =
122+
new KeyConstraint[HNil, M] {}
123+
124+
implicit def hlistKeys[K, V, T <: HList, M <: HList](implicit
125+
bct: KeyConstraint[T, M],
126+
sel: Selector[M, K]
127+
): KeyConstraint[FieldType[K, V] :: T, M] =
128+
new KeyConstraint[FieldType[K, V] :: T, M] {}
114129
}
115130

116131
/**
@@ -127,9 +142,14 @@ object ValueConstraint {
127142
type λ[L <: HList] = ValueConstraint[L, M]
128143
}
129144

130-
implicit def hnilValues[M <: HList] = new ValueConstraint[HNil, M] {}
131-
implicit def hlistValues[K, V, T <: HList, M <: HList]
132-
(implicit bct : ValueConstraint[T, M], sel : Selector[M, V]) = new ValueConstraint[FieldType[K, V] :: T, M] {}
145+
implicit def hnilValues[M <: HList]: ValueConstraint[HNil, M] =
146+
new ValueConstraint[HNil, M] {}
147+
148+
implicit def hlistValues[K, V, T <: HList, M <: HList](implicit
149+
bct: ValueConstraint[T, M],
150+
sel: Selector[M, V]
151+
): ValueConstraint[FieldType[K, V] :: T, M] =
152+
new ValueConstraint[FieldType[K, V] :: T, M] {}
133153
}
134154

135155
/**
@@ -146,8 +166,13 @@ object NotContainsConstraint {
146166
type λ[L <: HList] = NotContainsConstraint[L, U]
147167
}
148168

149-
implicit def hnilNotContains[U] = new NotContainsConstraint[HNil, U] {}
150-
implicit def hlistNotContains[H, T <: HList, U](implicit nc: T NotContainsConstraint U, neq: U =:!= H) =
169+
implicit def hnilNotContains[U]: NotContainsConstraint[HNil, U] =
170+
new NotContainsConstraint[HNil, U] {}
171+
172+
implicit def hlistNotContains[H, T <: HList, U](implicit
173+
nc: T NotContainsConstraint U,
174+
neq: U =:!= H
175+
): NotContainsConstraint[H :: T, U] =
151176
new NotContainsConstraint[H :: T, U] {}
152177
}
153178

@@ -161,8 +186,12 @@ object IsDistinctConstraint {
161186

162187
def apply[L <: HList](implicit idc: IsDistinctConstraint[L]): IsDistinctConstraint[L] = idc
163188

164-
implicit def hnilIsDistinct = new IsDistinctConstraint[HNil] {}
165-
implicit def hlistIsDistinct[H, T <: HList](implicit d: IsDistinctConstraint[T],
166-
nc: NotContainsConstraint[T, H]): IsDistinctConstraint[H :: T] =
189+
implicit def hnilIsDistinct: IsDistinctConstraint[HNil] =
190+
new IsDistinctConstraint[HNil] {}
191+
192+
implicit def hlistIsDistinct[H, T <: HList](implicit
193+
d: IsDistinctConstraint[T],
194+
nc: NotContainsConstraint[T, H]
195+
): IsDistinctConstraint[H :: T] =
167196
new IsDistinctConstraint[H :: T] {}
168197
}

0 commit comments

Comments
 (0)