Skip to content

Commit

Permalink
Add Scala compiler plugin: "sbt-silencer"
Browse files Browse the repository at this point in the history
Motivation:

Add "deprecated" warnings for the users, but avoid compilation errors
when used internally for the period of migration.

Modification:

- Add sbt silencer to `build.sbt`
- Deprecate `MVar` and promote `MVar2`
  • Loading branch information
kubum committed Feb 8, 2020
1 parent 60156c0 commit 4310daf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ val CompileTime = config("CompileTime").hide
val SimulacrumVersion = "1.0.0"
val CatsVersion = "2.1.0"
val DisciplineScalatestVersion = "1.0.0"
val SilencerVersion = "1.4.4"
val customScalaJSVersion = Option(System.getenv("SCALAJS_VERSION"))

addCommandAlias("ci", ";scalafmtSbtCheck ;scalafmtCheckAll ;test ;mimaReportBinaryIssues; doc")
Expand Down Expand Up @@ -238,6 +239,10 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
"org.typelevel" %%% "cats-laws" % CatsVersion % Test,
"org.typelevel" %%% "discipline-scalatest" % DisciplineScalatestVersion % Test
),
libraryDependencies ++= Seq(
compilerPlugin(("com.github.ghik" % "silencer-plugin" % SilencerVersion).cross(CrossVersion.full)),
("com.github.ghik" % "silencer-lib" % SilencerVersion % Provided).cross(CrossVersion.full)
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Expand Down
3 changes: 3 additions & 0 deletions core/shared/src/main/scala/cats/effect/concurrent/MVar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package concurrent
import cats.effect.concurrent.MVar.{TransformedMVar, TransformedMVar2}
import cats.effect.internals.{MVarAsync, MVarConcurrent}
import cats.~>
import com.github.ghik.silencer.silent

/**
* A mutable location, that is either empty or contains
Expand Down Expand Up @@ -53,6 +54,7 @@ import cats.~>
* Inspired by `Control.Concurrent.MVar` from Haskell and
* by `scalaz.concurrent.MVar`.
*/
@deprecated("`MVar` is now deprecated in favour of a new generation `MVar2` with `tryRead` support", "2.1.0")
abstract class MVar[F[_], A] {
/**
* Returns `true` if the `MVar` is empty and can receive a `put`, or
Expand Down Expand Up @@ -124,6 +126,7 @@ abstract class MVar[F[_], A] {
* The `MVar2` is the successor of `MVar` with [[tryRead]]. It was implemented separately only to maintain binary
* compatibility with `MVar`.
*/
@silent("deprecated")
abstract class MVar2[F[_], A] extends MVar[F, A] {
/**
* Returns the value without waiting or modifying.
Expand Down

0 comments on commit 4310daf

Please sign in to comment.