-
Notifications
You must be signed in to change notification settings - Fork 53
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
Cannot use modify in opaque types #234
Comments
It is not only opaque types. Following wrapper gives the same error: import com.softwaremill.quicklens.*
object Types {
case class V(x: Double, y: Double)
class Vec(val v: V)
object Vec {
def apply(x: Double, y: Double): Vec = new Vec(V(x, y))
}
extension (v: Vec) {
def x: Double = v.v.x
def y: Double = v.v.y
def copy(x: Double = v.x, y: Double = v.y): Vec = new Vec(V(x, y))
}
}
object Main {
import Types.*
def main(args: Array[String]): Unit = {
val a = Vec(1, 2)
val b = a.modify(_.x).using(_ + 1)
println(b)
}
} |
And when I remove extension and use members instead, the code works in Scala 2.13.14, but not in Scala 3: import com.softwaremill.quicklens._
object Types {
case class V(x: Double, y: Double)
class Vec(val v: V) {
def x: Double = v.x
def y: Double = v.y
def copy(x: Double = v.x, y: Double = v.y): Vec = new Vec(V(x, y)) {}
}
object Vec {
def apply(x: Double, y: Double): Vec = new Vec(V(x, y)) {}
}
}
object Main {
import Types._
def main(args: Array[String]): Unit = {
val a = Vec(1, 2)
val b = a.modify(_.x).using(_ + 1)
println(b)
}
} The error in Scala 3 is:
|
OndrejSpanel
added a commit
to OndrejSpanel/quicklens
that referenced
this issue
Dec 1, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Following opaque type has defined both getters and
copy
, but it is not possible to use quicklens on it:With Scala 3.4.2 the error is:
The text was updated successfully, but these errors were encountered: