[SE-0466] Under main actor default isolation, explicit nonisolated is not special

Given an explicitly-nonisolated type such as

    nonisolated struct S { }

all extensions of S were also being treated as nonisolated. This meant
that being implicitly nonisolated (i.e., when you're using nonisolated
default isolation) was different from explicitly-writing nonisolated,
which is unfortunate and confusing. Align the rules, such that an
extension of S will get default isolation:

    extension S {
      func f() { } // @MainActor if we're in main actor default isolation
    }
This commit is contained in:
Doug Gregor
2025-07-24 22:52:15 -07:00
parent 4ffe06ed7c
commit 5abbf2e4c9
5 changed files with 60 additions and 3 deletions

View File

@@ -332,6 +332,10 @@ EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)
/// Disable the special behavior of of explicit 'nonisolated' vs. being
/// implicitly nonisolated.
EXPERIMENTAL_FEATURE(NoExplicitNonIsolated, true)
/// Enables a module to allow non resilient access from other
/// modules within a package if built from source.
EXPERIMENTAL_FEATURE(AllowNonResilientAccessInPackage, false)