Scala 3 regression: derivation error for value classes
Open
Nobody has claimed this yet.
Blocked/needs help
Bug
- Dominant language
- Scala
- Stars
- 545
- Forks
- 66
- Avg merge
- 26m
- Merged PRs (30d)
- 2
Description
"org.typelevel" %% "kittens" % "3.3.0"
import cats.derived._
case class MyString(value: String) extends AnyVal
semiauto.monoid[MyString]
this snippet compiles successfully on Scala 2.13, but fails on Scala 3:
No given instance of type cats.derived.DerivedMonoid[Playground.MyString] was found.
I found:
cats.derived.DerivedMonoid.given_DerivedMonoid_A[Playground.MyString](
shapeless3.deriving.K0.mkProductInstances[
[A] =>> cats.derived.Derived.Or[cats.kernel.Monoid[A]], Playground.MyString]
(
/* missing */
summon[shapeless3.deriving.K0.ProductGeneric[Playground.MyString]]
)
)
But Failed to synthesize an instance of type shapeless3.deriving.K0.ProductGeneric[Playground.MyString]: class MyString is not a generic product because it is a value class.
The following import might make progress towards fixing the problem:
import cats.derived.DerivedMonoid.Strict.product
Scastie: https://scastie.scala-lang.org/DqVORi3bSU6rB8JM0PupHw
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Scala 3 failure with the provided kittens 3.3.0 snippet and compare it with Scala 2.13 behavior. Investigate semiauto.monoid[MyString] and the suggested DerivedMonoid.Strict.product import; the issue is done when value-class derivation succeeds on Scala 3 without the missing ProductGeneric error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100