Skip to content

Conversation

@SolalPirelli
Copy link
Contributor

Fixes #24485

else true
)
&& (!sym.is(Accessor) || (sym.isSetter && sym.owner.derivesFrom(defn.Caps_Stateful) && !sym.field.hasAnnotation(defn.UntrackedCapturesAnnot)))
|| ccConfig.strictMutability && sym.name == nme.update && sym == defn.Array_update
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two things I don't quite understand here:

  1. The method doc says "update is implicit for consume methods" but the code doesn't handle them at all, is that because they're implicitly handled by being Mutable | Method?
  2. What's the purpose of this hardcoding of Array.update? Can it not be defined as an update method? (And if not, should that be documented somewhere?)

Copy link
Member

Choose a reason for hiding this comment

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

Array class itself is hardcoded to be considered as mutable but not inherit from it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? Java interop? (sorry if this is a silly question...)

Copy link
Contributor

Choose a reason for hiding this comment

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

The hard-coding of Array was a fairly recent addition #24649. IIRC, for backwards compatibility, we cannot retroactively make Array extend Mutable. We plan to have a new collections-library design based around separation checking.

Copy link
Contributor

Choose a reason for hiding this comment

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

That also reminds me: We don't have a good way right now to represent this Array treatment in the library's API docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. The method doc says "update is implicit for consume methods" but the code doesn't handle them at all, is that because they're implicitly handled by being Mutable | Method?

Yes, update methods receive the Mutable flag, which is done by private def normalizeFlags in typer/Namer.scala.

@SolalPirelli SolalPirelli force-pushed the solal/var-should-not-be-update-def branch from 00eda9d to 92f60f4 Compare January 6, 2026 13:23
@SolalPirelli SolalPirelli marked this pull request as ready for review January 6, 2026 13:29
@SolalPirelli SolalPirelli requested a review from bracevac January 6, 2026 14:10
@SolalPirelli SolalPirelli merged commit 3121239 into main Jan 7, 2026
66 checks passed
@SolalPirelli SolalPirelli deleted the solal/var-should-not-be-update-def branch January 7, 2026 10:24
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.

Generated getters are considered update def

4 participants