Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused Local Value Warning with Scala 2.12.4 when Using (Shapeless) Tagged Types #79

Open
michaelahlers opened this issue Jan 28, 2018 · 0 comments

Comments

@michaelahlers
Copy link

michaelahlers commented Jan 28, 2018

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?

michaelahlers added a commit to michaelahlers/plaid-client-scala that referenced this issue Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant