Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transforming into case class with mutable field breaks from 0.8.0 #400

Closed
5 of 7 tasks
hughsimpson opened this issue Oct 16, 2023 · 1 comment
Closed
5 of 7 tasks
Labels
bug Erroneous behavior in existing features

Comments

@hughsimpson
Copy link
Contributor

hughsimpson commented Oct 16, 2023

Checklist

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

@hughsimpson hughsimpson added the bug Erroneous behavior in existing features label Oct 16, 2023
@hughsimpson hughsimpson changed the title Transforming into case class with mutable field breads from Transforming into case class with mutable field breads from 0.8.0 Oct 16, 2023
@hughsimpson hughsimpson changed the title Transforming into case class with mutable field breads from 0.8.0 Transforming into case class with mutable field breaks from 0.8.0 Oct 16, 2023
@MateuszKubuszok
Copy link
Member

It will be released in 0.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Erroneous behavior in existing features
Projects
None yet
Development

No branches or pull requests

2 participants