Skip to content

Commit 3958855

Browse files
authored
Merge pull request #18198 from rintaro/ide-rdar41100570
[IDE] Fix asstion failure when querying cursor info in defer statement body
2 parents b042215 + 7ca7e44 commit 3958855

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/IDE/SourceEntityWalker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ std::pair<bool, Stmt *> SemaAnnotator::walkToStmtPre(Stmt *S) {
217217
// walk into the body.
218218
if (auto *FD = DeferS->getTempDecl()) {
219219
auto *RetS = FD->getBody()->walk(*this);
220+
if (!RetS)
221+
return { false, nullptr };
220222
assert(RetS == FD->getBody());
221-
(void)RetS;
222223
}
223224
bool Continue = SEWalker.walkToStmtPost(DeferS);
224225
if (!Continue)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
func foo(x: String) {
2+
defer { _ = x.count }
3+
}
4+
5+
// RUN: %sourcekitd-test -req=cursor -cursor-action -pos=2:15 %s -- %s | %FileCheck %s
6+
// CHECK: source.lang.swift.ref.var.local (1:10-1:11)

0 commit comments

Comments
 (0)