-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Hi,
I am not sure whether it is a bug, but for sure it's quite a surprising behavior.
There is an option in the configuration called Configuration.default.withDefaults which allows for the derivation of non-case classes based on the fields they specify.
When combined with the following scalac options:-Xlint:strict-unsealed-patmat and -Wconf:cat=other-match-analysis:error it causes compilation to fail with "match may not be exhaustive" error.
This alone isn't yet that bad, but the error will propagate downstream through the chain of defined derivations and macros making it quite hard to debug for the end-users. I myself got it when I was trying to derive some tapir's type-classes that rely on circe codecs.
Here is a failed build on CI which illustrates that problem: https://github.com/softwaremill/livestub/runs/2586343239
Update: When trying to prepare a minimal example to reproduce I discovered that such a class needs also to specify an unapply method.
The minimal example to reproduce:
import io.circe.generic.extras.Configuration
import io.circe.generic.semiauto._
trait JsonSupport {
implicit val config: Configuration = Configuration.default.withDefaults
implicit val headerEncoder = deriveEncoder[Header]
}
class Header(val name: String, val value: String) {}
object Header {
def unapply(h: Header): Option[(String, String)] = Some((h.name, h.value))
}Originally reported in circe/circe#1756