Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Oct 19, 2025

Whether something is mutable or not depends on the context:

  • this of a Mutable type is exclusive in update methods, read-only elsewhere
  • a selection from a mutable type with read-only capture set is again read-only

They still were read-only, but all Capabilities implicitly capture `cap` now.
@odersky odersky force-pushed the fix-mutability branch 2 times, most recently from 3ed1c87 to 958eb30 Compare October 20, 2025 10:37
 - this of a Mutable type is exclusive in update methods, read-only elsewhere
 - a selection from a mutable type with read-only capture set is again read-only
Need to disable `associateWithMutable` for them.
@bracevac bracevac self-requested a review October 20, 2025 10:43
Treat them analogous to calls of update methods
 - whether we record x or x.rd also depends on the exclusivity in context
 - fix issue of missing updates for denotations when recording use of a path
@odersky odersky requested a review from noti0na1 October 22, 2025 05:42
Sometimes, disallowing assignments to mutable fields from normal methods is too restrictive. For instance:
```scala
class Cache[T](eval: () -> T):
private transparent var x: T = compiletime.uninitialized
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like reusing the keyword transparent again for another different meaning...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can certainly discuss this. Any suggestions what might be a better modifier?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why my changes were overridden, but such changes should also be made in project/resources/referenceReplacements/sidebar.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it now.

New doc page on mutability, split off from "Separation Checking".
@odersky
Copy link
Contributor Author

odersky commented Oct 22, 2025

Are there any tests from the mutability qualifiers paper that we could adapt to use here? Or from the paper that Ed presented at Scala Workshop?

@odersky odersky merged commit 38bb363 into scala:main Oct 23, 2025
51 checks passed
@odersky odersky deleted the fix-mutability branch October 23, 2025 07:23
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

Successfully merging this pull request may close these issues.

3 participants