-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[Sema] Improve SerialExecutor diagnostics #66934
Conversation
@swift-ci please test |
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.
Is it possible to fix the overall issue of the deprecation warning by specifying which version of Swift the old enqueue got deprecated in? Right now it appears to say in all versions:
@available(*, deprecated, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
but perhaps we could just change this to say it was deprecated in 5.9. Thoughts @ktoso?
The problematic warning is triggered by a custom check in sema, which is what this PR modifies. Meanwhile, the warning due to Thanks for the review @kavon, it's a bit late rn but I'll try to address these changes some time over the coming week 🙌 |
There is no such capability AFAIK @tshortli should comment on general tricks with availability though, we worked together and arrived at this combination of deprecation annotations -- these changes carried a high risk and caused a lot of mayhem along the way, so we better be careful when introducing changes here. |
// RUN: %target-typecheck-verify-swift -enable-experimental-move-only | ||
// REQUIRES: concurrency | ||
// REQUIRES: OS=macosx | ||
|
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.
This is probably missing a bunch of disables, like:
// UNSUPPORTED: back_deployment_runtime | |
// REQUIRES: concurrency_runtime | |
// UNSUPPORTED: freestanding | |
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.
The requirements here are based on the ones in custom_executor_enqueue_impls.swift, the primary difference being the removal of -disable-availability-checking
from the swiftc invocation. Do we need more disables here than in the other test? I see that I missed copying over the UNSUPPORTED: freestanding
so I'll add that in — but not quite sure why this wouldn't support a back-deployed runtime.
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.
we don't backdeploy the ExecutorJob
type, so since the test is touching that I don't think it'll work there
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.
All of the usages of ExecutorJob
are annotated with @available(SwiftStdlib 5.9, *)
— that seems sufficient to me but correct me if I'm missing something. The CI checks seem to have passed, is there a specific configuration they aren't covering that I can test manually?
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.
AFAICS this looks correct, the new diagnostic also makes sense.
Note that the warning is not from the deprecated annotation but directly from Sema, as @kabiroberai mentioned already.
Let's give this a full test run, and I expect this must be disabled on some platforms AFAIR
@swift-ci please test |
@swift-ci please test |
Hey @ktoso, is there anything blocking this from being merged now? |
Thanks looking into final checks here, I think it looks good. Let's confirm freestanding |
preset=stdlib_S_standalone_minimal_macho_x86_64,build,test |
Radar tracking this rdar://110329131 |
Thanks for the good work here @kabiroberai ! |
This PR tackles the case of
SerialExecutor
conformances with pre-SwiftStdlib 5.9 deployment targets. Previously, such a conformance would produce an unfixable warning about theenqueue(UnownedJob)
requirement being deprecated — even though it's the only requirement that can be implemented without restricting the availability to SwiftStdlib 5.9. Fixing this involves two main changes:ExecutorJob
requirement can be used.ExecutorJob
andUnownedJob
requirements are implemented in a pre-5.9 availability context, pointing out that theExecutorJob
overload will never be selected.For one motivating example behind this change, consider the custom ClockExecutor in swift-async-algorithms. This type currently has an unfixable warning about
enqueue(UnownedJob)
. Moreover, it appears that there was an attempted fix via apple/swift-async-algorithms#274 in order to address this warning — but in fact the new overload is never selected. With this PR, the old warning disappears and typechecking should now diagnose the fact that theExecutorJob
overload does not work as expected. If/when swift-async-algorithms drops support for pre-5.9 targets, the original deprecation warning will correctly appear again.