Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion swift-concurrency/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ Project settings that change concurrency behavior:
| Strict concurrency | `.enableExperimentalFeature("StrictConcurrency=targeted")` | `SWIFT_STRICT_CONCURRENCY` |
| Default isolation | `.defaultIsolation(MainActor.self)` | `SWIFT_DEFAULT_ACTOR_ISOLATION` |
| Upcoming features | `.enableUpcomingFeature("NonisolatedNonsendingByDefault")` | `SWIFT_UPCOMING_FEATURE_*` |
| Approachable Concurrency | N/A (use individual upcoming features) | `SWIFT_APPROACHABLE_CONCURRENCY` |

If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance. Do not guess.
> **Xcode 26 note**: New projects created in Xcode 26 will often start with `SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor` and `SWIFT_APPROACHABLE_CONCURRENCY = YES` enabled by default. Treat these as likely defaults for newly created projects, not as confirmed settings.

If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance. Do not guess, even for new Xcode 26 projects.

Guardrails:

Expand Down Expand Up @@ -58,6 +61,7 @@ Skip Quick Fix Mode when any of these are true:
| Core Data concurrency warnings | Are `NSManagedObject` instances crossing contexts or actors? | Pass `NSManagedObjectID` or map to a Sendable value type. | `references/core-data.md` |
| `Thread.current` unavailable from asynchronous contexts | Are you debugging by thread instead of isolation? | Reason in terms of isolation and use Instruments/debugger instead. | `references/threading.md` |
| SwiftLint concurrency-related warnings | Which specific lint rule triggered? | Use `references/linting.md` for rule intent and preferred fixes; avoid dummy awaits. | `references/linting.md` |
| `... cannot satisfy conformance requirement for a 'Sendable' type parameter` (`SendableMetatype`) | Does the conformance carry global-actor isolation? | Remove actor isolation from the conformance, or avoid passing the metatype across isolation boundaries. See `SendableMetatype` section in `references/actors.md`. | `references/actors.md` |

## When Quick Fixes Fail

Expand Down
41 changes: 41 additions & 0 deletions swift-concurrency/references/actors.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,47 @@ extension PersonViewModel: @MainActor Equatable {

> **Course Deep Dive**: This topic is covered in detail in [Lesson 5.6: Adding isolated conformance to protocols](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=lesson-reference)

### `SendableMetatype` Error with Isolated Conformances

Isolated conformances **cannot** satisfy a `SendableMetatype` requirement. This surfaces when you pass `MyClass.self` to a generic function whose type parameter requires `Sendable`.

```swift
protocol P {
static func doSomething()
}

func doSomethingStatic<T: P & SendableMetatype>(_ type: T.Type) { } // explicitly requires a Sendable type/metatype

@MainActor
class C { }

extension C: @MainActor P {
static func doSomething() { }
}

@MainActor
func test(c: C) {
doSomethingStatic(C.self)
// ❌ main actor-isolated conformance of 'C' to 'P' cannot satisfy
// conformance requirement for a 'Sendable' type parameter
}
```

**Fix options**:

1. Remove actor isolation from the original conformance if the protocol requirements don't access actor state:

```swift
@MainActor
class C: P {
nonisolated static func doSomething() { } // ✅ Non-isolated requirement on a non-isolated conformance
}
```

2. Avoid passing the metatype across isolation boundaries — call the static method directly rather than routing through the generic function.

3. Make the generic function actor-aware so it accepts an isolated conformance (requires changing the callee's signature).

## Actor Reentrancy

**Critical**: State can change between suspension points.
Expand Down