Skip to content

[TypeChecker/NameLookup] SE-0463: A few fixes for SendableCompletionHandlers feature #79478

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
Mar 4, 2025

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Feb 19, 2025

  • Allow @objc @implementation to mismatch on @Sendable in parameter positions

    Warn about missing @Sendable annotations (even in Swift 6 language mode) to give users and developers time to adopt Swift concurrency.

  • Shadowing: strip @Sendable annotations for declarations ObjC/@objc declarations to avoid ambiguities until shadowing declarations adopt @Sendable.

  • Strip Sendable while processing AnyObject lookup results

  • Allow associated type inference to skip @Sendable on ObjC witnesses

  • Fix @_dynamicReplacement to skip sendable annotations on ObjC declarations

Resolves: rdar://85569247

@xedin
Copy link
Contributor Author

xedin commented Feb 19, 2025

@swift-ci please test

@xedin xedin force-pushed the sendable-completion-handler-fixes branch from f858d63 to bbe2e1c Compare February 19, 2025 01:58
@xedin
Copy link
Contributor Author

xedin commented Feb 19, 2025

@swift-ci please test

@xedin xedin force-pushed the sendable-completion-handler-fixes branch from bbe2e1c to 7e0996c Compare February 19, 2025 02:19
@xedin
Copy link
Contributor Author

xedin commented Feb 19, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Feb 19, 2025

@swift-ci please test Linux platform

@xedin
Copy link
Contributor Author

xedin commented Feb 19, 2025

@swift-ci please test Linux platform

@xedin xedin force-pushed the sendable-completion-handler-fixes branch from 7e0996c to aa1c79d Compare February 21, 2025 02:36
@xedin
Copy link
Contributor Author

xedin commented Feb 21, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Feb 21, 2025

@swift-ci please test source compatibility

…` in parameter positions

Just like for protocol matching, let's allow `@Sendable` mismatches
in parameter positions to make sure that it's possible for header
authors to add concurrency annotations without breaking clients.

This is especially important for `SendableCompletionHandlers` feature
that makes imported sync completion handler parameters `@Sendable`.
…s ObjC/@objc declarations

When `SendableCompletionHandlers` feature is enabled, ClangImporter
is going to inject `@Sendable` attribute into the completion handler
parameter's function type. We need to make sure that his new behavior
doesn't break shadowing rules and allow APIs to annotate their ObjC
declarations with `@Sendable` without breaking clients.
@xedin xedin force-pushed the sendable-completion-handler-fixes branch from aa1c79d to 0004a4b Compare February 21, 2025 22:24
@xedin
Copy link
Contributor Author

xedin commented Feb 21, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Feb 21, 2025

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Feb 24, 2025

@swift-ci please test source compatibility

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Feb 24, 2025

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Feb 24, 2025

@swift-ci please test source compatibility release

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Feb 24, 2025

@swift-ci please test source compatibility release

@xedin
Copy link
Contributor Author

xedin commented Feb 25, 2025

@swift-ci please test source compatibility

…esults

All of the declarations returned by dynamic `AnyObject` lookup
are `@objc` and hence `@preconcurrency` which means that it should
be possible to introduce `@Sendable` and `any Sendable` annotations
without affecting lookup and shadowing behavior.
@xedin
Copy link
Contributor Author

xedin commented Feb 28, 2025

@swift-ci please test

@xedin xedin force-pushed the sendable-completion-handler-fixes branch from 332c3ca to 15a0e5a Compare February 28, 2025 19:12
@xedin
Copy link
Contributor Author

xedin commented Feb 28, 2025

@swift-ci please test

@xedin xedin changed the title [TypeChecker/NameLookup] A few fixes for SendableCompletionHandlers feature [TypeChecker/NameLookup] SE-0463: A few fixes for SendableCompletionHandlers feature Feb 28, 2025
…tnesses

Witness checking itself is allowed to skip `@Sendable` mismatch in this
situation. This is a narrow fix for `SendableCompletionHandlers` feature
to make sure that the behavior doesn't change for non-ObjC witnesses
… on ObjC declarations

Refactors `@_dynamicReplacement` attribute verification to consider
only exact matches first, and if there are none, attempt to strip
away sendability on ObjC declarations to make sure that any new
`@Sendable` or `any Sendable` introduced to `@precocurrency` declarations
don't break the overload selection.
@xedin xedin force-pushed the sendable-completion-handler-fixes branch from 15a0e5a to bb247d7 Compare February 28, 2025 21:24
@xedin
Copy link
Contributor Author

xedin commented Feb 28, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Mar 3, 2025

@swift-ci please smoke test

@xedin xedin merged commit 157e71a into swiftlang:main Mar 4, 2025
5 checks passed
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