Skip to content

Commit

Permalink
Update Scala to 2.13 and other dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed Apr 26, 2024
1 parent d969cd2 commit b55d031
Show file tree
Hide file tree
Showing 30 changed files with 235 additions and 217 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
scala: [2.11.12, 2.12.15, 2.13.8]
java: [adopt@1.8]
scala: [2.11.12, 2.12.19, 2.13.13]
java: [temurin@8]
platform: [jvm, js, native]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -34,10 +34,12 @@ jobs:
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 8

- name: Cache sbt
uses: actions/cache@v2
Expand Down Expand Up @@ -75,19 +77,21 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8]
java: [adopt@1.8]
scala: [2.13.13]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 8

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -108,4 +112,4 @@ jobs:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ++${{ matrix.scala }} ci-release
run: sbt ++${{ matrix.scala }} ci-release
2 changes: 1 addition & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
ghapi -X DELETE $REPO/actions/artifacts/$id
done
done
done
37 changes: 26 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import com.typesafe.sbt.SbtGit.GitKeys._
import com.typesafe.tools.mima.core._
import com.typesafe.sbt.SbtGit.GitKeys.*
import com.typesafe.tools.mima.core.*
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossProject

val Scala211 = "2.11.12"
val Scala212 = "2.12.15"
val Scala213 = "2.13.8"
val Scala212 = "2.12.19"
val Scala213 = "2.13.13"

commonSettings
noPublishSettings
crossScalaVersions := Nil

ThisBuild / organization := "com.chuusai"
ThisBuild / scalaVersion := Scala213
ThisBuild / scalaVersion := Scala211
ThisBuild / crossScalaVersions := Seq(Scala211, Scala212, Scala213)
ThisBuild / mimaFailOnNoPrevious := false
ThisBuild / versionScheme := Some("pvp")

// GHA configuration

ThisBuild / githubWorkflowBuildPreamble := Seq(WorkflowStep.Run(List("sudo apt install clang libunwind-dev libgc-dev libre2-dev")))
ThisBuild / githubWorkflowJavaVersions := Seq("[email protected]")
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"))
ThisBuild / githubWorkflowArtifactUpload := false
ThisBuild / githubWorkflowBuildMatrixAdditions += "platform" -> List("jvm", "js", "native")
ThisBuild / githubWorkflowBuildMatrixFailFast := Some(false)
Expand Down Expand Up @@ -78,20 +78,31 @@ val scalacOptions212 = Seq(

val scalacOptions213 = Seq(
"-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,-byname-implicit,_",
"-Ywarn-unused:-implicits",
"-Wconf:msg=shadowing a nested class of a parent is deprecated:s"
"-Wunused:-implicits",
"-Wconf:msg=shadowing a nested class of a parent is deprecated:s",
)

val scalacTestOptions213 = Seq(
"-Xlint:-infer-any,-named-booleans",
"-Wunused:-locals,-privates",
// Symbol.unapply returns Option
"-Wconf:cat=other-implicit-type:s,cat=other-match-analysis&src=*/lazy.scala:s",
)

lazy val commonSettings = crossVersionSharedSources ++ Seq(
resolvers ++= Resolver.sonatypeOssRepos("releases"),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
incOptions := incOptions.value.withLogRecompileOnMacro(false),
scalacOptions := scalacOptionsAll,
Compile / compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
Compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => scalacOptions212
case Some((2, 13)) => scalacOptions213
case _ => Nil
}),
Test / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => scalacTestOptions213
case _ => Nil
}),
Compile / console / scalacOptions -= "-Xfatal-warnings",
Test / console / scalacOptions -= "-Xfatal-warnings",
console / initialCommands := """import shapeless._""",
Expand Down Expand Up @@ -182,17 +193,21 @@ lazy val examples = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.configureCross(configureJUnit)
.dependsOn(core)
.settings(moduleName := "examples")
.settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.1.1")
.settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.2.0")
.settings(runAllIn(Compile))
.settings(commonSettings)
.settings(noPublishSettings)
.nativeSettings(Compile / sources ~= (_.filterNot(_.getName == "sexp.scala")))
.settings(scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => scalacTestOptions213
case _ => Nil
}))

lazy val examplesJVM = examples.jvm
lazy val examplesJS = examples.js
lazy val examplesNative = examples.native

