-
-
Notifications
You must be signed in to change notification settings - Fork 205
Open
Description
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:
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?
Metadata
Metadata
Assignees
Labels
No labels