Skip to content

Add stableNull annotation to force tracking mutable fields #23528

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

Merged
merged 6 commits into from
Jul 28, 2025

Conversation

noti0na1
Copy link
Member

@noti0na1 noti0na1 commented Jul 15, 2025

class A:
  @stableNull var s: String | Null = null
  def getS: String =
    if s == null then s = ""
    s

The annotation will be added as private in scala for now. We plan to make it public in the next major release.

@olhotak
Copy link
Contributor

olhotak commented Jul 15, 2025

I think stableNull would be a better name.

@noti0na1 noti0na1 marked this pull request as ready for review July 16, 2025 11:42
@noti0na1 noti0na1 requested a review from a team as a code owner July 16, 2025 11:42
@noti0na1 noti0na1 requested a review from hamzaremmal July 16, 2025 11:43
@noti0na1 noti0na1 changed the title Add nullTrackable annotation to force tracking mutable fields Add stableNull annotation to force tracking mutable fields Jul 16, 2025
@SethTisue
Copy link
Member

If I understand correctly, then before becoming public, this would be considered by the SIP committee as part of the explicit-nulls feature.

@noti0na1 noti0na1 requested a review from olhotak July 27, 2025 09:53
Copy link
Contributor

@olhotak olhotak left a comment

Choose a reason for hiding this comment

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

LGTM

@noti0na1 noti0na1 merged commit 95b37a7 into scala:main Jul 28, 2025
36 checks passed
@noti0na1 noti0na1 deleted the null-trackable branch July 28, 2025 00:12
@WojciechMazur WojciechMazur added this to the 3.7.3 milestone Jul 29, 2025
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.

5 participants