-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Rule to check for Swift 5-mode-incompatible API #5987
Comments
Ok I'm trying to come up with examples. You have to catch public API that uses global actors,
non-triggering: Example("public struct S: Sendable {}"),
Example("public class C: Sendable {}"),
Example("public actor A {}"),
Example("public @MyActor enum E { case a }"),
Example("private @MainActtor struct S { }"),
Example("@MainActtor struct S { }"), triggering: Example("↓@MainActor public struct S {}"),
Example("↓@MainActor public func globalActor()"),
Example("public func sendableClosure(_ block: ↓@Sendable () -> Void)"),
Example("public func globalActorClosure(_ block: ↓@MainActor () -> Void)"),
Example(
"public func globalActorClosure(_ block: ↓@MyActor () -> Void)",
configuration: ["global_actors": ["MyActor"]]
),
Example("public func sendingParameter(p: sending NonSendable)"),
Example("↓@MainActor public protocol GlobalActor {}"),
Example("public struct S { public func sendableClosure(_ block: ↓@Sendable () -> Void) }"),
Example("↓@MyActor public struct S {}", configuration: ["global_actors": ["MyActor"]]),
Example("public func generic<T> where T: ↓Sendable") |
Thank you for the idea a the examples! What would be a good name for the new rule? Probably the hardest part ... 😅 |
I started playing around with an implementation, and I used "IncompatibleConcurrencyAnnotationRule". But I rapidly realized that I don't have enough Swift syntax knowledge. What do you think of that one? |
With "incompatible" meaning "not back-deployable"? But that's probably too long and a too weird combination of words. I think "IncompatibleConcurrencyAnnotationRule" is good with an explanation of what it means in the description.
It's a hurdle to get used to it. But with some experience it's fun to work with it. |
New Issue Checklist
Feature or Enhancement Proposal
There are a number of ways to break compatibility with Swift 5 mode (strict concurrency off) that are difficult to notice. Here are some examples:
In all of these cases, to preserve compatibility you must use
@preconcurrency
.I think this could be a great new rule!
The text was updated successfully, but these errors were encountered: