chimney
chimney copied to clipboard
Compilation of partial transformation fails when there are fields named both `is{Name}` and `{name}`
Describe the bug
Compilation of partial transformation fails when the destination type contains fields named both is{Name}
and {name}
,
Compilation succeeds when adding .withFieldComputed(_.isName, _.isName)
, but fails with .withFieldRenamed(_.isName, _.isName)
or without it.
Reproduction Scastie Code Snippet
Code
import io.scalaland.chimney.dsl.*
case class Proto(isSomething: Boolean, somethingDetail: Option[Proto.SomethingDetail])
object Proto:
case class SomethingDetail(a: String, b: Int)
case class Domain(isSomething: Boolean, something: Option[Domain.Something])
object Domain:
case class Something(a: String, b: Int)
val proto = Proto(isSomething = true, somethingDetail = Some(Proto.SomethingDetail("hello", 1)))
val result = proto.intoPartial[Domain]
.withFieldRenamed(_.somethingDetail, _.something)
.transform
println(result)
Error
Chimney can't derive transformation from Playground.Proto to Playground.Domain
Playground.Domain
isSomething: scala.Boolean - can't derive transformation from isSomething: scala.Option[Playground.Proto.SomethingDetail] in source type Playground.Proto
scala.Boolean
derivation from somethingdetail: Playground.Proto.SomethingDetail to scala.Boolean is not supported in Chimney!
Consult https://chimney.readthedocs.io for usage examples.
Which Chimney version do you use 0.8.4
Which platform do you use Scala 3.3.0, 3.3.1, 3.3.2-RC1 / JVM