-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Constructors: fixes to maintain needed private fields. #774
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
Conversation
Allows not to go deep into tree, additionally fixes bugs with fields that are only used in inner classes being removed.
Curiously enough, it only found bugs in old scheme It was deleting accessors, that used to be vals but became defs without anybody raising the `Method` flag.
/rebuild |
@odersky please review |
if (inConstructor && (sym.is(ParamAccessor) || seenPrivateVals.contains(sym))) { | ||
// used inside constructor, accessed on this, | ||
// could use constructor argument instead, no need to retain field | ||
println("hoha") |
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.
hoha! You probably don't want to keep this :)
if (mightBeDropped(sym) && sym.owner.isClass) { | ||
val owner = sym.owner.asClass | ||
|
||
tree match { |
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 return value of this match is not used anywhere.
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.
this match returns Unit. How could it be used?
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.
Ah ok, I missed that retain
had side-effects, I suggest replacing def retain
by def retain()
and using retain()
to follow the scala style.
5852560
to
d1ecc22
Compare
/rebuild |
/rebuild |
def retain = | ||
retainedPrivateVals.add(sym) | ||
|
||
if (mightBeDropped(sym) && sym.owner.isClass) { |
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'd reverse the order of the two conditions in the &&. mightBeDropped makes sense only for class members.
Otherwise LGTM |
2ee4caa
to
863d72d
Compare
Constructors: fixes to maintain needed private fields.
fixes #772