-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
workaround for a possible scala bug in show for value class. #1804
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1804 +/- ##
==========================================
+ Coverage 94.88% 94.88% +<.01%
==========================================
Files 241 241
Lines 4147 4148 +1
Branches 107 97 -10
==========================================
+ Hits 3935 3936 +1
Misses 212 212
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks alright to me. I might consider naming it cshow
because it's not really private - user-defined functions that require a ContravariantShow
will need it, not sure if anyone will use that though.
Minimised and reported upstream at scala/bug#10458, if you want to leave a reference in the code. |
Thanks very much! @dwijnand |
Now I run into https://issues.scala-lang.org/browse/SI-6260 which is not fixed on 2.10.6 |
Drop 2.10 support? Otherwise I suggest seeing if simulacrum can be taught to see the show inherited from ContravariantShow. |
core/src/main/scala/cats/Show.scala
Outdated
@@ -13,11 +13,12 @@ import cats.functor.Contravariant | |||
@typeclass trait Show[T] extends Show.ContravariantShow[T] { | |||
// duplicated so simulacrum knows it requires an instance of this trait | |||
def show(t: T): String | |||
def _show(t: T): String = show(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be final
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved away from this solution.
I can't get simulacrum to recoganize the super class. So i decided to hand roll the type class boilerplate by simulacrum |
core/src/main/scala/cats/Show.scala
Outdated
|
||
/** | ||
* Hand rolling the type class boilerplate due to https://issues.scala-lang.org/browse/SI-6260 and scala/bug#10458 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SI-6260 is scala/bug#6260
so I got rid of the simulacrum and thus the duplicated
What do you guys think? @johnynek @julien-truffaut @sellout @edmundnoble @dwijnand |
|
@dwijnand what would be the best way to restrict the test to 2.11+? I can think of using |
unmanagedSourceDirectories in Test ++= {
val ss = (scalaSource in Test).value
if (CrossVersion.partialVersion(scalaVersion.value) exists (_._2 >= 11))
Seq(file(ss.getPath + "-2.11+"))
else
Nil
}
|
thanks @dwijnand in scalajs enabled projects the |
Hmm, that makes things more complicated :) unmanagedSourceDirectories in Test ++= {
val bd = baseDirectory.value
if (CrossVersion.partialVersion(scalaVersion.value) exists (_._2 >= 11))
CrossType.Pure.sharedSrcDir(bd, "test").toList map (f => file(f.getPath + "-2.11+"))
else
Nil
}
|
Thanks! @dwijnand it would've taken me weeks to figure out. fix pushed. |
Does this mean that 2.10 users won't be able to use |
@edmundnoble , it means that they will use |
fixes #1802