[6.0][Concurrency] Implement a narrow carve out in the isolation override checking for NSObject.init().
#75749
+39
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: [6.0][Concurrency] Don't ignore mismatching isolation for overrides of Clang-imported superclass methods. #74238 added new data-race safety diagnostics for overriding the isolation of a superclass method that's imported from Objective-C. This started diagnosing
@MainActor-isolated types that overrideNSObject.init.Now, overriding
NSObject.init()within a@MainActor-isolated type is difficult-to-impossible, especially if you need to call an initializer from an intermediate superclass that is also@MainActor-isolated. Standard opt-out tools likeMainActor.assumeIsolatedcannot be applied to things like stored property initialization andsuper.init(), making the issue extremely difficult to work around. This is a major usability regression for programs that interoperate with Objective-C and make heavy use of@MainActor-isolated types.Scope: Only impacts isolated overrides of
NSObject.init().Issues: Swift 6 regression overriding initializers due to Swift Concurrency #75732, rdar://133349184
Original PRs: [Concurrency] Implement a narrow carve out in the isolation override checking for
NSObject.init(). #75748Risk: Low; the only effect is removing warnings in complete concurrency checking / errors in Swift 6 mode. This carve-out won't admit a runtime data-race safety hole, because dynamic isolation checks will be inserted in the
@objcthunks underDynamicActorIsolation, and direct calls will enforce@MainActoras usual.Testing: Added new tests.
Reviewers: TBD