Skip to content

[Concurrency] Implement an experimental feature for setting default actor isolation per file using a typealias. #80572

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

Closed
wants to merge 2 commits into from

Conversation

hborla
Copy link
Member

@hborla hborla commented Apr 6, 2025

This feature is gated behind the DefaultIsolationTypealias experimental feature flag.

Pitch discussion is at https://forums.swift.org/t/pitch-a-typealias-for-per-file-default-actor-isolation/79150. Please leave design feedback on the forums!

@hborla hborla force-pushed the default-actor-isolation branch from ad394f8 to 734ce1a Compare April 6, 2025 23:32
@hborla
Copy link
Member Author

hborla commented Apr 6, 2025

@swift-ci please smoke test

@hborla hborla force-pushed the default-actor-isolation branch from 734ce1a to d634254 Compare April 7, 2025 16:37
@hborla
Copy link
Member Author

hborla commented Apr 7, 2025

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Apr 8, 2025

@swift-ci please smoke test macOS

@hborla hborla marked this pull request as ready for review April 8, 2025 04:46
@@ -40,6 +40,7 @@ KNOWN_SDK_TYPE_DECL(ObjectiveC, ObjCBool, StructDecl, 0)
KNOWN_SDK_TYPE_DECL(Concurrency, CheckedContinuation, NominalTypeDecl, 2)
KNOWN_SDK_TYPE_DECL(Concurrency, UnsafeContinuation, NominalTypeDecl, 2)
KNOWN_SDK_TYPE_DECL(Concurrency, MainActor, NominalTypeDecl, 0)
KNOWN_SDK_TYPE_DECL(Concurrency, nonisolated, NominalTypeDecl, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I don't think we should be pulling such sneaky tricks. It's adding more confusion to an already complex world of keywords, attributes and now there'd be a type with the same name as a keyword as well but ofc not interchangable. Let's acknnowladge it's a type and follow usual Swift naming conventions, so Nonisolated for this

Copy link
Member Author

Choose a reason for hiding this comment

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

This line of code isn't doing anything other than generating some compiler API to easily get a known type in the Concurrency library. The actual part of this I think you object to is the type I added to stdlib/public/Concurrency/Actor.swift:

@available(SwiftStdlib 6.2, *)
public struct nonisolated {}

But yes, let's discuss this on the forum thread because that's design feedback.

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.

Overall LGTM :) Just unsure about the nonisolated type name, but let's leave that for evolution discussion

actor isolation per file using a typealias.

This feature is gated behind the `DefaultIsolationTypealias` experimental
feature flag.
@hborla hborla force-pushed the default-actor-isolation branch from d634254 to ef24f35 Compare April 18, 2025 21:54
@hborla
Copy link
Member Author

hborla commented Apr 18, 2025

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Jun 1, 2025

Superseded by #81863

@hborla hborla closed this Jun 1, 2025
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