Skip to content

Commit

Permalink
Drops Scala 2.11 support on master (#3051)
Browse files Browse the repository at this point in the history
* drop Scala 2.11 support

* fixing one test

* fix missed rename

* BC check

* format

* added back deprecated tests
  • Loading branch information
kailuowang authored Sep 17, 2019
1 parent 548ab6c commit d8a05a5
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 83 deletions.
14 changes: 3 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ git:
jdk:
- openjdk8

scala_version_211: &scala_version_211 2.11.12

scala_version_212: &scala_version_212 2.12.9
scala_version_213: &scala_version_213 2.13.0

Expand All @@ -34,22 +34,17 @@ jobs:
install: pip install --user codecov
script: sbt coverage buildJVM bench/test coverageReport && codecov

- &js_tests
stage: test
- stage: test
env: TEST="JS tests"
# http://austinpray.com/ops/2015/09/20/change-travis-node-version.html
install: rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
script: sbt ++$TRAVIS_SCALA_VERSION! validateJS && sbt ++$TRAVIS_SCALA_VERSION! validateKernelJS && sbt ++$TRAVIS_SCALA_VERSION! validateFreeJS
scala: *scala_version_211
- <<: *js_tests
scala: *scala_version_212

- &jvm_tests
stage: test
env: TEST="JVM tests"
script: sbt ++$TRAVIS_SCALA_VERSION! buildJVM bench/test
scala: *scala_version_211
- <<: *jvm_tests
scala: *scala_version_212
- <<: *jvm_tests
scala: *scala_version_213
Expand All @@ -65,12 +60,9 @@ jobs:
env: TEST="scalafix"
script: cd scalafix && sbt tests/test

- &bincompat_check
stage: test
- stage: test
env: TEST="binary compatibility"
script: sbt ++$TRAVIS_SCALA_VERSION! validateBC
scala: *scala_version_211
- <<: *bincompat_check
scala: *scala_version_212

- stage: styling
Expand Down
4 changes: 3 additions & 1 deletion binCompatTest/src/main/scala/catsBC/MimaExceptions.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package catsBC
import cats.InjectK
import cats.implicits._

object MimaExceptions {
Expand Down Expand Up @@ -27,6 +28,7 @@ object MimaExceptions {
true.iterateUntilM(Option(_))(identity _),
Either.catchOnly[NumberFormatException] { "foo".toInt },
(1.validNel[String], 2.validNel[String], 3.validNel[String]) mapN (_ + _ + _),
(1.asRight[String], 2.asRight[String], 3.asRight[String]) parMapN (_ + _ + _)
(1.asRight[String], 2.asRight[String], 3.asRight[String]) parMapN (_ + _ + _),
InjectK.catsReflexiveInjectKInstance[Option]
)
}
50 changes: 13 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scala
List(CrossType.Pure, CrossType.Full)
.flatMap(_.sharedSrcDir(srcBaseDir, srcName).toList.map(f => file(f.getPath + suffix)))
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, y)) if y <= 12 =>
extraDirs("-2.12-")
case Some((2, y)) if y >= 13 =>
extraDirs("-2.13+")
case _ => Nil
Expand Down Expand Up @@ -82,7 +80,7 @@ lazy val commonSettings = commonScalaVersionSettings ++ Seq(
val docSource = (sources in (Compile, doc)).value
if (priorTo2_13(scalaVersion.value)) docSource else Nil
}
) ++ warnUnusedImport ++ update2_12 ++ xlint
) ++ warnUnusedImport

def macroDependencies(scalaVersion: String) =
CrossVersion.partialVersion(scalaVersion) match {
Expand Down Expand Up @@ -152,11 +150,6 @@ lazy val commonJvmSettings = Seq(
Test / javaOptions := Seq("-Xmx3G")
)

lazy val commonNativeSettings = Seq(
scalaVersion := "2.11.12", // TODO: load scala version form .travis.yml: https://github.com/dwijnand/sbt-travisci/issues/11
crossScalaVersions := Seq("2.11.12")
)

lazy val includeGeneratedSrc: Setting[_] = {
mappings in (Compile, packageSrc) ++= {
val base = (sourceManaged in Compile).value
Expand Down Expand Up @@ -398,7 +391,15 @@ def mimaSettings(moduleName: String) =
exclude[MissingTypesProblem]("cats.arrow.FunctionKMacros$"),
exclude[IncompatibleMethTypeProblem]("cats.arrow.FunctionKMacros#Lifter.this"),
exclude[IncompatibleResultTypeProblem]("cats.arrow.FunctionKMacros#Lifter.c")
) ++ //package private classes no longer needed
Seq(
exclude[MissingClassProblem]("cats.kernel.compat.scalaVersionMoreSpecific$"),
exclude[MissingClassProblem]("cats.kernel.compat.scalaVersionMoreSpecific"),
exclude[MissingClassProblem](
"cats.kernel.compat.scalaVersionMoreSpecific$suppressUnusedImportWarningForScalaVersionMoreSpecific"
)
)

}
)

