From 7f7601c1702cee0173fc9cf9e5696f7b9e8f5be3 Mon Sep 17 00:00:00 2001 From: Georgi Krastev Date: Wed, 15 May 2024 09:59:21 +0300 Subject: [PATCH] Update Scala Native to 0.5 and drop Scala 2.11 (#1358) --- .github/workflows/ci.yml | 4 +- README.md | 13 +++---- build.sbt | 20 ++-------- .../src/test/scala/shapeless/generic.scala | 23 ++++++++++++ .../shapeless/GenericTests213.scala | 37 ------------------- project/Boilerplate.scala | 2 +- project/build.properties | 2 +- project/plugins.sbt | 4 +- 8 files changed, 39 insertions(+), 66 deletions(-) delete mode 100644 core/shared/src/test/scala_2.13+/shapeless/GenericTests213.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edd7752e3..a888a387d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - scala: [2.11.12, 2.12.17, 2.13.11] + scala: [2.12.19, 2.13.14] java: [temurin@8] platform: [jvm, js, native] runs-on: ${{ matrix.os }} @@ -77,7 +77,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.13.11] + scala: [2.13.14] java: [temurin@8] runs-on: ${{ matrix.os }} steps: diff --git a/README.md b/README.md index 56a9c638b..29b91c74e 100644 --- a/README.md +++ b/README.md @@ -120,20 +120,20 @@ resolvers ++= Seq( [ci]: https://travis-ci.org/milessabin/shapeless -Builds are available for Scala 2.11.x, 2.12.x and 2.13.x. The main line of development for -shapeless 2.3.3 is Scala 2.13.2. +Builds are available for Scala 2.12 and 2.13. +The main line of development for shapeless 2.3.x is Scala 2.13. ```scala -scalaVersion := "2.13.5" +scalaVersion := "2.13.14" libraryDependencies ++= Seq( - "com.chuusai" %% "shapeless" % "2.3.3" + "com.chuusai" %% "shapeless" % "2.3.11" ) ``` For using snapshots of Shapeless you should add, ```scala -scalaVersion := "2.13.5" +scalaVersion := "2.13.14" libraryDependencies ++= Seq( "com.chuusai" %% "shapeless" % "2.4.0-SNAPSHOT" @@ -163,8 +163,7 @@ releases][olderusage] on the shapeless wiki. ## Building shapeless -shapeless is built with SBT 1.3.10 or later, and its main branch is built with Scala 2.13.2 by default but also -cross-builds for 2.11.12 and 2.12.12. +shapeless is built with SBT 1.x and its main branch is built with Scala 2.13 by default but also cross-builds for 2.12. [namehashing]: https://github.com/sbt/sbt/issues/1640 diff --git a/build.sbt b/build.sbt index 7cc45192e..4037fc54c 100644 --- a/build.sbt +++ b/build.sbt @@ -3,9 +3,8 @@ import com.typesafe.tools.mima.core.* import sbtcrossproject.CrossPlugin.autoImport.crossProject import sbtcrossproject.CrossProject -val Scala211 = "2.11.12" -val Scala212 = "2.12.17" -val Scala213 = "2.13.11" +val Scala212 = "2.12.19" +val Scala213 = "2.13.14" commonSettings noPublishSettings @@ -13,7 +12,7 @@ crossScalaVersions := Nil ThisBuild / organization := "com.chuusai" ThisBuild / scalaVersion := Scala213 -ThisBuild / crossScalaVersions := Seq(Scala211, Scala212, Scala213) +ThisBuild / crossScalaVersions := Seq(Scala212, Scala213) ThisBuild / mimaFailOnNoPrevious := false ThisBuild / versionScheme := Some("pvp") @@ -193,7 +192,7 @@ lazy val examples = crossProject(JSPlatform, JVMPlatform, NativePlatform) .configureCross(configureJUnit) .dependsOn(core) .settings(moduleName := "examples") - .settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.2.0") + .settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.4.0") .settings(runAllIn(Compile)) .settings(commonSettings) .settings(noPublishSettings) @@ -248,17 +247,6 @@ lazy val mimaSettings = Seq( ProblemFilters.exclude[DirectMissingMethodProblem]("shapeless.package.macrocompat"), // inaccessible interface change ProblemFilters.exclude[MissingClassProblem]("shapeless.CaseClassMacros$PatchedContext$2$PatchedLookupResult"), - // methods added to traits (not binary compatible on Scala 2.11) - ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless.LowPriorityUnaryTCConstraint.hnilUnaryTC"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless.SingletonTypeUtils.isSymbolLiteral"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless.CaseClassMacros.mkAttributedRef"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless.CaseClassMacros.numNonCaseParamLists"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless.ReprTypes.objectRef"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless.IsCons1Macros.mkPackUnpack"), - ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("shapeless.CaseClassMacros.varargTpt"), - ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("shapeless.CaseClassMacros.varargTC"), - ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("shapeless.IsCons1Macros.varargTpt"), - ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("shapeless.IsCons1Macros.varargTC") ) ) diff --git a/core/shared/src/test/scala/shapeless/generic.scala b/core/shared/src/test/scala/shapeless/generic.scala index b66c0b420..4b22842ec 100644 --- a/core/shared/src/test/scala/shapeless/generic.scala +++ b/core/shared/src/test/scala/shapeless/generic.scala @@ -177,6 +177,16 @@ package GenericTestsAux { @generateGeneric object A } + + case class WrongApplySignature private(value: String) + object WrongApplySignature { + def apply(v: String): Either[String, WrongApplySignature] = scala.Left("No ways") + } + + case class CCWithCustomUnapply(x: Int, y: String) + object CCWithCustomUnapply { + def unapply(cc: CCWithCustomUnapply): Option[(Int, String, String)] = None + } } class GenericTests { @@ -878,6 +888,19 @@ class GenericTests { assertEquals(Priv("secret"), gen.from(Inl(Priv("secret")))) assertEquals(Inl(Priv("secret")), gen.to(Priv("secret"))) } + + @Test + def testCCWithCustomUnapply(): Unit = { + illTyped("Generic[WrongApplySignature]") + val cc = CCWithCustomUnapply(23, "foo") + val gen = Generic[CCWithCustomUnapply] + val r = gen.to(cc) + val f = gen.from(13 :: "bar" :: HNil) + assertTypedEquals[Int :: String :: HNil](23 :: "foo" :: HNil, r) + typed[CCWithCustomUnapply](f) + assertEquals(13, f.x) + assertEquals("bar", f.y) + } } package GenericTestsAux2 { diff --git a/core/shared/src/test/scala_2.13+/shapeless/GenericTests213.scala b/core/shared/src/test/scala_2.13+/shapeless/GenericTests213.scala deleted file mode 100644 index 057f20e4b..000000000 --- a/core/shared/src/test/scala_2.13+/shapeless/GenericTests213.scala +++ /dev/null @@ -1,37 +0,0 @@ -package shapeless - -import org.junit.Assert.assertEquals -import org.junit.Test -import shapeless.test.{illTyped, typed} -import shapeless.testutil.assertTypedEquals - -object GenericTests213 { - case class WrongApplySignature private(value: String) - object WrongApplySignature { - // We can't replace the synthetic `apply` method on Scala 2.11 - def apply(v: String): Either[String, WrongApplySignature] = Left("No ways") - } - - case class CCWithCustomUnapply(x: Int, y: String) - object CCWithCustomUnapply { - def unapply(cc: CCWithCustomUnapply): Option[(Int, String, String)] = None - } -} - -class GenericTests213 { - import GenericTests213._ - - illTyped("Generic[WrongApplySignature]") - - @Test - def testCCWithCustomUnapply(): Unit = { - val cc = CCWithCustomUnapply(23, "foo") - val gen = Generic[CCWithCustomUnapply] - val r = gen.to(cc) - val f = gen.from(13 :: "bar" :: HNil) - assertTypedEquals[Int :: String :: HNil](23 :: "foo" :: HNil, r) - typed[CCWithCustomUnapply](f) - assertEquals(13, f.x) - assertEquals("bar", f.y) - } -} diff --git a/project/Boilerplate.scala b/project/Boilerplate.scala index 2407697f5..d61aadc98 100644 --- a/project/Boilerplate.scala +++ b/project/Boilerplate.scala @@ -490,7 +490,7 @@ object Boilerplate { val `a:T..n:T` = synVals.map(_ + ":T").mkString(", ") val commonImplicits = "factory: Factory[T, CC[T]], ev: AdditiveCollection[CC[T]]" val implicits = scalaBinaryVersion match { - case "2.11" | "2.12" => commonImplicits + case "2.12" => commonImplicits case _ => s"dis: DefaultToIndexedSeq[CC], $commonImplicits" } diff --git a/project/build.properties b/project/build.properties index 04267b14a..081fdbbc7 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.9 +sbt.version=1.10.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index 43fe87737..d4c0424e8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,8 +6,8 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0. addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0") addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.12.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.9") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2") addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")