Skip to content

Commit

Permalink
Support 2.11.12 by using old cats (#211)
Browse files Browse the repository at this point in the history
* Support 2.11.12 by using old cats

* don't do js for scala 2.11

* try to fix a compile warning

* disable patmat analysis, mima

* disable mima for 2.11

* remove commented code.
  • Loading branch information
johnynek committed May 6, 2021
1 parent 0c246d9 commit 171678d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.0.0-RC2, 3.0.0-RC3, 2.12.13, 2.13.5]
scala: [3.0.0-RC2, 3.0.0-RC3, 2.11.12, 2.12.13, 2.13.5]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -122,6 +122,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.11.12)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.11.12-${{ matrix.java }}

- name: Inflate target directories (2.11.12)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.13)
uses: actions/download-artifact@v2
with:
Expand Down
27 changes: 18 additions & 9 deletions build.sbt
Expand Up @@ -14,12 +14,7 @@ ThisBuild / organizationName := "Typelevel"
ThisBuild / publishGithubUser := "johnynek"
ThisBuild / publishFullName := "P. Oscar Boykin"

ThisBuild / crossScalaVersions := List("3.0.0-RC2", "3.0.0-RC3", "2.12.13", "2.13.5")

ThisBuild / versionIntroduced := Map(
"3.0.0-M2" -> "0.1.99",
"3.0.0-M3" -> "0.1.99"
)
ThisBuild / crossScalaVersions := List("3.0.0-RC2", "3.0.0-RC3", "2.11.12", "2.12.13", "2.13.5")

ThisBuild / spiewakCiReleaseSnapshots := true

Expand Down Expand Up @@ -122,15 +117,27 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Full)
.settings(
name := "cats-parse",
libraryDependencies ++=
libraryDependencies ++= {
val isScala211 = CrossVersion.partialVersion(scalaVersion.value).contains((2, 11))
Seq(
cats.value,
if (isScala211) cats211.value else cats.value,
munit.value % Test,
munitScalacheck.value % Test
)
},
scalacOptions ++= {
val isScala211 = CrossVersion.partialVersion(scalaVersion.value).contains((2, 11))
// this code seems to trigger a bug in 2.11 pattern analysis
if (isScala211) List("-Xno-patmat-analysis") else Nil
},
mimaPreviousArtifacts := {
val isScala211 = CrossVersion.partialVersion(scalaVersion.value).contains((2, 11))
if (isScala211) Set.empty else mimaPreviousArtifacts.value
}
)
.settings(dottyJsSettings(ThisBuild / crossScalaVersions))
.jsSettings(
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filterNot(_.startsWith("2.11")),
Global / scalaJSStage := FastOptStage,
parallelExecution := false,
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
Expand All @@ -150,7 +157,9 @@ lazy val bench = project
.settings(
name := "bench",
coverageEnabled := false,
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filter(_.startsWith("2.")),
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filter { v =>
v.startsWith("2.12") || v.startsWith("2.13")
},
libraryDependencies ++=
Seq(
fastParse,
Expand Down
9 changes: 0 additions & 9 deletions core/shared/src/main/scala/cats/parse/Parser.scala
Expand Up @@ -1803,9 +1803,6 @@ object Parser {
override def defer[A](pa: => Parser[A]): Parser[A] =
Parser.this.defer(pa)

override def fix[A](fn: Parser[A] => Parser[A]): Parser[A] =
Parser.recursive(fn)

override def functor = this

override def map[A, B](fa: Parser[A])(fn: A => B): Parser[B] =
Expand All @@ -1817,9 +1814,6 @@ object Parser {
override def filter[A](fa: Parser[A])(fn: A => Boolean): Parser[A] =
fa.filter(fn)

override def filterNot[A](fa: Parser[A])(fn: A => Boolean): Parser[A] =
fa.filter { a => !fn(a) }

override def flatMap[A, B](fa: Parser[A])(fn: A => Parser[B]): Parser[B] =
Parser.this.flatMap10(fa)(fn)

Expand Down Expand Up @@ -2894,9 +2888,6 @@ object Parser0 {
override def filter[A](fa: Parser0[A])(fn: A => Boolean): Parser0[A] =
fa.filter(fn)

override def filterNot[A](fa: Parser0[A])(fn: A => Boolean): Parser0[A] =
fa.filter { a => !fn(a) }

override def product[A, B](fa: Parser0[A], fb: Parser0[B]): Parser0[(A, B)] =
Parser.product0(fa, fb)

Expand Down
14 changes: 9 additions & 5 deletions core/shared/src/test/scala/cats/parse/ParserTest.scala
Expand Up @@ -1117,11 +1117,15 @@ class ParserTest extends munit.ScalaCheckSuite {
property("rep0 can be reimplemented with oneOf0 and defer") {
forAll(ParserGen.gen, Arbitrary.arbitrary[String]) { (genP, str) =>
def rep0[A](pa: Parser[A]): Parser0[List[A]] =
Defer[Parser0].fix[List[A]] { tail =>
(pa ~ tail)
.map { case (h, t) => h :: t }
.orElse(Parser.pure(Nil))
}
Parser
.recursive[List[A]] { tail =>
(pa ~ tail.?)
.map {
case (h, Some(t)) => h :: t
case (h, None) => h :: Nil
}
}
.orElse(Parser.pure(Nil))

val lst1 = rep0(genP.fa)
val lst2 = genP.fa.rep0
Expand Down
1 change: 1 addition & 0 deletions project/Dependencies.scala
Expand Up @@ -3,6 +3,7 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._

object Dependencies {
lazy val cats = Def.setting("org.typelevel" %%% "cats-core" % "2.6.0")
lazy val cats211 = Def.setting("org.typelevel" %%% "cats-core" % "2.0.0")
lazy val munit = Def.setting("org.scalameta" %%% "munit" % "0.7.25")
lazy val munitScalacheck = Def.setting("org.scalameta" %%% "munit-scalacheck" % "0.7.25")
lazy val fastParse = "com.lihaoyi" %% "fastparse" % "2.3.2"
Expand Down

0 comments on commit 171678d

Please sign in to comment.