-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Add a Fix-It to the warning about unnecessary @preconcurrency
conformance
#73742
Conversation
…rmance When we diagnose an unnecessary `@preconcurrency` on a conformance, also provide a Fix-It to remove the `@preconcurrency`.
@swift-ci please smoke 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.
Thank you!
: RootProtocolConformance(ProtocolConformanceKind::Normal, | ||
conformingType), | ||
Protocol(protocol), Loc(loc), Context(dc) { | ||
Protocol(protocol), Loc(loc), PreconcurrencyLoc(preconcurrencyLoc), | ||
Context(dc) { |
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.
Could you please add an assert to make sure that preconcurrencyLoc
is never valid when isPreconcurrency
is set to false
?
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.
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(); |
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.
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 :/
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.
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.
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.
What devilry is this? The .getAdvancedLoc(1)
thing is actually working for @retroactive
, and I don't understand why
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.
That is weird...
When we diagnose an unnecessary
@preconcurrency
on a conformance, also provide a Fix-It to remove the@preconcurrency
.