Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning about unhandled type class during compilation

Tags:

scala

sbt

Given the following minimal code:

package object MyPackage {
  case class Pimp(private val i: Int) extends AnyVal 
}

SBT (0.13.8) complains:

[warn] sbt-api: Unhandled type class scala.reflect.internal.Types$MethodType : ($this: myPackage.package.Pimp)Int

My build file is roughly this:

Project("sbtissue", file("sbtissue")).settings(scalaVersion := "2.11.6")

Changing the relevant line in the source file to:

class Pimp(private val i: Int) extends AnyVal

or:

case class Pimp(i: Int) extends AnyVal

raises no warning when compiling. What can I do to prevent this warning?

Related: https://groups.google.com/forum/#!topic/simple-build-tool/KWdg4HfYqMk

like image 520
Peter Schmitz Avatar asked Oct 20 '22 14:10

Peter Schmitz


1 Answers

I think you've found a legitimate edge case, if a little niche maybe.

I would recommend dropping the private as it doesn't really fit with the idea of a case class, and also, given the existence of a generated unapply, it doesn't hide that value anyways:

Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_40).
Type in expressions to have them evaluated.
Type :help for more information.

scala> case class Pimp(private val i: Int) extends AnyVal
defined class Pimp

scala> val p1 = Pimp(1)
p1: Pimp = Pimp(1)

scala> p1.i
<console>:11: error: value i is not a member of Pimp
              p1.i
                 ^

scala> val Pimp(n) = p1
n: Int = 1
like image 184
Dale Wijnand Avatar answered Oct 23 '22 00:10

Dale Wijnand