Transforming into case class with mutable field breaks from 0.8.0
hughsimpson opened this issue · comments
Checklist
- I read the documentation at https://chimney.readthedocs.io/ and checked that the functionality exists
- I verified that the behavior for my use case doesn't match the documentation
- I checked the https://github.com/scalalandio/chimney/issues and haven't found the issue reported
- I confirmed that the bug is not related to functionality that was deprecated: lifted transformers (
TransformerF
s) orunsafeOption
flags
Describe the bug
Transforming into a class with a mutable field no longer works as of 0.8.0 - I did not find this in a list of removed functionality
Reproduction
The following works in 0.7.5, fails to compile on 0.8.0
object Main extends App {
def fromRow(row: Bar): Foo = row.transformInto[Foo]
}
case class Foo(var string: String)
case class Bar(string: String)
Expected behavior
As per the documentation 'every class with a public primary constructor can be the target of the transformation.' - a case class with a mutable field is very much a class with a public primary constructor - I would expect this to continue to work as before
Actual behavior
~/chimney_min_bug/src/main/scala/chimney_min_bug/Main.scala:7:49: Chimney can't derive transformation from chimney_min_bug.Bar to chimney_min_bug.Foo
[error]
[error] chimney_min_bug.Foo
[error] setStri(stri: java.lang.String) - no accessor named stri in source type chimney_min_bug.Bar
[error]
[error]
[error] Consult https://chimney.readthedocs.io for usage examples.
[error]
[error] def fromRow(row: Bar): Foo = row.transformInto[Foo]
[error] ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
Which Chimney version do you use
Succeeds with 0.7.5, fails with 0.8.0
Which platform do you use
- JVM
- Scala.js
- Scala Native
If you checked JVM
$ java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13, mixed mode, sharing)
Additional context
N/A
It will be released in 0.8.1