Skip to content

Fix inconsistencies with isolated parameters. #61862

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 2 commits into from
Nov 12, 2022

Conversation

kavon
Copy link
Member

@kavon kavon commented Nov 2, 2022

subsumes #60483

There are a whole bunch of ways the rules about isolated parameters are either not being enforced, or the wrong isolation is being used for such functions. This PR tries to sharpen the definition and rules so they make sense.

TODOs:

  • maybe move the check to TypeChecker::checkParameterList
  • fix isolation for subscript (seems to default to nonisolated) deferred.
  • make sure isolation for initializers is working / covered (doesn't check isolation at all?) deferred.
  • fix isolation for function values like this:
@MainActor
func update<R>(_ callback: @Sendable @escaping @MainActor (isolated Foo) -> R) -> R {
  callback(Foo()) // error: call to actor-isolated parameter 'callback' in a synchronous main actor-isolated context
}
  • enforce the rules for closures

resolves rdar://100039019

@kavon
Copy link
Member Author

kavon commented Nov 2, 2022

@swift-ci please test

@ktoso
Copy link
Contributor

ktoso commented Nov 2, 2022

Looking good so far! I am confused about: 46fd8e2 (#61862) this is not the semantics I'd expect there.

@kavon kavon marked this pull request as draft November 2, 2022 15:17
@ktoso ktoso requested a review from DougGregor November 9, 2022 09:09
@kavon kavon force-pushed the isolated-param-holes-100039019 branch from 46fd8e2 to 3e93923 Compare November 11, 2022 03:28
@ktoso
Copy link
Contributor

ktoso commented Nov 11, 2022

Resolves #60474

@kavon
Copy link
Member Author

kavon commented Nov 11, 2022

@swift-ci please test

@kavon kavon force-pushed the isolated-param-holes-100039019 branch 2 times, most recently from df6f8ea to ae6686c Compare November 11, 2022 23:44
This covers function types, closures, and function declarations:

- only one `isolated` parameter
- no global-actor + `isolated` parameter
- no `nonisolated` + `isolated`.

all diagnostics are warnings until Swift 6
@kavon kavon force-pushed the isolated-param-holes-100039019 branch from ae6686c to 3b3bdaf Compare November 12, 2022 00:00
@kavon
Copy link
Member Author

kavon commented Nov 12, 2022

@swift-ci please test and merge

@kavon kavon marked this pull request as ready for review November 12, 2022 04:09
@kavon kavon merged commit 6d75fac into swiftlang:main Nov 12, 2022
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