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
[SR-10979] Add fix-it for missing operator #26258
Conversation
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.
This looks good to me, thanks for fixing this! I have a couple of suggestions, but overall this looks goof.
lib/Sema/TypeCheckDecl.cpp
Outdated
insertion += operatorName.str(); | ||
insertion += " : <# Precedence Group #>\n"; | ||
TC.diagnose(FD, diag::declared_operator_without_operator_decl) | ||
.fixItInsert(insertionLoc, insertion); |
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.
Can you guard this on if insertionLoc.isValid()
?
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.
Just one small suggestion
lib/Sema/TypeCheckDecl.cpp
Outdated
// FIXME: Add Fix-It introducing an operator declaration? | ||
TC.diagnose(FD, diag::declared_operator_without_operator_decl); | ||
SourceLoc insertionLoc; | ||
if (dyn_cast<SourceFile>(FD->getParent())) { |
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.
if (dyn_cast<SourceFile>(FD->getParent())) { | |
if (isa<SourceFile>(FD->getParent())) { |
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.
Thanks for the suggestion, applied.
lib/Sema/TypeCheckDecl.cpp
Outdated
CurContext; | ||
CurContext = CurContext->getParent()) { | ||
insertionLoc = CurContext->getAsDecl()->getStartLoc(); | ||
if (dyn_cast<SourceFile>(CurContext->getParent())) |
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.
if (dyn_cast<SourceFile>(CurContext->getParent())) | |
if (isa<SourceFile>(CurContext->getParent())) |
@swift-ci please test |
⛵ Thanks @mcichecki! And welcome to the Swift project, we really appreciate your contribution! |
This PR adds fix-it for operator functions when operator is not declared.
Resolves SR-10979.