scalacheck-shapeless
scalacheck-shapeless copied to clipboard
Unused Local Value Warning with Scala 2.12.4 when Using (Shapeless) Tagged Types
Maybe not a ScalaCheck-Shapeless bug per se, but after switching from Scala 2.12.3 with -Xlint
enabled I began getting unused value warnings for implicit Arbitrary
instances for (Shapeless) tagged types in scope.
To illustrate:
// build.sbt
name := "sample"
version := "0.1"
scalaVersion := "2.12.3"
scalacOptions :=
"-Xfatal-warnings" ::
"-Xlint" ::
Nil
libraryDependencies ++=
"com.chuusai" %% "shapeless" % "2.3.3" ::
"com.github.alexarchambault" %% "scalacheck-shapeless_1.13" % "1.1.8" % Test ::
Nil
// src/test/scala/Unused.scala
import org.scalacheck.Arbitrary._
import org.scalacheck.ScalacheckShapeless._
import org.scalacheck._
import shapeless.tag
import shapeless.tag._
object Unused {
sealed trait Foo
case class Bear(s: String, i: Int @@ Foo)
val gen: Gen[Bear] = {
implicit val arbFoo: Arbitrary[Int @@ Foo] = Arbitrary(arbitrary[Int].map(tag[Foo].apply[Int]))
arbitrary[Bear]
}
}
That works fine with 2.12.3
, but assigning 2.12.4
to scalaVersion
and recompiling results in:
sbt:sample> ;clean;test:compile
[success] Total time: 2 s, completed Jan 28, 2018, 1:44:20 PM
sbt:sample> set scalaVersion := "2.12.4"
sbt:sample> ;clean;test:compile
[error] /tmp/sample/src/test/scala/Unused.scala:13:16: local val arbFoo in value gen is never used
[error] implicit val arbFoo: Arbitrary[Int @@ Foo] = Arbitrary(arbitrary[Int].map(tag[Foo].apply[Int]))
[error] ^
Setting -Xlint:-unused,_
gets this compiling with 2.12.4.
Can support for arbitrary tagged types be added to ScalaCheck-Shapeless?