-
Notifications
You must be signed in to change notification settings - Fork 323
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
Occurences in Java. Don't expose setters for Scope vars. #11464
Conversation
public abstract String symbol(); | ||
|
||
/** The definition of a symbol in the aliasing graph. */ | ||
public static final class Def implements GraphOccurrence { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not declare it as record? It used to be sealed case class
in Scala.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with record
is that all (default) constructor fields are publicly accessible. I plan to control the encapsulation more in some subsequent changes. Thus I went the more verbose way and created a class
.
var childScopes: List[Scope] = List(), | ||
var occurrences: Map[Id, GraphOccurrence] = HashMap(), | ||
var allDefinitions: List[GraphOccurrence.Def] = List() | ||
private[Graph] var _childScopes: List[Scope] = List(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the purpose of this refactoring. Why not simply define these fields as private var childScopes: List[Scope] = ...
without the rename and define public plain old getters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only guessing but it looks like he wanted to limit the scope of variables so that one does not accidentally mutate them? But yes, the motivation is unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title of this PR is:
Don't expose setters for Scope vars.
Renaming the fields to private var _xyz
and adding def xyz = _xyz
achieves that goal. If there is a better way in Scala to have public getters, but private setters, feel free to propose it.
Jaroslav Tulach reports a new STANDUP for today (2024-11-01): Progress: .
Next Day: Vacation is over. Back to work. |
Pull Request Description
Another change motivated by work on #11365. Continuation of #11419.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,