Skip to content

[Constraint solver] Don't adjust types in calls to @preconcurrency functions #59849

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

DougGregor
Copy link
Member

When calling a @preconcurrency function, don't adjust the types of parameters, because SILGen considers such calls to be invalid and will assert. Instead, suppress or alter diagnostics later on to deal with Sendable and global-actor mismatches.

Fix rdar://95995193

…functions

When calling a `@preconcurrency` function, don't adjust the types of
parameters. Instead, we'll suppress or alter diagnostics later on to deal
with Sendable and global-actor mismatches.

Fixes the crash from rdar://95995193, but diagnostics need more work.
Instead of the `warning` Boolean threaded through the solver's
diagnostics, thread `DiagnosticBehavior` to be used as the behavior
limit. Use this for concurrency checking (specifically dropped
`@Sendable` and dropped global actors) so the solver gets more control
over these diagnostics.

This change restores the diagnostics to a usable state after the prior
change, which introduced extra noise. The only change from existing
beavior is that dropping a global actor from a function type is now
always a warning in Swift < 6. This is partly intentional, because
there are some places where dropping the global actor is well-formed.
@DougGregor DougGregor changed the title [Constriant solver] Don't adjust types in calls to @preconcurrency functions [Constraint solver] Don't adjust types in calls to @preconcurrency functions Jul 1, 2022
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

The type checker is now permitting `@Sendable` closures whose captures
can be by-reference, because we do not error. Remove an aspirational
SIL verifier check that banned this.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit afd65fa into swiftlang:main Jul 2, 2022
@DougGregor DougGregor deleted the preconcurrency-sendable-params branch July 3, 2022 05:51
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.

3 participants