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

Allow var in refinements #19809

Closed
odersky opened this issue Feb 28, 2024 · 3 comments · Fixed by #19982
Closed

Allow var in refinements #19809

odersky opened this issue Feb 28, 2024 · 3 comments · Fixed by #19982
Assignees
Labels
itype:enhancement Spree Suitable for a future Spree
Milestone

Comments

@odersky
Copy link
Contributor

odersky commented Feb 28, 2024

Minimized example

  type A = Any { var x: Int }

Output

1 |  type A = Any { var x: Int }
  |                 ^^^^^^^^^^
  |                 refinement cannot be a mutable var.
  |                 You can use an explicit getter x and setter x_= instead

Expectation

Expand the refinement to

type A = Any { def x: Int, def x_=($x: Int): Unit }

instead.

That's what Scala 2 does. See also: https://contributors.scala-lang.org/t/why-is-there-a-restriction-on-refinements-not-having-vars/6498/6

To fix this, we need to touch the following pieces of code:

  • Both versions of syntax.md, to allow the new syntax
  • The parser, make sure the new syntax also shows up as a doc comment of the parsing method
  • Code in Desugar that does the expansion.
@odersky odersky added stat:needs triage Every issue needs to have an "area" and "itype" label itype:enhancement Spree Suitable for a future Spree and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 28, 2024
@odersky
Copy link
Contributor Author

odersky commented Feb 28, 2024

This is a good Spree ticket, but if someone wants to pick it up before, please go ahead.

@hamzaremmal
Copy link
Member

I will pick it up for the next Spree.

cc @mbovel

@hamzaremmal hamzaremmal self-assigned this Feb 28, 2024
@mbovel
Copy link
Member

mbovel commented Mar 15, 2024

This issue was picked for the Issue Spree of March 19th, 2024. @hamzaremmal, @aherlihy will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:enhancement Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants