-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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) |
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.
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
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.
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).
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 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) |
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.
Missing sym.info =
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.
Oops
As #1723 demonstrates, doing this at PostTyper is too late.
Review by @smarter. How about having a look at #1644 soon in return?