Skip to content

Commit eb2b522

Browse files
authored
Merge pull request #76768 from kubamracek/embedded-docs10
[embedded] Adjust docs to clarify support for class-bound existentials
2 parents 0fa07ba + ca3a7f4 commit eb2b522

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

docs/EmbeddedSwift/EmbeddedSwiftStatus.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ For an introduction and motivation into Embedded Swift, please see "[A Vision fo
88

99
## Embedded Swift Language Features
1010

11-
| **Language Feature** | **Currently Supported In Embedded Swift** |
12-
|-------------------------------------------------------|-------------------------------------------|
13-
| *Anything not listed below* | Yes |
14-
| Library Evolution (resilience) | No, intentionally unsupported long-term |
15-
| Objective-C interoperability | No, intentionally unsupported long-term |
16-
| Non-WMO builds | No, intentionally unsupported long-term (WMO should be used) |
17-
| Existentials | No, currently disallowed |
18-
| Any, AnyObject | No, currently disallowed |
19-
| Metatypes | No, currently only allowed as unused arguments (type hints) |
20-
| Untyped throwing | No, intentionally unsupported long-term (typed throwing should be used instead) |
21-
| Weak references, unowned references | No |
22-
| Non-final generic class methods | No, intentionally unsupported long-term |
23-
| Parameter packs (variadic generics) | No, not yet supported |
11+
| **Language Feature** | **Currently Supported In Embedded Swift** |
12+
|-------------------------------------------------------|------------------------------------------------------------------------------------|
13+
| *Anything not listed below* | Yes |
14+
| Library Evolution (resilience) | No, intentionally unsupported long-term |
15+
| Objective-C interoperability | No, intentionally unsupported long-term |
16+
| Non-WMO builds | No, intentionally unsupported long-term (WMO should be used) |
17+
| Existentials (values of protocol types) | Only class-bound existentials (for protocols derived from AnyObject) are supported |
18+
| Any | No, currently disallowed |
19+
| AnyObject | Yes |
20+
| Metatypes | No, currently only allowed as unused arguments (type hints) |
21+
| Untyped throwing | No, intentionally unsupported long-term (typed throwing should be used instead) |
22+
| Weak references, unowned references | No |
23+
| Non-final generic class methods | No, intentionally unsupported long-term |
24+
| Parameter packs (variadic generics) | No, not yet supported |
2425

2526
## Embedded Standard Library Breakdown
2627

docs/EmbeddedSwift/UserManual.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ func sayHello() {
164164
}
165165
```
166166

167-
Additionally, you can also use an attribute (also experimental, and not source stable) to make entire functions, types and other declarations unavailable in Embedded Swift. This can be particularly useful to explicitly mark your own code (and also entire types and conformances) that relies on features unavailable in Embedded Swift, e.g. existentials or strings -- it is explicitly allowed to use those in unavailable contexts:
167+
Additionally, you can also use an attribute (also experimental, and not source stable) to make entire functions, types and other declarations unavailable in Embedded Swift. This can be particularly useful to explicitly mark your own code (and also entire types and conformances) that relies on features unavailable in Embedded Swift, e.g. the Any type or Codable -- it is explicitly allowed to use those in unavailable contexts:
168168

169169
```swift
170170
@_unavailableInEmbedded
171-
func useAnExistential(_: Any) { ... }
171+
func useAny(_: Any) { ... }
172172

173173
@_unavailableInEmbedded
174-
extension MyStruct: CustomStringConvertible {
175-
var description: String { return "..." }
174+
extension MyStruct: Codable {
175+
...
176176
}
177177
```
178178

@@ -183,7 +183,7 @@ Embedded Swift is a subset of the Swift language, and some features are not avai
183183
Features that are not available:
184184

185185
- **Not available**: Runtime reflection (`Mirror` APIs).
186-
- **Not available**: Values of protocol types ("existentials"), e.g. `let a: Hashable = ...`, are not allowed. `Any` and `AnyObject` are also not allowed.
186+
- **Not available**: Values of protocol types ("existentials"), unless the protocol is restricted to be class-bound (derived from AnyObject). E.g. `let a: Hashable = ...` is not allowed. `Any` is also not allowed.
187187
- **Not available**: Metatypes, e.g. `let t = SomeClass.Type` or `type(of: value)` are not allowed.
188188
- **Not available**: Printing and stringification of arbitrary types (achieved via reflection in desktop Swift).
189189
- **Not available yet (under development)**: Swift Concurrency.

0 commit comments

Comments
 (0)