Skip to content

Various fixes for @preconcurrency #73698

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
merged 5 commits into from
May 17, 2024

Conversation

DougGregor
Copy link
Member

Audit the places where we do Sendable checking to ensure that they handle @preconcurrency appropriately, and fix several issues:

  • Diagnosing @Sendable methods on a non-Sendable type
  • Diagnosing a non-Sendable nonisolated let
  • Diagnosing access to non-Sendable instance properties of an actor-isolated type within the deinitializer

Moreover, make sure that we correctly check for @preconcurrency for the actual non-Sendable nominal types that occur within a larger type expression, e.g., the NS in NS? rather than only looking at the outer optional. This makes @preconcurrency work properly for arrays, optionals, sets, etc. of non-Sendable types. Fixes rdar://125081249

…es in deinit

Instance properties of non-sendable types cannot safely be
accessed within deinitializers. Make sure we respect `@preconcurrency`
when diagnosing these.
When determining whether a non-sendable type is a nominal type that is
affected by `@preconcurrency`, be sure to look at the specific type
even when it's part of larger type, e.g., the `NS` in `NS?`. This
makes `@preconcurrency` work properly through structural types like
arrays, optionals, and dictionaries.

While here, also check whether the nominal declaration itself has been
marked as `@preconcurrency`.

Fixes rdar://125081249.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaics LGTM

@DougGregor DougGregor merged commit af51b5f into swiftlang:main May 17, 2024
@DougGregor DougGregor deleted the preconcurrency-fixes branch May 17, 2024 16:53
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