Skip to content

Scala 3 regression: derivation error for value classes #658

@yakivy

Description

@yakivy
"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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions