Skip to content

[5.10][Concurrency] Allow default arguments to require actor isolation. #69149

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

Merged

Conversation

hborla
Copy link
Member

@hborla hborla commented Oct 12, 2023

  • Explanation: This is the experimental implementation of allowing default arguments to call global-actor-isolated functions. Actor isolation checking is deferred to the caller; it is an error to use a default argument from across isolation domains. Though this is experimental, cherry-picking is useful to make cherry-picking other actor isolation checker bug fixes easier, and it leaves open the opportunity to close the data-race hole with global-actor-isolated instance properties in 5.10 if the feature is accepted.
  • Scope: Limited to the actor isolation checker. The implementation is gated behind -enable-experimental-feature IsolatedDefaultValues, so it will not impact existing code.
  • Risk: Low; the feature is not actually enabled.
  • Testing: Added new tests.
  • Reviewer: @xedin @ktoso
  • Issue: rdar://101058224
  • Main branch PR: [Concurrency] Allow default arguments to require actor isolation. #68794, [Concurrency] Rename IsolatedDefaultArguments to IsolatedDefaultValues. #69030

Type checking a default argument expression will compute the required
actor isolation for evaluating that argument value synchronously. Actor
isolation checking is deferred to the caller; it is an error to use a
default argument from across isolation domains.

Currently gated behind -enable-experimental-feature IsolatedDefaultArguments.

(cherry picked from commit 95a7107)
…d isolation

for a default argument, and improve diagnostics for conflicting isolation.

(cherry picked from commit 88b2332)
properties to require actor isolation.

Member initializer expressions are only used in a constructor with
matching actor isolation. If the isolation prohibits the member
initializer from being evaluated synchronously (or propagating required
isolation through closure bodies), then the default value cannot be used
and the member must be explicitly initialized in the constructor.

Member initializer expressions are also used as default arguments for the
memberwise initializer, and the same rules for default argument isolation
apply.

(cherry picked from commit 7f11947)
…allers to go

through the DefaultInitializerIsolation request.

(cherry picked from commit 67e3326)
@hborla hborla requested a review from a team as a code owner October 12, 2023 14:35
@hborla
Copy link
Member Author

hborla commented Oct 12, 2023

@swift-ci please test

@hborla hborla merged commit 533bcda into swiftlang:release/5.10 Oct 12, 2023
@hborla hborla deleted the 5.10-isolated-initializer-expressions branch October 12, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants