---
title: Sendable metatypes (SendableMetatypes)
framework: swift-compiler
role: article
role_heading: Article
path: swift-compiler/documentation/diagnostics/sendable-metatypes
---

# Sendable metatypes (SendableMetatypes)

## Overview

Overview Types that are shared in concurrent code generally need to conform to Sendable. The same is true in generic code when sharing parameters of a generic parameter T. For example, the given code will produce an error under strict concurrency checking func doSomethingElsewhere<T>(_ value: T) {   Task { @concurrent in     print(value) // warning: capture of non-Sendable type 'T'   } } because value can have a non-Sendable type that is not safe to share. To address this potential data race, the type T can be marked as Sendable: func doSomethingElsewhere<T: Sendable>(_ value: T) {   Task { @concurrent in     print(value)   } } The same issue can occur when passing the type T itself, rather than a value of type T. The compiler will indicate such problems by noting that the metatype of T, spelled T.Type, is not Sendable: protocol P {   static func doSomething() }

func doSomethingStatic<T: P>(_: T.Type) {   Task { @concurrent in     T.doSomething() // warning: capture of non-Sendable type 'T.Type' in an isolated closure   } } In these cases, the type parameter should be required to conform to the SendableMetatype protocol, e.g., func doSomethingStatic<T: P & SendableMetatype>(_: T.Type) {   Task { @concurrent in     T.doSomething()   } } The SendableMetatype requirement allows the function to share the type T in concurrent code. To maintain data race safety, it prevents callers from using isolated conformances in the call. For example, the following code will be rejected due to a data race: @MainActor class C: @MainActor P {   static func doSomething() { } }

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

The conformance of C to P can only be used on the main actor, so it cannot be provided to doSomethingStatic, which calls the conformance from a different concurrent task.

## 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)
