Skip to content

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

Merged
merged 7 commits into from
Sep 14, 2015

Conversation

DarkDimius
Copy link
Contributor

fixes #772

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.
@DarkDimius DarkDimius changed the title Constructos: fixes to maintain needed private fields. Constructors: fixes to maintain needed private fields. Aug 24, 2015
@DarkDimius
Copy link
Contributor Author

error sbt.ResolveException: unresolved dependency: org.scala-sbt#relation;0.13.5: not found

/rebuild

@DarkDimius
Copy link
Contributor Author

@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")
Copy link
Member

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 :)

DarkDimius added a commit to dotty-staging/dotty that referenced this pull request Aug 25, 2015
if (mightBeDropped(sym) && sym.owner.isClass) {
val owner = sym.owner.asClass

tree match {
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@DarkDimius
Copy link
Contributor Author

error sbt.ResolveException: download failed: com.typesafe.sbteclipse#sbteclipse-core;2.2.0!sbteclipse-core.jar

/rebuild

@DarkDimius
Copy link
Contributor Author

/rebuild

def retain =
retainedPrivateVals.add(sym)

if (mightBeDropped(sym) && sym.owner.isClass) {
Copy link
Contributor

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.

@odersky
Copy link
Contributor

odersky commented Aug 28, 2015

Otherwise LGTM

DarkDimius added a commit to dotty-staging/dotty that referenced this pull request Sep 9, 2015
DarkDimius added a commit that referenced this pull request Sep 14, 2015
Constructors: fixes to maintain needed private fields.
@DarkDimius DarkDimius merged commit 4f2e912 into scala:master Sep 14, 2015
@allanrenucci allanrenucci deleted the fix-constructors branch December 14, 2017 19:19
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.

Constructors removes private fields used only in inner classes
3 participants