-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Use 'fileprivate' for synthesized members of 'private' decls #15980
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
@swift-ci Please test |
@swift-ci Please test source compatibility |
How does this affect the synthesis of A quick glance indicates that this doesn't change anything there, but I want to make sure I haven't missed anything. The intent here is just to have |
Yep, that's correct. I didn't touch CodingKeys for exactly the reason you said: it's not part of the protocol and does not need to be exposed to others by default, no matter what the access level of the enclosing type. |
Oops, there's a predicate I can use instead of |
@jrose-apple Okay, excellent, thanks for confirming! Do you think we can add that assertion to the unit test as well, then? Just to be safe around future changes here. |
@@ -2259,9 +2259,21 @@ ValueDecl::getFormalAccessScope(const DeclContext *useDC, | |||
llvm_unreachable("unknown access level"); | |||
} | |||
|
|||
void ValueDecl::copyFormalAccessFrom(ValueDecl *source) { | |||
void ValueDecl::copyFormalAccessFrom(const ValueDecl *source, | |||
bool sourceIsParentContext) { |
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.
Do you need sourceIsParentContext, or can you just check if the source's parent DeclContext is a SourceFile, and if so, turn Private to FilePrivate?
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.
It's relevant for any type, unfortunately, not just those at the top level. If we wanted to do it without the flag we could check if source
and this
are related in some way, but that seems more complicated for something every call site already knows.
Since 'private' means "limit to the enclosing scope (and extensions thereof)", putting it on a member means that the member can't be accessed everywhere the type might show up. That's normally a good thing, but it's not the desired effect for synthesized members used for derived conformances, and when it comes to class initializers this actually violates AST invariants. rdar://problem/39478298
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 fix makes sense, you can merge it as-is but I have an optional suggestion that may not make sense
c200f85
to
01a7ec4
Compare
Made the tweaks mentioned above. @swift-ci Please smoke test |
Since
private
means "limit to the enclosing scope (and extensions thereof)", putting it on a member means that the member can't be accessed everywhere the type might show up. That's normally a good thing, but it's not the desired effect for synthesized members used for derived conformances, and when it comes to class initializers this actually violates AST invariants.rdar://problem/39478298