8000 Retain var class param if used by som-snytt · Pull Request #9005 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Retain var class param if used #9005

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 1 commit into from :issue/12002
Jun 4, 2020
Merged

Retain var class param if used #9005

merged 1 commit into from
Jun 4, 2020

Conversation

som-snytt
Copy link
Contributor

Normally a private[this] class parameter does not get
a field if it is not referenced outside the constructor.
For a var, also check that it is not assigned to inside
the constructor.

Fixes scala/bug#12002

Normally a `private[this]` class parameter does not get
a field if it is not referenced outside the constructor.
For a var, also check that it is not assigned to inside
the constructor.
@scala-jenkins scala-jenkins added this to the 2.13.4 milestone May 23, 2020
@som-snytt som-snytt modified the milestones: 2.13.4, 2.13.3 May 23, 2020
@SethTisue SethTisue added the prio:blocker release blocker (used only by core team, only near release time) label Jun 1, 2020
Copy link
Member
@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

No expert, but LGTM.

I mean: adding traversals is expensive, right? So, ideally, it would be nice to define this separately and fuse it with the detectUsages traversal. But if there's no clean/easy/nice way to do that, to me this looks like it does a nice job minimising additional work.

@som-snytt
Copy link
Contributor Author

Agreed this is a baby step for correctness. The phase does quite some work in a couple of passes. I mention somewhere that I wanted to move the var in this case to the constructor, but didn't have time to spend. The class has grown over time and seen a previous refactor; it's probably time again. Not sure if I mentioned somewhere that doti does not elide fields at this time.

Copy link
Member
@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

thank you!

@lrytz lrytz merged commit ad00156 into scala:2.13.x Jun 4, 2020
@som-snytt som-snytt deleted the issue/12002 branch June 4, 2020 09:53
@SethTisue SethTisue removed the prio:blocker release blocker (used only by core team, only near release time) label Jun 23, 2020
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.

[2.13 regression] Scala 2.13 miscompiles Spark: it forgets to emit a field leading to a NoSuchFieldError at runtime
5 participants
0