swift-book
swift-book copied to clipboard
Access Control: Declarations with no explicit specifier use the enclosing declaration's level, not private
Previous ID | SR-15597 |
Radar | None |
Original Reporter | Saurabh Pote (JIRA User) |
Type | Bug |
Attachment: Download
Environment
Playground - Xcode 13.1
Additional Detail from JIRA
Votes | 0 |
Component/s | swift |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 3ddc3cc79f130a6791d115057efa79a2
Issue Description:
The swift documentation states that for a private class, a method without an access control specifier will be implicitly a private method(Snapshot1_SwiftDoc) attached. However when the same is executed in a playground, the method is accessible from outside the class(Snapshot2_Playground attached). If we explicitly mark the method as private, then an error is thrown as per Snapshot3_Playground.
The issue is in the book; the behavior is correct: a member without an access control specifier is as accessible as the type declaration if the type declaration is private
, fileprivate
or internal
. In your case, both the class and the method are effectively fileprivate
. @hborla Should we transfer it?
@amartini51 my understanding is the swift-book repo isn't yet taking general content improvement contributions, but I agree with Anthony that it's best to transfer TSPL content issues over there. What do you think?
Thanks, @hborla — I've transferred it over to the TSPL repo. You're correct that our current focus is on publishing the book using DocC, but we do also want to collect known issues with the content here as well, so we can continue to fix them.