-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AST/Sema] SE-0478: Implement using
declaration under an experimental flag
#81863
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
[AST/Sema] SE-0478: Implement using
declaration under an experimental flag
#81863
Conversation
Initially this declaration is going to be used to determine per-file default actor isolation i.e. `using @MainActor` and `using nonisolated` but it could be extended to support other file-global settings in the future.
swiftlang/swift-syntax#3087 |
724a885
to
ae89b98
Compare
swiftlang/swift-syntax#3087 |
using
declaration under an experimental flag
…f `.swift` These are split-file C++ tests, this is a problem for swift-syntax because `.swift` tests get parsed for round-trip testing if swift-syntax is located near swift.
The default isolation is computed based on `using` declaration found in the file, if any.
These declarations are effectively `fileprivate` at the moment and should appear in swift interfaces.
…experimental feature
Infer default actor isolation from `using` declaration in the file scope and use it to override one that is set by `-default-isolation` flag.
ae89b98
to
bc61bfb
Compare
swiftlang/swift-syntax#3087 |
swiftlang/swift-syntax#3087 |
swiftlang/swift-syntax#3087 |
@@ -66,3 +71,12 @@ func misisngPatternTest(arr: [Int]) { | |||
for {} // expected-error {{expected pattern, 'in', and expression in 'for' statement}} | |||
// expected-note@-1 {{insert pattern, 'in', and expression}} {{7-7=<#pattern#> }} {{7-7=in }} {{7-7=<#expression#> }} | |||
} | |||
|
|||
using @MainActor // expected-note {{default isolation was previously declared here}} | |||
using nonisolated // expected-error {{invalid redeclaration of file-level default actor isolation}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, exactly what I was worried about when I saw the proposal update :)
Good to see we diagnose this.
This is an alternative spelling of
typealias DefaultIsolation = (MainActor | nonisolated)
that was proposed as part of SE-0478.using
declaration accepts an attribute or a modifier and currently could be used to set a default actor isolation per file, but could be extended to support other use-cases in the future.Implementation uses
DefaultIsolationPerFile
experimental feature flag to hide the syntax.