From 73e218c24f566576a7be1b5c412ed3ab9010f407 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Tue, 21 Aug 2018 16:24:57 +0900 Subject: [PATCH] wip Scala 2.13.0-M4 --- .travis.yml | 10 +--- build.sbt | 55 +++++++++++++++------- core/jvm/src/main/scala/fs2/compress.scala | 4 +- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e58efa6d6..93cce855a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: scala scala: - 2.11.12 - 2.12.6 + - 2.13.0-M4 jdk: - oraclejdk8 @@ -24,11 +25,4 @@ env: - PUBLISH=true script: - - sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -Dfs2.test.verbose testJVM - - sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -Dfs2.test.verbose testJS - - sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 doc mimaReportBinaryIssues - - (test $TRAVIS_SCALA_VERSION == "2.11.12" && sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -J-Xms2g -J-Xmx2g docs/tut) || test $TRAVIS_SCALA_VERSION == "2.12.6" - -after_success: - - test $PUBLISH == "true" && test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "series/1.0" && sbt +publish - + - sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -Dfs2.test.verbose coreJVM/compile diff --git a/build.sbt b/build.sbt index 7eacbf7f6b..dc1715cc83 100644 --- a/build.sbt +++ b/build.sbt @@ -21,6 +21,16 @@ lazy val contributors = Seq( lazy val commonSettings = Seq( organization := "co.fs2", + scalacOptions ++= { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, v)) if v >= 13 => + Nil + case _ => + Seq( + "-Ypartial-unification" + ) + } + }, scalacOptions ++= Seq( "-feature", "-deprecation", @@ -28,7 +38,6 @@ lazy val commonSettings = Seq( "-language:higherKinds", "-language:existentials", "-language:postfixOps", - "-Ypartial-unification" ) ++ (if (scalaBinaryVersion.value.startsWith("2.12")) List( @@ -51,13 +60,13 @@ lazy val commonSettings = Seq( scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value, javaOptions in (Test, run) ++= Seq("-Xms64m", "-Xmx64m"), libraryDependencies ++= Seq( - compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.6"), + compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7"), "org.typelevel" %%% "cats-core" % "1.2.0", "org.typelevel" %%% "cats-laws" % "1.2.0" % "test", "org.typelevel" %%% "cats-effect" % "1.0.0-RC3", "org.typelevel" %%% "cats-effect-laws" % "1.0.0-RC3" % "test", - "org.scalatest" %%% "scalatest" % "3.0.5" % "test", - "org.scalacheck" %%% "scalacheck" % "1.13.5" % "test" + "org.scalatest" %%% "scalatest" % "3.0.6-SNAP1" % "test", + "org.scalacheck" %%% "scalacheck" % "1.14.0" % "test" ), scmInfo := Some(ScmInfo(url("https://github.com/functional-streams-for-scala/fs2"), "git@github.com:functional-streams-for-scala/fs2.git")), @@ -220,7 +229,7 @@ lazy val core = crossProject(JVMPlatform, JSPlatform) .settings( name := "fs2-core", sourceDirectories in (Compile, scalafmt) += baseDirectory.value / "../shared/src/main/scala", - libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.5" + libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.6" ) .jsSettings(commonJsSettings: _*) @@ -234,15 +243,7 @@ lazy val coreJVM = core.jvm Seq(s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""", "*") }, OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"), - osgiSettings, - libraryDependencies ++= { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, minor)) if minor >= 13 => - Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "0.1.2" % "test") - case _ => - Seq() - } - } + osgiSettings ) .settings(mimaSettings) lazy val coreJS = core.js.disablePlugins(DoctestPlugin, MimaPlugin) @@ -274,7 +275,18 @@ lazy val benchmarkMacros = project .settings(noPublish) .settings( name := "fs2-benchmark-macros", - addCompilerPlugin(("org.scalamacros" % "paradise" % "2.1.1").cross(CrossVersion.patch)), + libraryDependencies ++= { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, v)) if v <= 12 => + Seq( + compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch) + ) + case _ => + // if scala 2.13.0-M4 or later, macro annotations merged into scala-reflect + // https://github.com/scala/scala/pull/6606 + Nil + } + }, libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value ) @@ -289,7 +301,18 @@ lazy val benchmark = project o.startsWith("-Xmx") || o.startsWith("-Xms")) ++ Seq("-Xms256m", "-Xmx256m") ) .settings( - addCompilerPlugin(("org.scalamacros" % "paradise" % "2.1.1").cross(CrossVersion.patch)), + libraryDependencies ++= { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, v)) if v <= 12 => + Seq( + compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch) + ) + case _ => + // if scala 2.13.0-M4 or later, macro annotations merged into scala-reflect + // https://github.com/scala/scala/pull/6606 + Nil + } + }, libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value ) .enablePlugins(JmhPlugin) diff --git a/core/jvm/src/main/scala/fs2/compress.scala b/core/jvm/src/main/scala/fs2/compress.scala index f6ff9ed2e8..53aee66081 100644 --- a/core/jvm/src/main/scala/fs2/compress.scala +++ b/core/jvm/src/main/scala/fs2/compress.scala @@ -56,7 +56,7 @@ object compress { if ((fin && deflater.finished) || (!fin && deflater.needsInput)) acc else { val count = deflater.deflate(buffer) - _deflate_collect(deflater, buffer, acc ++ buffer.iterator.take(count), fin) + _deflate_collect(deflater, buffer, acc ++ buffer.iterator.take(count).toSeq, fin) } /** @@ -100,6 +100,6 @@ object compress { if (inflater.finished || inflater.needsInput) acc else { val count = inflater.inflate(buffer) - _inflate_collect(inflater, buffer, acc ++ buffer.iterator.take(count)) + _inflate_collect(inflater, buffer, acc ++ buffer.iterator.take(count).toSeq) } }