Open neko-kai opened 5 years ago
Thanks for catching this. I'll try to take a look this weekend.
Derivation also fails if there's default parameters in companion object's apply
method,
it could be related
case class Test(field1: Option[String], field2: Int, field3: Boolean)
object Test {
def apply(value: List[String], bool: Boolean = false): Test =
Test(value.headOption, value.length, bool)
}
io.circe.derivation.deriveDecoder[Test]
cmd7.sc:1: type mismatch;
found : Boolean
required: Int
val res7 = io.circe.derivation.deriveDecoder[Test]
^
Compilation Failed
Derivation in this code:
Will produce the following error:
Where
WithCirce
is defined as:If the default parameter is removed, the error disappears:
This didn't happen in older versions of circe-derivation and indicates that the code for default value management is splicing additional references to the companion object – which I'm not sure are necessary for the use case, although I may be wrong.
/cc @aparo