Skip to content

Add a Fix-It to the warning about unnecessary @preconcurrency conformance #73742

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

Conversation

DougGregor
Copy link
Member

When we diagnose an unnecessary @preconcurrency on a conformance, also provide a Fix-It to remove the @preconcurrency.

…rmance

When we diagnose an unnecessary `@preconcurrency` on a conformance,
also provide a Fix-It to remove the `@preconcurrency`.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor enabled auto-merge May 20, 2024 01:47
@DougGregor DougGregor merged commit 8d7e694 into swiftlang:main May 20, 2024
3 checks passed
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Thank you!

: RootProtocolConformance(ProtocolConformanceKind::Normal,
conformingType),
Protocol(protocol), Loc(loc), Context(dc) {
Protocol(protocol), Loc(loc), PreconcurrencyLoc(preconcurrencyLoc),
Context(dc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add an assert to make sure that preconcurrencyLoc is never valid when isPreconcurrency is set to false?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good idea!

@@ -147,7 +147,7 @@ SourceLoc TypeRepr::findAttrLoc(TypeAttrKind kind) const {
for (auto attr : attrTypeRepr->getAttrs()) {
if (auto typeAttr = attr.dyn_cast<TypeAttribute*>())
if (typeAttr->getKind() == kind)
return typeAttr->getAttrLoc();
return typeAttr->getStartLoc();
Copy link
Contributor

Choose a reason for hiding this comment

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

I was looking for what this change is going to affect and found https://github.com/apple/swift/blob/main/lib/Sema/TypeCheckDeclPrimary.cpp#L1803-L1806 which instead of 1 should also use strlen("@retroactive ")? We have a few tests for that diagnostic but none of them check fix-it :/

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll do that. I feel like there should be a better way than that strlen, but I wasn't up for adding more infrastructure right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

What devilry is this? The .getAdvancedLoc(1) thing is actually working for @retroactive, and I don't understand why

Copy link
Contributor

Choose a reason for hiding this comment

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

That is weird...

@DougGregor DougGregor deleted the fixit-unused-preconcurrency-conformance branch May 20, 2024 16:04
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.

2 participants