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 Mar 22, 2020
1 parent 9399999 commit 78cc281
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ val CompileTime = config("CompileTime").hide
val SimulacrumVersion = "1.0.0"
val CatsVersion = "2.1.1"
val DisciplineScalatestVersion = "1.0.1"
val SilencerVersion = "1.6.0"
val customScalaJSVersion = Option(System.getenv("SCALAJS_VERSION"))

addCommandAlias("ci", ";scalafmtSbtCheck ;scalafmtCheckAll ;test ;mimaReportBinaryIssues; doc")
Expand Down Expand Up @@ -239,6 +240,11 @@ 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 % CompileTime).cross(CrossVersion.full),
("com.github.ghik" % "silencer-lib" % SilencerVersion % Test).cross(CrossVersion.full)
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Expand Down Expand Up @@ -330,9 +336,6 @@ lazy val siteSettings = Seq(
Map("permalink" -> "/", "title" -> "Home", "section" -> "home", "position" -> "0")
)
),
micrositeConfigYaml := ConfigYml(
yamlCustomProperties = Map("plugins" -> List("jekyll-relative-links"))
),
micrositeCompilingDocsTool := WithMdoc,
mdocIn := (sourceDirectory in Compile).value / "mdoc",
fork in mdoc := true,
Expand Down
6 changes: 6 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

/**
* @define mVarDescription A mutable location, that is either empty or contains a value of type `A`.
Expand Down Expand Up @@ -58,7 +59,9 @@ sealed private[concurrent] trait MVarDocumentation extends Any {}
/**
* $mVarDescription
*/
@deprecated("`MVar` is now deprecated in favour of a new generation `MVar2` with `tryRead` and `swap` support", "2.2.0")
abstract class MVar[F[_], A] extends MVarDocumentation {

/**
* Returns `true` if the `MVar` is empty and can receive a `put`, or
* `false` otherwise.
Expand Down Expand Up @@ -131,7 +134,9 @@ abstract class MVar[F[_], A] extends MVarDocumentation {
* The `MVar2` is the successor of `MVar` with [[tryRead]] and [[swap]]. It was implemented separately only to maintain
* binary compatibility with `MVar`.
*/
@silent("deprecated")
abstract class MVar2[F[_], A] extends MVar[F, A] {

/**
* Replaces a value in MVar and returns the old value.
Expand All @@ -158,6 +163,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

0 comments on commit 78cc281

Please sign in to comment.