@@ -171,28 +171,30 @@ func _rethrowsViaClosure(_ fn: () throws -> ()) rethrows {
171
171
172
172
/// A type whose values can be implicitly or explicitly copied.
173
173
///
174
- /// Although this protocol doesn’t have any required methods or properties,
175
- /// it does have semantic requirements that are enforced at compile time.
176
- /// These requirements are listed in the sections below.
177
- /// XXX what are the requirements -- just that copying is ok?
178
- /// Conformance to `Copyable` must be declared
179
- /// in the same file as the type's declaration.
180
- /// <!-- XXX TR: Confirm previous sentence; borrowed from Sendable docs -->
174
+ /// Conforming to this protocol indicates that a type's value can be copied;
175
+ /// this protocol doesn’t have any required methods or properties.
176
+ /// You don't generally need to write an explicit conformance to `Copyable`.
177
+ /// The following places implicitly include `Copyable` conformance:
181
178
///
182
- /// Conformance to the `Copyable` protocol
183
- /// is implicitly included in the following places:
184
- ///
185
- /// * Structures declarations
186
- /// * Enumerations declarations
179
+ /// * Structures declarations,
180
+ /// unless it has a noncopyable stored property
181
+ /// * Enumerations declarations,
182
+ /// unless it has a case whose associated value isn't copyable
187
183
/// * Class declarations
184
+ /// * Actor declarations
188
185
/// * Protocol declarations
189
186
/// * Associated type declarations
190
187
/// * The `Self` type in a protocol extension
191
188
///
189
+ /// A class or actor can contain noncopyable stored properties,
190
+ /// while still being copyable itself ---
191
+ /// classes and actors are copied by retaining and releasing references.
192
+ ///
192
193
/// In a declaration that includes generic type parameters,
193
194
/// each generic type parameter implicitly includes `Copyable`
194
195
/// in its list of requirements.
195
- /// Metatypes and tuples of copyable types are also implicitly copyable.
196
+ /// Metatypes and tuples of copyable types are also implicitly copyable,
197
+ /// as are boxed protocol types.
196
198
/// For example,
197
199
/// all of the following pairs of declarations are equivalent:
198
200
///
@@ -203,31 +205,29 @@ func _rethrowsViaClosure(_ fn: () throws -> ()) rethrows {
203
205
/// protocol MyProtocol { }
204
206
/// protocol MyProtocol: Copyable { }
205
207
///
206
- /// XXX example of assoc type or Self
208
+ /// protocol AnotherProtocol {
209
+ /// associatedtype MyType
210
+ /// associatedtype MyType: Copyable
211
+ /// }
207
212
///
208
213
/// func genericFunction<T>(t: T) { }
209
214
/// func genericFunction<T>(t: T) where T: Copyable { }
215
+ ///
216
+ /// let x = any MyProtocol
217
+ /// let x = any MyProtocol & Copyable
210
218
/// ```
211
219
///
212
- /// To suppress an implicit conformance to `Copyable`
213
- /// you write `~Copyable`.
220
+ /// To suppress an implicit conformance to `Copyable` you write `~Copyable`.
214
221
/// For example,
215
222
/// only copyable types can conform to `MyProtocol` in the example above,
216
223
/// but both copyable and noncopyable types
217
- /// can conform to the following protocol :
224
+ /// can conform `NoRequirements` in the example below :
218
225
///
219
226
/// ```swift
220
227
/// protocol NoRequirements: ~Copyable { }
221
228
/// ```
222
229
///
223
- /// Extensions on the `Copyable` protocol are not allowed.
224
- ///
225
- /// XXX link to the right chapter
226
- /// For information about the language-level concurrency model that `Task` is part of,
227
- /// see [Concurrency][concurrency] in [The Swift Programming Language][tspl].
228
- ///
229
- /// [concurrency]: https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html
230
- /// [tspl]: https://docs.swift.org/swift-book/
230
+ /// Extensions to the `Copyable` protocol are not allowed.
231
231
@_marker public protocol Copyable { }
232
232
233
233
@_marker public protocol Escapable { }
0 commit comments