mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Fix a crash when performing related identifers request on self
Performing a related identifiers request on `self` returns an empty result because `self` is not an identifier. We thus can’t retrieve the first location to compute the old name. rdar://121668042
This commit is contained in:
@@ -2550,7 +2550,10 @@ void SwiftLangSupport::findRelatedIdentifiersInFile(
|
||||
|
||||
RenameLocs Locs = localRenameLocs(SrcFile, Info->VD);
|
||||
|
||||
std::string OldName = Locs.getLocations().front().OldName.str();
|
||||
std::optional<std::string> OldName;
|
||||
if (!Locs.getLocations().empty()) {
|
||||
OldName = Locs.getLocations().front().OldName.str();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
for (auto loc : Locs.getLocations()) {
|
||||
assert(loc.OldName == OldName &&
|
||||
|
||||
Reference in New Issue
Block a user