Skip to content

Commit f5488c5

Browse files
authored
Merge pull request #63601 from DougGregor/sourcekit-macro-buffer-loc
[SourceKit] Disable optimization that's now incorrect with macros.
2 parents 1aa400c + 642d0e9 commit f5488c5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,13 @@ class SemanticAnnotator : public SourceEntityWalker {
945945
if (AvailableAttr::isUnavailable(D))
946946
return true;
947947

948+
Optional<unsigned> inBufferID;
949+
if (SM.getRangeForBuffer(BufferID).contains(Range.getStart()))
950+
inBufferID = BufferID;
951+
948952
auto &SM = D->getASTContext().SourceMgr;
949953
if (D == D->getASTContext().getOptionalNoneDecl() &&
950-
SM.extractText(Range, BufferID) == "nil") {
954+
SM.extractText(Range, inBufferID) == "nil") {
951955
// If a 'nil' literal occurs in a swift-case statement, it gets replaced
952956
// by a reference to 'Optional.none' in the AST. We want to continue
953957
// highlighting 'nil' as a keyword and not as an enum element.

0 commit comments

Comments
 (0)