Skip to content

[5.9][Executors] Do not consider Loc validity in determining to emit error/warning about enqueue(_:) #67959

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

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Aug 16, 2023

Description: The introduction of new protocol requirements in protocol Executor required careful and custom handling by the compiler in order to not break ABI/API. This logic made a wrong assumption that it can rely on valid/invalid source location information to determine if "this decl exists and is valid" -- while in reality, we cannot rely on loc at all for making this decision. This happened to work in tests and swiftpm projects because source location was always available.

Symbols may not have valid loc attached just because they're in a different module and we don't have swiftsourceinfo for them. E.g. with Xcode the Archive action does not copy the swiftsourceinfo and thus we end up ALWAYS emitting the error that an implementation is missing -- even if it is there, but we simply trigger the "illegal loc!" case incorrectly.

Solution: Stop relying on the incorrect assumption that a "valid loc" can be used to determine if we have the method or not. This worked by accident, since in swift the unit test suite we entered this missing loc code path.

Instead, we must manually inspect the witnesses and determine that at least one of them is NOT the default implementation provided in the stdlib (because we implement ALL of the requirements in order to introduce the new protocol requirement without breaking API/ABI). The same goes about warnings, since we do not want to emit warnings about the standard library when end-users do something slightly wrong in their adoption -- it is their conformance mistake we must warn about.

Risk: Low
Risk details: The primary error fix is about removing the use of loc information entirely from decision making about emitting errors, i.e. we're removing a buggy source of information from the decision making -- the primary logic all remains the same.

Due to that removal, we also add some warning suppression that previously occurred naturally (correctly "by accident"), by concretely handling the special casing of the concrete extension in _Concurrency module that performs actions we should not warn about in stdlib due to it implementing bin-compat concerns.

Reward: Medium,
Reward details: Projects built in a way where swiftsourceinfo is not available (e.g. in Xcode by running "Archive") are now able to adopt libraries that adopted custom executors -- e.g. like Swift NIO. The reward is medium because custom executor adoption in this pattern isn't quite wide-spread yet.

Review by: @DougGregor @owenv
Testing: Warnings and errors emitted by this are well tested; We also verified a known reproducer using Xcode and "Archive" action is resolved by a compiler with this fix.
Original PR: #67957
Scope: This is a compiler only change.
Radar: rdar://113913291

instead, error if all implementations are "default from stdlib" because end-user MUST implement at least one of them

Don't trigger warnings about stdlib itself when user code might trigger them

The standard library's enqueue() does not play by the same rules -- we
provide "deprecated" implementations in  order to remain source/binary
compatible, and showing warnings about this when users make mistake will
only be misleading.
@ktoso ktoso requested a review from a team as a code owner August 16, 2023 14:07
@ktoso
Copy link
Contributor Author

ktoso commented Aug 16, 2023

@swift-ci please test

@ktoso ktoso added concurrency Feature: umbrella label for concurrency language features 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels Aug 16, 2023
@DougGregor DougGregor merged commit 1c64963 into swiftlang:release/5.9 Aug 16, 2023
@ktoso ktoso deleted the pick-dont-use-loc-validness-in-diagnostics-determination-113913291 branch August 16, 2023 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency Feature: umbrella label for concurrency language features 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants