@@ -1660,7 +1660,7 @@ extension Person: Equatable {
16601660You can opt out of this inference for a global-actor-isolated type
16611661by explicitly declaring that a protocol conformance is nonisolated.
16621662The following code example declares
1663- a nonisolated isolated conformance to ` Equatable ` in an extension:
1663+ a nonisolated conformance to ` Equatable ` in an extension:
16641664
16651665``` swift
16661666@MainActor
@@ -1690,10 +1690,10 @@ A conformance requirement to `Sendable` allows generic code to send parameter
16901690values to concurrently-executing code. If generic code accepts non-` Sendable `
16911691types, then the generic code can only use the input values from the current
16921692isolation domain. These generic APIs can safely accept isolated conformances
1693- and call protocol requirement as long as the caller is on the same global
1693+ and call protocol requirements as long as the caller is on the same global
16941694actor that the conformance is isolated to. The following code has a protocol
16951695` P ` , a class ` C ` with a main-actor isolated conformance to ` P ` , and
1696- call-sites to the ` P.perform ` requirement from a main-actor
1696+ calls to the ` P.perform ` requirement from a main-actor
16971697task and a concurrent task:
16981698
16991699``` swift
@@ -1732,11 +1732,12 @@ from a concurrent task results in an error,
17321732because it would allow calling the main actor isolated implementation
17331733of ` P.perform ` from outside the main actor.
17341734
1735- Generic code can check whether a value conforms to a protocol
1735+ Abstract code that uses type parameters and ` any ` types
1736+ can check whether a value conforms to a protocol
17361737through dynamic casting.
17371738The following code has a protocol ` P ` ,
17381739and a method ` performIfP ` that accepts a parameter of type ` Any `
1739- which is dynamic cast to ` any P ` in the function body:
1740+ which is dynamically cast to ` any P ` in the function body:
17401741
17411742``` swift
17421743protocol P {
@@ -1754,11 +1755,13 @@ Isolated conformances are only safe to use
17541755when the code is running on the global actor
17551756that the conformance is isolated to,
17561757so the dynamic cast only succeeds
1757- if the dynamic cast occurs on the global actor.
1758- If you declare a main-actor isolated conformance to ` P `
1758+ if the dynamic cast occurs on that global actor.
1759+ For example, if you declare a main-actor isolated conformance to ` P `
17591760and call ` performIfP ` with an instance of the conforming type,
1760- the dynamic cast will only succeed
1761- when ` performIfP ` is called from the main actor:
1761+ the dynamic cast will succeed
1762+ when ` performIfP ` is called in a main actor task, and it
1763+ will fail when ` performIfP ` is called in a concurrent
1764+ task:
17621765
17631766``` swift
17641767@MainActor class C : @MainActor P {
@@ -1790,14 +1793,15 @@ so the dynamic cast fails and `perform` is not called.
17901793
17911794Protocol requirements can be used
17921795through instances of conforming types and through
1793- instances of the conforming types themselves
1796+ instances of the conforming types themselves,
17941797called * metatype values* .
17951798In generic code,
17961799a conformance requirement to ` Sendable ` or ` SendableMetatype `
17971800tells Swift that an instance or metatype value is safe to use concurrently.
17981801To prevent isolated conformances from being used outside of their actor,
17991802a type with an isolated conformance
1800- can't be used for a type that must also satisfy a conformance requirement
1803+ can't be used as the concrete generic argument for a type
1804+ parameter that requires a conformance
18011805to ` Sendable ` or ` SendableMetatype ` .
18021806
18031807A conformance requirement to ` Sendable ` indicates
@@ -1815,7 +1819,7 @@ func performConcurrently<T: P>(_ t: T) where T: Sendable {
18151819}
18161820```
18171821
1818- The above code admits data races if the conformance to ` P ` is isolated,
1822+ The above code would admit data races if the conformance to ` P ` was isolated,
18191823because the implementation of ` perform `
18201824may access global actor isolated state.
18211825To prevent data races,
@@ -1833,7 +1837,8 @@ The above code results in an error
18331837because the conformance of ` C ` to ` P ` is main-actor isolated,
18341838which can't satisfy the ` Sendable ` requirement of ` performConcurrently ` .
18351839
1836- Protocol requirements can also be called through metatype values.
1840+ Static and initializer protocol requirements
1841+ can also be called through metatype values.
18371842A conformance to Sendable on the metatype type,
18381843such as ` Int.Type ` ,
18391844indicates that a metatype value is safe
@@ -1865,7 +1870,7 @@ func performConcurrently<T: P>(n: Int, for: T.Type) async where T: SendableMetat
18651870```
18661871
18671872Without a conformance to ` SendableMetatype ` ,
1868- generic code must only use metatype values in the current isolation domain.
1873+ generic code must only use metatype values from the current isolation domain.
18691874The following code results in an error
18701875because the non-` Sendable ` metatype ` T `
18711876is used from concurrent child tasks:
0 commit comments