You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import monocle.syntax.all._
case class A private (field1: String, field2: String)
object A {
def apply(field1: String, field2: String): A = new A(field1, field2)
val copiedObject = A("1", "2").copy(field1 = "3")
val modifiedObject = A("1", "2").focus(_.field1).replace("3")
println(copiedObject)
println(modifiedObject)
}
val copiedObject = A("1", "2").copy(field1 = "3") //compile error
val modifiedObject = A("1", "2").focus(_.field1).replace("3") //compile error
println(copiedObject)
println(modifiedObject)
Error:
missing argument for parameter field2 of method copy in class A: (field1: String, field2: String): Playground.A
method copy cannot be accessed as a member of (from : Playground.A) from module class Playground$.
Could you please clarify whether it is expected behavior?
The text was updated successfully, but these errors were encountered:
Thank you for the response. Should the library behavior be the same for Scala 2 and 3? I expect that people migrating their codebase from Scala 2 to Scala 3 may face this issue.
Ideally, yes it should be the same but I believe this is due to a change of semantic between Scala 2 and 3 for private case class constructors. So Monocle is just following the Scala language.
Hello,
I've noticed that the code that compiles and works fine in scala 2 doesn't work for scala 3.
Scastie:
Scala 2 -> https://scastie.scala-lang.org/FmuLKaM0TpmNvQ3xHdpUSg
Scala 3 -> https://scastie.scala-lang.org/7FBOxnIPQbemh5TomJrUig
Code:
Error:
Could you please clarify whether it is expected behavior?
The text was updated successfully, but these errors were encountered: