Doesn't work with literal type
user753 opened this issue · 3 comments
user753 commented
scala 3.2.2
quicklens v1.9.2
case class Test(f: "foo")
Test("foo").modify(_.f).setTo("foo")
[error] | Test("foo").modify(_.f).setTo("foo")
[error] | ^^^^^^^^^^^^^^^^^^^^^^^
[error] | Found: String
[error] | Required: ("foo" : String)
Test("foo").modify(_.f).setTo("foo": "foo")
also doesn't work
KacperFKorban commented
Now it should be possible to do
case class Test(f: "foo")
Test("foo").modify["foo"](_.f).setTo("foo")
user753 commented
Thanks.
Is it the compiler limitation that the generic type need to be specified?
Test("foo").modify(_.f)
Found: String
Required: ("foo" : String)
KacperFKorban commented
The issue is with type inference. The compiler infers the type parameter of modify
to be String
. In general, the compiler avoids inferring singleton types ATM. It's not necessarily a limitation, but a design choice.