softwaremill / softwaremill/quicklens
Cannot use modify in opaque types
Open
@KacperFKorban is already working on this.
Since Jun 30, 2024.
- Dominant language
- Scala
- Stars
- 852
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
Following opaque type has defined both getters and copy, but it is not possible to use quicklens on it:
import com.softwaremill.quicklens.*
object Types {
case class V(x: Double, y: Double)
opaque type Vec = V
object Vec {
def apply(x: Double, y: Double): Vec = V(x, y)
}
extension (v: Vec) {
def x: Double = v.x
def y: Double = v.y
def copy(x: Double = v.x, y: Double = v.y): 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)
}
}
With Scala 3.4.2 the error is:
Unsupported path element. Path must have shape: .field1.field2.each.field3.(...), got: (($1: Types.Vec) => Types.x($1))
val b = a.modify(.x).using(_ + 1)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.