---
title: isolation()
framework: swift
role: symbol
role_heading: Macro
path: swift/isolation()
---

# isolation()

Produce a reference to the actor to which the enclosing code is isolated, or nil if the code is nonisolated.

## Declaration

```swift
@freestanding(expression) macro isolation<T>() -> T
```

## Overview

Overview If the type annotation provided for #isolation is not (any Actor)?, the type must match the enclosing actor type. If no type annotation is provided, the type defaults to (any Actor)?.

## See Also

### Actors

- [Sendable](swift/sendable.md)
- [Actor](swift/actor.md)
- [AnyActor](swift/anyactor.md)
- [MainActor](swift/mainactor.md)
- [GlobalActor](swift/globalactor.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [ConcurrentValue](swift/concurrentvalue.md)
- [UnsafeSendable](swift/unsafesendable.md)
- [UnsafeConcurrentValue](swift/unsafeconcurrentvalue.md)
- [extractIsolation(_:)](swift/extractisolation(_:).md)
