Skip to content

Fix-#1723: Avoid private leaks on completion #1922

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 3 commits into from
Feb 2, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 1, 2017

As #1723 demonstrates, doing this at PostTyper is too late.

Review by @smarter. How about having a look at #1644 soon in return?

As scala#1723 demonstrates, doing this at PostTyper is too late.
@@ -343,6 +343,7 @@ object Checking {
fail(i"$sym cannot have the same name as ${cls.showLocated} -- class definitions cannot be overridden")
sym.setFlag(Private) // break the overriding relationship by making sym Private
}
avoidPrivateLeaks(sym, sym.pos)
Copy link
Member

Choose a reason for hiding this comment

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

So far, no method in Checking mutates anything, it would be nice to keep this pattern. I suggest doing what checkNonCyclic does and returning the potentially updated sym.info, i.e.:

if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass)
  checkNoPrivateLeaks(sym, sym.pos)
else
  sym.info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far, no method in Checking mutates anything

The line just above the avoidPrivateLeaks call is also a mutation (admittedly, only in the error case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have now refactored. You were right, the new organization is more coherent.

avoidPrivateLeaks got moved from Checking to TypeAssigner, where it
fits well besides the other avoid methods.
@@ -733,7 +733,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
// no longer necessary.
goto(end)
setPos(start, tree)
Checking.avoidPrivateLeaks(sym, tree.pos)
ta.avoidPrivateLeaks(sym, tree.pos)
Copy link
Member

Choose a reason for hiding this comment

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

Missing sym.info =

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops

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 participants