Skip to content

Fix Sendability warnings #137

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

Merged
merged 3 commits into from
Jun 21, 2024
Merged

Fix Sendability warnings #137

merged 3 commits into from
Jun 21, 2024

Conversation

gjcairo
Copy link
Contributor

@gjcairo gjcairo commented Aug 11, 2023

This PR fixes Sendability warnings present when enabling strict concurrency checking.

Motivation:

We want to make sure swift-metrics is free of concurrency bugs, and thus removing Sendability warnings is crucial.

Modifications:

  • Fixed a couple of Sendability warnings that Xcode would report when enabling strict concurrency checking.
  • Also fixed other non-Sendability-related warnings about non-exhaustive switches.

Result:

swift-metrics is now warning-free.

@gjcairo gjcairo marked this pull request as ready for review August 11, 2023 14:34
@tomerd
Copy link
Member

tomerd commented Aug 11, 2023

@swift-server-bot test this please

@@ -71,6 +71,8 @@ extension Timer {
self.recordSeconds(value)
case .never:
self.record(0)
@unknown default:
self.record(0)
Copy link
Member

@ktoso ktoso Aug 14, 2023

Choose a reason for hiding this comment

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

In most CI runs this cases the following error:

/code/Sources/Metrics/Metrics.swift:74:9: error: default will never be executed
        @unknown default:
        ^
[8/13] Compiling Metrics Metrics.swift
/code/Sources/Metrics/Metrics.swift:74:9: error: default will never be executed
        @unknown default:
        ^

Can you investigate please @gjcairo ?

Choose a reason for hiding this comment

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

@ktoso Can you give an example of a CI config that causes this? I was about to open a PR to fix this because the enum is not frozen

Copy link
Member

Choose a reason for hiding this comment

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

We'll have to run tests again to know since it's been so long that since the logs have been removed.

Copy link
Member

Choose a reason for hiding this comment

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

@ktoso
Copy link
Member

ktoso commented Oct 24, 2023

kicking off to answer: #137 (comment)

@swift-server-bot test this please

@ktoso
Copy link
Member

ktoso commented Oct 24, 2023

  • Until 5.5 (excluding 5.5) all builds fail on directly using Sendable which does not exist in these versions.
internal final class AccumulatingMeter: MeterHandler, @unchecked Sendable {
                                                       ^
/code/Sources/CoreMetrics/Locks.swift:47:28: error: cannot find type 'Sendable' in scope
internal final class Lock: Sendable {
                           ^~~~~~~~
[2/8] Compiling CoreMetrics Metrics.swift
/code/Sources/CoreMetrics/Metrics.swift:801:56: error: unknown attribute 'unchecked'
internal final class AccumulatingMeter: MeterHandler, @unchecked Sendable {
                                                       ^
/code/Sources/CoreMetrics/Metrics.swift:801:66: error: cannot find type 'Sendable' in scope
internal final class AccumulatingMeter: MeterHandler, @unchecked Sendable {
                                                                 ^~~~~~~~
  • From 5.5 (including 5.5) all builds fail on:

[7/13] Compiling Metrics Metrics.swift
/code/Sources/Metrics/Metrics.swift:74:9: error: default will never be executed
        @unknown default:
        ^
error: fatalError

FYI @gjcairo; cc @AndrewHoos - since you mentioned you'd like to fix things here

@gjcairo
Copy link
Contributor Author

gjcairo commented Jun 21, 2024

@swift-server-bot test this please

@FranzBusch
Copy link
Member

@swift-server-bot add to allowlist

@FranzBusch
Copy link
Member

@swift-server-bot test this please

@gjcairo gjcairo force-pushed the sendability branch 2 times, most recently from ce12948 to 158f5b1 Compare June 21, 2024 12:08
@gjcairo gjcairo requested a review from ktoso June 21, 2024 13:17
@FranzBusch FranzBusch merged commit e0165b5 into apple:main Jun 21, 2024
6 checks passed
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.

5 participants