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

tagging value classes does not work #8

Closed
kwark opened this issue Dec 31, 2017 · 1 comment
Closed

tagging value classes does not work #8

kwark opened this issue Dec 31, 2017 · 1 comment

Comments

@kwark
Copy link

kwark commented Dec 31, 2017

Hello,

This tagging library is suffering from the same issue as shapeless: milessabin/shapeless#644

object Main extends App {

  trait FooTag
  case class A(value: Int) extends AnyVal

  import com.softwaremill.tagging._

  val foo = A(0).taggedWith[FooTag]

  println(Array(foo).apply(0))
  println(List(foo).head)

}

This will throw a ClassCastException

You can also run/checkout this scastie: https://scastie.scala-lang.org/kwark/h4No8bhdQGKIEBV14rTkrA

A solution is to make Tag a universal trait instead of a type alias:

trait Tag[+U] extends Any { type Tag <: U }

Also see: https://scastie.scala-lang.org/kwark/575syCWTQIWsVaeJAKVxoQ

You might want to check binary compatibility.

@kciesielski
Copy link
Member

Sorry for long silence, thanks a lot for reporting the issue and proposing a solution. As far as I checked it works well and there are no issues with binary compatibility. I'm preparing a proper fix.

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

2 participants