Skip to content

[SE-0466] Account for nonisolated functions and extensions, too #2916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 16 additions & 1 deletion proposals/0466-control-default-actor-isolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ When the default actor isolation is specified as `MainActor`, declarations are i
* All declarations inside an `actor` type, including static variables, methods, initializers, and deinitializers
* Declarations that cannot have global actor isolation, including typealiases, import statements, enum cases, and individual accessors
* Declarations whose primary definition directly conforms to a protocol that inherits `SendableMetatype`
* Declarations that are types nested within a nonisolated type
* Declarations that are nested within a nonisolated type, function, or extension

The following code example shows the inferred actor isolation in comments given the code is built with `-default-isolation MainActor`:

Expand All @@ -87,6 +87,21 @@ class C {

// @MainActor
static var value = 10

nonisolated func f() {
// nonisolated
struct Nested {
// ...
}
}
}

nonisolated extension C {
// nonisolated
func g() { }

// nonisolated
struct NestedInExtension { }
}

@globalActor
Expand Down