Skip to content

Conversation

@xedin
Copy link
Contributor

@xedin xedin commented Feb 7, 2026

  • Explanation:

    When default isolation is set to MainActor a type should be considered nonisolated if it's primary definition is stated to conform to a Sendable or SendableMetatype protocol. But default isolation computation currently produces "unspecified" instead which cannot be used as a condition during conformance isolation inference and so some implied conformances are wrongly considered to be @MainActor.

    The change adjusts the default isolation computation to produce nonisolated isolation in the case described above and adds a condition to the conformance isolation checking to prevent inferring @MainActor from an extension if a type itself is nonisolated.

  • Resolves: rdar://166542727

  • Main branch PR: [Concurrency] Mark a type as nonisolated if a conformance requires it #86682

  • Risk: Low. This change allows more code to type-check in @MainActor as default isolation mode and affects only extensions.

  • Reviewed By: @hborla

  • Testing: Added new test-cases to the suite.

xedin added 3 commits February 6, 2026 16:20
When default isolation is set to `MainActor` a type should be
considered `nonisolated` if it's primary definition is stated
to conform to a `Sendable` or `SendableMetatype` protocol. But
default isolation computation currently produces "unspecified"
instead which cannot be used as a condition during conformance
isolation inference and so some implied conformances are
wrongly considered to be `@MainActor`.

The change adjusts the default isolation computation to produce
`nonisolated` isolation in the case described above and adds
a condition to the conformance isolation checking to prevent
inferring `@MainActor` from an extension if a type itself is
`nonisolated`.

Resolves: rdar://166542727
(cherry picked from commit 4646ca1)
… default mode

Members declared in an extension are @mainactor isolated
even if it's an extension of a nonisolated type. This helps
to extend types from other modules, for example, to conform
to new protocols declared in @mainactor isolated module without
having to explicitly state `@MainActor`.

(cherry picked from commit a71a7d2)
…d only if both type and witness are

Conformance is considered `nonisolated` only if both type and witness
are nonisolated at the same time, otherwise it would be `@MainActor`.

(cherry picked from commit 3b239b3)
@xedin xedin requested a review from a team as a code owner February 7, 2026 00:24
@xedin xedin added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.3 labels Feb 7, 2026
@xedin
Copy link
Contributor Author

xedin commented Feb 9, 2026

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Feb 10, 2026

@swift-ci please test Windows platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks swift 6.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant