Skip to content

Commit 6e6fe53

Browse files
authored
Remove redundant list of access levels (#376)
Fixes: rdar://151045991
2 parents 45c9ae6 + 2e54fc2 commit 6e6fe53

File tree

1 file changed

+11
-43
lines changed

1 file changed

+11
-43
lines changed

TSPL.docc/LanguageGuide/AccessControl.md

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -169,61 +169,29 @@ and compile that product module with testing enabled.
169169
## Access Control Syntax
170170

171171
Define the access level for an entity by placing
172-
one of the `open`, `public`, `internal`, `fileprivate`, or `private` modifiers
172+
one of the modifiers listed in <doc:AccessControl#Access-Levels>,
173+
such as `public` or `private`,
173174
at the beginning of the entity's declaration.
175+
For example:
174176

175177
```swift
176-
open class SomeOpenClass {}
177178
public class SomePublicClass {}
178-
internal class SomeInternalClass {}
179-
fileprivate class SomeFilePrivateClass {}
180-
private class SomePrivateClass {}
181-
182-
open var someOpenVariable = 0
183-
public var somePublicVariable = 0
184-
internal let someInternalConstant = 0
185-
fileprivate func someFilePrivateFunction() {}
179+
internal struct SomeInternalStruct() {}
186180
private func somePrivateFunction() {}
187181
```
188182

189-
<!--
190-
- test: `accessControlSyntax`
191-
192-
```swifttest
193-
-> open class SomeOpenClass {}
194-
-> public class SomePublicClass {}
195-
-> internal class SomeInternalClass {}
196-
-> fileprivate class SomeFilePrivateClass {}
197-
-> private class SomePrivateClass {}
198-
199-
-> open var someOpenVariable = 0
200-
-> public var somePublicVariable = 0
201-
-> internal let someInternalConstant = 0
202-
-> fileprivate func someFilePrivateFunction() {}
203-
-> private func somePrivateFunction() {}
204-
```
205-
-->
206-
207-
Unless otherwise specified, the default access level is internal,
183+
The code above declares `SomePublicClass` as public,
184+
`SomeInternalStruct` as internal,
185+
and `somePrivateFunction()` as private.
186+
If you don't write an explicit access level,
187+
the default access level modifier is `internal`,
208188
as described in <doc:AccessControl#Default-Access-Levels>.
209-
This means that `SomeInternalClass` and `someInternalConstant` can be written
210-
without an explicit access-level modifier,
211-
and will still have an access level of internal:
189+
For example, in the code below, `SomeInternalStruct` is implicitly internal:
212190

213191
```swift
214-
class SomeInternalClass {} // implicitly internal
215-
let someInternalConstant = 0 // implicitly internal
192+
struct SomeInternalStruct() {}
216193
```
217194

218-
<!--
219-
- test: `accessControlDefaulted`
220-
221-
```swifttest
222-
-> class SomeInternalClass {} // implicitly internal
223-
-> let someInternalConstant = 0 // implicitly internal
224-
```
225-
-->
226-
227195
## Custom Types
228196

229197
If you want to specify an explicit access level for a custom type,

0 commit comments

Comments
 (0)