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 4, 2020
1 parent bb87b2d commit 9bbfcff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 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 @@ -235,6 +236,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
9 changes: 7 additions & 2 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 @@ -52,10 +53,10 @@ import cats.~>
*
* Inspired by `Control.Concurrent.MVar` from Haskell and
* by `scalaz.concurrent.MVar`.
*
* Note: the interface `MVar` is now deprecated in favour of a new generation `MVar2` that supports `tryRead`.
*/
@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
* `false` otherwise.
Expand Down Expand Up @@ -126,7 +127,9 @@ 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 All @@ -145,6 +148,7 @@ abstract class MVar2[F[_], A] extends MVar[F, A] {

/** Builders for [[MVar]]. */
object MVar {

/**
* Builds an [[MVar]] value for `F` data types that are [[Concurrent]].
*
Expand Down Expand Up @@ -257,6 +261,7 @@ object MVar {
* Returned by the [[apply]] builder.
*/
final class ApplyBuilders[F[_]](val F: Concurrent[F]) extends AnyVal {

/**
* Builds an `MVar` with an initial value.
*
Expand Down

0 comments on commit 9bbfcff

Please sign in to comment.