Skip to content

Conversation

ffried
Copy link
Contributor

@ffried ffried commented Oct 7, 2022

Improve diagnostics for depracted Lock.

Motivation:

When using a Lock instance handed by another library and calling withLock or withLockVoid on it, the compiler will issue an incorrect fix-it warning that withLock (or withLockVoid) was renamed to NIOLock and by applying it will incorrectly change the method signature to NIOLock.

For example when using Vapor, there is a property called locks on Vapor's Application class. Vapors hands out locks to users here. However, creating these locks isn't done by the users of Vapor, but by Vapor itself. Thus, users cannot fix the deprecation themselves.

Modifications:

The warning results from annotating the extension that adds withLock and withLockVoid with @available(*, deprecated, renamed: "NIOLock"). This removes the annotation and moves these two methods into the main declaration of Lock.

Result:

The fix-it warning no longer appears when using withLock or withLockVoid.

Motivation:

When using a `Lock` instance handed by another library and calling `withLock` or `withLockVoid` on it,
the compiler will issue an incorrect fix-it warning that `withLock` (or `withLockVoid`) was renamed to `NIOLock`.

Modifications:

The warning results from annotating the extension that adds `withLock` and `withLockVoid` with `@available(*, deprecated, renamed: "NIOLock")`.
This removes the annotation and moves these two methods into the main declaration of `Lock`.

Result:

The fix-it warning no longer appears when using `withLock` or `withLockVoid`.
@swift-server-bot
Copy link

Can one of the admins verify this patch?

10 similar comments
@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@ffried
Copy link
Contributor Author

ffried commented Oct 7, 2022

Hmm, @swift-server-bot seems to be a bit of an overachiever... 😄

@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Oct 7, 2022
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

This seems like a reasonable change to me.

@Lukasa
Copy link
Contributor

Lukasa commented Oct 7, 2022

@swift-server-bot test this please

@Lukasa Lukasa enabled auto-merge (squash) October 7, 2022 13:37
@Lukasa Lukasa merged commit 41f0b2d into apple:main Oct 7, 2022
@ffried ffried deleted the feature/lock-deprecation-improvement branch October 11, 2022 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants