-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[RelatedIdents] Fix an assertion failure if two invalid declarations have the same base name #73468
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
[RelatedIdents] Fix an assertion failure if two invalid declarations have the same base name #73468
Conversation
@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.
Nice find!
lib/Refactoring/LocalRename.cpp
Outdated
@@ -195,6 +195,7 @@ swift::ide::getRenameInfo(ResolvedCursorInfoPtr cursorInfo) { | |||
|
|||
class RenameRangeCollector : public IndexDataConsumer { | |||
StringRef usr; | |||
SmallString<64> displayName; |
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.
Any reason not to treat this the same as usr
? ie. local smallstring and copy into string storage? I haven't looked at where usr
is used and if there's a good reason we're doing that anyway, so this really is a genuine question and not just rhetorically asking you to change 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.
I was writing a whole paragraph about how usr
is returned and thus needs to be in stringStorage
anyway and how name
is only used locally so no need to waste space in stringStorage
for it, only that I now realized that name
is returned and usr
is not. 😅
Changed both to use SmallString<64>
as a member of RenameRangeCollector
because it simplifies the code.
lib/Refactoring/LocalRename.cpp
Outdated
usr = stringStorage->copyString(usrStorage.str()); | ||
|
||
llvm::raw_svector_ostream nameOS(displayName); | ||
index::printDisplayName(D, nameOS); |
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.
Do we really have to expose printDisplayName
here? It just handles getters/setters, which presumably we don't care about here anyway (ie. can this just be D->getName()
?)
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 would prefer to, yes. Less because we need it right now and more to be future-proof. If we modify printDisplayName
in the future without remembering to change the call here, we would be missing results from related idents.
ade4b2a
to
df035eb
Compare
@swift-ci Please smoke test |
…have the same base name For example, the following declarations have the same USR with a single ERROR_TYPE parameter despite being distinct declarations. ```swift func bar(body: Invalid) {} func bar(ignoreCase: Bool, body: Invalid) {} ``` We originally intended to check the USR so that local rename behaves more like global rename, which also looks symbols up by USR. But the above example proves that assumption wrong. rdar://126803702
df035eb
to
1a67c61
Compare
@swift-ci Please smoke test |
@swift-ci Please smoke test |
For example, the following declarations have the same USR with a single ERROR_TYPE parameter despite being distinct declarations.
We originally intended to check the USR so that local rename behaves more like global rename, which also looks symbols up by USR. But the above example proves that assumption wrong.
rdar://126803702