Expand Down Expand Up @@ -788,7 +789,7 @@ addCommandAlias("validateKernelJS", "kernelLawsJS/test")
addCommandAlias("validateFreeJS", "freeJS/test") //separated due to memory constraint on travis
addCommandAlias("validate", ";clean;validateJS;validateKernelJS;validateFreeJS;validateJVM")

addCommandAlias("prePR", ";fmt;++2.11.12 mimaReportBinaryIssues")
addCommandAlias("prePR", "fmt")

////////////////////////////////////////////////////////////////////////////////////////////////////
// Base Build Settings - Should not need to edit below this line.
Expand Down Expand Up @@ -827,7 +828,8 @@ def commonScalacOptions(scalaVersion: String) =
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfatal-warnings",
"-deprecation"
"-deprecation",
"-Xlint:-unused,_"
) ++ (if (priorTo2_13(scalaVersion))
Seq(
"-Yno-adapted-args",
Expand Down Expand Up @@ -878,15 +880,7 @@ lazy val sharedReleaseProcess = Seq(
)

lazy val warnUnusedImport = Seq(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
Seq("-Ywarn-unused-import")
case Some((2, n)) if n >= 12 =>
Seq("-Ywarn-unused:imports")

}
},
scalacOptions ++= Seq("-Ywarn-unused:imports"),
scalacOptions in (Compile, console) ~= { _.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports")) },
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
Expand All @@ -898,21 +892,3 @@ lazy val credentialSettings = Seq(
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq
)

lazy val update2_12 = Seq(
scalacOptions -= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Yinline-warnings"
case _ => ""
}
}
)

lazy val xlint = Seq(
scalacOptions += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Xlint:-unused,_"
case _ => "-Xlint"
}
}
)
3 changes: 0 additions & 3 deletions core/src/main/scala/cats/Inject.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cats

import kernel.compat.scalaVersionMoreSpecific._

/**
* Inject is a type class providing an injection from type `A` into
* type `B`. An injection is a function `inj` which does not destroy
Expand All @@ -27,7 +25,6 @@ abstract class Inject[A, B] {
final def unapply(b: B): Option[A] = prj(b)
}

@suppressUnusedImportWarningForScalaVersionMoreSpecific
sealed abstract private[cats] class InjectInstances {
implicit def catsReflexiveInjectInstance[A]: Inject[A, A] =
new Inject[A, A] {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/cats/InjectK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cats

import cats.arrow.FunctionK
import cats.data.EitherK
import kernel.compat.scalaVersionMoreSpecific._

/**
* InjectK is a type class providing an injection from type
Expand Down Expand Up @@ -33,7 +32,6 @@ abstract class InjectK[F[_], G[_]] {
final def unapply[A](ga: G[A]): Option[F[A]] = prj(ga)
}

@suppressUnusedImportWarningForScalaVersionMoreSpecific
sealed abstract private[cats] class InjectKInstances {
implicit def catsReflexiveInjectKInstance[F[_]]: InjectK[F, F] =
new InjectK[F, F] {
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/ChainSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class ChainSuite extends CatsSuite {

test("Chain#get is consistent with List#lift") {
forAll { (x: Chain[Int], idx: Int) =>
x.get(idx) should ===(x.toList.lift(idx))
x.get(idx.toLong) should ===(x.toList.lift(idx))
}
}

Expand Down
14 changes: 12 additions & 2 deletions tests/src/test/scala/cats/tests/EitherSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ class EitherSuite extends CatsSuite {
}
}

test("raiseOrPure syntax consistent with fromEither") {
test("liftTo syntax consistent with fromEither") {
val ev = ApplicativeError[Validated[String, *], String]
forAll { (fa: Either[String, Int]) =>
fa.raiseOrPure[Validated[String, *]] should ===(ev.fromEither(fa))
fa.liftTo[Validated[String, *]] should ===(ev.fromEither(fa))
}
}

Expand All @@ -363,3 +363,13 @@ class EitherSuite extends CatsSuite {
}

}

@deprecated("To test deprecated methods", "2.1.0")
class DeprecatedEitherSuite extends CatsSuite {
test("raiseOrPure syntax consistent with fromEither") {
val ev = ApplicativeError[Validated[String, *], String]
forAll { (fa: Either[String, Int]) =>
fa.raiseOrPure[Validated[String, *]] should ===(ev.fromEither(fa))
}
}
}

0 comments on commit d8a05a5

Please sign in to comment.