Skip to content

Concurrency: Reject nonisolated lazy properties #76518

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 1 commit into from
Sep 17, 2024

Conversation

slavapestov
Copy link
Contributor

We already banned nonisolated property wrappers, and 'lazy' is conceptually similar, so it makes sense to disallow it also.

Fixes #76513.

We already banned nonisolated property wrappers, and 'lazy' is
conceptually similar, so it makes sense to disallow it also.

Fixes swiftlang#76513.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit ad68d22 into swiftlang:main Sep 17, 2024
3 checks passed
@vanvoorden
Copy link
Contributor

vanvoorden commented Feb 13, 2025

@slavapestov Ahh… so I just now ran into the 'nonisolated' is not supported on lazy properties error on my project building from 6.1. :(

I thought this was a feature… but it was a bug this whole time. :(

Hmm… any high level conceptual directions I could at look for a workaround when 6.1 goes live?

I am building from Swift 6 concurrency mode… it looks like Swift 5 mode only shows a warning?

@vanvoorden
Copy link
Contributor

The workaround I ended up with was boxing my original type without the nonisolated lazy in another actor. The Parent actor can then use lazy to construct a Child on demand. Seems to work… for now…

Would you know if there were any more in progress diffs related to nonisolated variables that I might want to follow along and watch to learn more what is happening? Is there anything else you can think of I should keep an eye out for?

@vanvoorden
Copy link
Contributor

vanvoorden commented May 14, 2025

https://forums.swift.org/t/accepted-se-0481-weak-let/79895/

Do we know if this would this at all affect a potential nonisolated lazy let built from the 6.2 toolchain?

I might have misread the proposal. I don't think lazy let was explicitly proposed.

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.

It is possible to declare nonisolated lazy var on actor in Swift 6
2 participants