Skip to content
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

Doesn't work with literal type #157

Closed
user753 opened this issue May 2, 2023 · 3 comments
Closed

Doesn't work with literal type #157

user753 opened this issue May 2, 2023 · 3 comments

Comments

@user753
Copy link

user753 commented May 2, 2023

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 added a commit to KacperFKorban/quicklens that referenced this issue May 3, 2023
This allows manually specifying type arguments of the focused field

Also suppress some warnings in Scala 3 macros

related to softwaremill#157
@KacperFKorban
Copy link
Collaborator

Now it should be possible to do

case class Test(f: "foo")
Test("foo").modify["foo"](_.f).setTo("foo")

@adamw adamw closed this as completed May 3, 2023
@user753
Copy link
Author

user753 commented May 4, 2023

Thanks.
Is it the compiler limitation that the generic type need to be specified?

Test("foo").modify(_.f)

Found:    String
Required: ("foo" : String)

@KacperFKorban
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants