---
title: Isolated conformances (IsolatedConformances)
framework: swift-compiler
role: article
role_heading: Article
path: swift-compiler/documentation/diagnostics/isolated-conformances
---

# Isolated conformances (IsolatedConformances)

## Overview

Overview Using an isolated conformance from outside the actor can cause data races in your program. Resolve these errors by only using isolated conformances within the actor. A protocol conformance can be isolated to a specific global actor, meaning that the conformance can only be used by code running on that actor. Isolated conformances are expressed by specifying the global actor on the conformance itself: protocol P {   func f() }

@MainActor class MyType: @MainActor P {   /*@MainActor*/ func f() {     // must be called on the main actor   } } Swift will produce diagnostics if the conformance is directly accessed in code that isn’t guaranteed to execute in the same global actor. For example: func acceptP<T: P>(_ value: T) { }

/*nonisolated*/ func useIsolatedConformance(myType: MyType) {   acceptP(myType) // error: main actor-isolated conformance of 'MyType' to 'P' cannot be used in nonisolated context } To address this issue, mark the code as having the same global actor as the conformance it is trying to use. In this case, mark useIsolatedConformance as @MainActor so that the code is guaranteed to execute on the main actor. An isolated conformance cannot be used together with a Sendable requirement, because doing so would allow the conformance to cross isolation boundaries and be used from outside the global actor. For example: func acceptSendableP<T: P & Sendable>(_ value: T) { }

@MainActor func useIsolatedConformanceOnMainActor(myType: MyType) {   acceptSendableP(myType) // error: main-actor-isolated conformance of 'MyType' to 'P' cannot satisfy conformance requirement for 'Sendable' type parameter 'T' } These errors can be addressed by either making the conformance itself nonisolated or making the generic function not require Sendable.

## See Also

- [@dynamicCallable implementation requirements (DynamicCallable)](swift-compiler/documentation/diagnostics/dynamic-callable-requirements.md)
- [Add @preconcurrency import (AddPreconcurrencyImport)](swift-compiler/documentation/diagnostics/add-preconcurrency-import.md)
- [Always enabled availability domains (AlwaysAvailableDomain)](swift-compiler/documentation/diagnostics/always-available-domain.md)
- [Argument matching for trailing closures (TrailingClosureMatching)](swift-compiler/documentation/diagnostics/trailing-closure-matching.md)
- [Calling a mutating async actor-isolated method (ActorIsolatedMutatingAsync)](swift-compiler/documentation/diagnostics/actor-isolated-mutating-async.md)
- [Calling an actor-isolated method from a synchronous nonisolated context (ActorIsolatedCall)](swift-compiler/documentation/diagnostics/actor-isolated-call.md)
- [Captures in a `@Sendable` closure (SendableClosureCaptures)](swift-compiler/documentation/diagnostics/sendable-closure-captures.md)
- [Compilation caching (CompilationCaching)](swift-compiler/documentation/diagnostics/compilation-caching.md)
- [Conforming to `StringInterpolationProtocol` (StringInterpolationConformance)](swift-compiler/documentation/diagnostics/string-interpolation-conformance.md)
- [Conversion from `@isolated(any)` function type to synchronous function type (ConversionFromIsolatedAnyToSynchronous)](swift-compiler/documentation/diagnostics/conversion-from-isolated-any-to-synchronous.md)
- [Cross-isolation data race (RegionIsolationCrossIsolationDataRace)](swift-compiler/documentation/diagnostics/region-isolation-cross-isolation-data-race.md)
- [Deprecated declaration warnings (DeprecatedDeclaration)](swift-compiler/documentation/diagnostics/deprecated-declaration.md)
- [Deprecated implementation-only imports (ImplementationOnlyDeprecated)](swift-compiler/documentation/diagnostics/implementation-only-deprecated.md)
- [Dynamic exclusivity (DynamicExclusivity)](swift-compiler/documentation/diagnostics/dynamic-exclusivity.md)
- [Embedded Swift language restrictions (EmbeddedRestrictions)](swift-compiler/documentation/diagnostics/embedded-restrictions.md)