lazy val crossVersionSharedSources: Seq[Setting[_]] =
lazy val crossVersionSharedSources: Seq[Setting[?]] =
Seq(Compile, Test).map { sc =>
(sc / unmanagedSourceDirectories) ++= {
(sc / unmanagedSourceDirectories).value.flatMap { dir: File =>
Expand Down
5 changes: 2 additions & 3 deletions core/jvm/src/test/scala/shapeless/lazy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

package shapeless

import scala.language.reflectiveCalls

import org.junit.Test
import org.junit.Assert._

import scala.language.reflectiveCalls

class LazyStrictTestsJVM {

Expand Down
32 changes: 15 additions & 17 deletions core/jvm/src/test/scala/shapeless/serialization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,23 @@

package shapeless

import java.io._

import org.junit.Test
import org.junit.Assert._
import org.junit.Test
import shapeless.labelled._
import shapeless.nat._
import shapeless.ops.function._
import shapeless.ops.nat._
import shapeless.ops.traversable._
import shapeless.poly.~>>
import shapeless.record._
import shapeless.serializationtestutils._
import shapeless.syntax.singleton._
import shapeless.syntax.std.TupleOps
import shapeless.syntax.zipper._
import shapeless.syntax._
import shapeless.union._

import labelled._
import nat._
import ops.function._
import ops.nat._
import ops.traversable._
import poly.{ ~>> }
import record._
import syntax.{ CoproductOps, GenericZipperOps, HListOps, HListZipperOps, NatOps, RecordOps, TypeableOps, UnionOps }
import syntax.std.TupleOps
import syntax.singleton._
import syntax.zipper._
import test._
import serializationtestutils._
import union._
import java.io._

object SerializationTestDefns {

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/shapeless/generic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ trait CaseClassMacros extends ReprTypes with CaseClassMacrosVersionSpecifics {
val repWCard = Star(wildcard)

def narrow(tree: Tree, tpe: Type): Tree = tpe match {
case ConstantType(c) => q"$c.asInstanceOf[$tpe]"
case ConstantType(const) => q"$const.asInstanceOf[$tpe]"
case _ => tree
}

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/shapeless/generic1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Generic1Macros(val c: whitebox.Context) extends CaseClassMacros {
def mkGeneric1Impl[T[_], FR[_[_]]](implicit tTag: WeakTypeTag[T[_]], frTag: WeakTypeTag[FR[Any]]): Tree = {
val tpe = tTag.tpe.etaExpand
val frTpe = c.openImplicits.headOption match {
case Some(ImplicitCandidate(_, _, TypeRef(_, _, List(_, tpe)), _)) => tpe
case Some(ImplicitCandidate(_, _, TypeRef(_, _, List(_, frTpe)), _)) => frTpe
case _ => frTag.tpe.typeConstructor
}

Expand Down
59 changes: 44 additions & 15 deletions core/shared/src/main/scala/shapeless/hlistconstraints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ object BasisConstraint {
type λ[L <: HList] = BasisConstraint[L, M]
}

implicit def hnilBasis[M <: HList] = new BasisConstraint[HNil, M] {}
implicit def hlistBasis[H, T <: HList, M <: HList](implicit bct : BasisConstraint[T, M], sel : Selector[M, H]) =
implicit def hnilBasis[M <: HList]: BasisConstraint[HNil, M] =
new BasisConstraint[HNil, M] {}

implicit def hlistBasis[H, T <: HList, M <: HList](implicit
bct: BasisConstraint[T, M],
sel: Selector[M, H]
): BasisConstraint[H :: T, M] =
new BasisConstraint[H :: T, M] {}
}

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

implicit def hnilLUB[T] = new LUBConstraint[HNil, T] {}
implicit def hlistLUB[H, T <: HList, B](implicit bct : LUBConstraint[T, B], ev: H <:< B) =
implicit def hnilLUB[T]: LUBConstraint[HNil, T] =
new LUBConstraint[HNil, T] {}

implicit def hlistLUB[H, T <: HList, B](implicit
bct: LUBConstraint[T, B],
ev: H <:< B
): LUBConstraint[H :: T, B] =
new LUBConstraint[H :: T, B] {}
}

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

implicit def hnilKeys[M <: HList] = new KeyConstraint[HNil, M] {}
implicit def hlistKeys[K, V, T <: HList, M <: HList]
(implicit bct : KeyConstraint[T, M], sel : Selector[M, K]) = new KeyConstraint[FieldType[K, V] :: T, M] {}
implicit def hnilKeys[M <: HList]: KeyConstraint[HNil, M] =
new KeyConstraint[HNil, M] {}

implicit def hlistKeys[K, V, T <: HList, M <: HList](implicit
bct: KeyConstraint[T, M],
sel: Selector[M, K]
): KeyConstraint[FieldType[K, V] :: T, M] =
new KeyConstraint[FieldType[K, V] :: T, M] {}
}

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

implicit def hnilValues[M <: HList] = new ValueConstraint[HNil, M] {}
implicit def hlistValues[K, V, T <: HList, M <: HList]
(implicit bct : ValueConstraint[T, M], sel : Selector[M, V]) = new ValueConstraint[FieldType[K, V] :: T, M] {}
implicit def hnilValues[M <: HList]: ValueConstraint[HNil, M] =
new ValueConstraint[HNil, M] {}

implicit def hlistValues[K, V, T <: HList, M <: HList](implicit
bct: ValueConstraint[T, M],
sel: Selector[M, V]
): ValueConstraint[FieldType[K, V] :: T, M] =
new ValueConstraint[FieldType[K, V] :: T, M] {}
}

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

implicit def hnilNotContains[U] = new NotContainsConstraint[HNil, U] {}
implicit def hlistNotContains[H, T <: HList, U](implicit nc: T NotContainsConstraint U, neq: U =:!= H) =
implicit def hnilNotContains[U]: NotContainsConstraint[HNil, U] =
new NotContainsConstraint[HNil, U] {}

implicit def hlistNotContains[H, T <: HList, U](implicit
nc: T NotContainsConstraint U,
neq: U =:!= H
): NotContainsConstraint[H :: T, U] =
new NotContainsConstraint[H :: T, U] {}
}

Expand All @@ -161,8 +186,12 @@ object IsDistinctConstraint {

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

implicit def hnilIsDistinct = new IsDistinctConstraint[HNil] {}
implicit def hlistIsDistinct[H, T <: HList](implicit d: IsDistinctConstraint[T],
nc: NotContainsConstraint[T, H]): IsDistinctConstraint[H :: T] =
implicit def hnilIsDistinct: IsDistinctConstraint[HNil] =
new IsDistinctConstraint[HNil] {}

implicit def hlistIsDistinct[H, T <: HList](implicit
d: IsDistinctConstraint[T],
nc: NotContainsConstraint[T, H]
): IsDistinctConstraint[H :: T] =
new IsDistinctConstraint[H :: T] {}
}
Loading

0 comments on commit b55d031

Please sign in to comment.