Skip to content

Commit 4caa6d7

Browse files
committed
IDE: Fix indexing for Sema-built curry thunks
1 parent b45f70d commit 4caa6d7

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

lib/AST/Expr.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,11 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
18511851
case AutoClosureExpr::Kind::SingleCurryThunk: {
18521852
auto *body = getSingleExpressionBody();
18531853
body = body->getSemanticsProvidingExpr();
1854+
1855+
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(body)) {
1856+
body = openExistential->getSubExpr();
1857+
}
1858+
18541859
if (auto *outerCall = dyn_cast<ApplyExpr>(body)) {
18551860
return outerCall->getFn();
18561861
}
@@ -1866,6 +1871,11 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
18661871
AutoClosureExpr::Kind::SingleCurryThunk);
18671872
auto *innerBody = innerClosure->getSingleExpressionBody();
18681873
innerBody = innerBody->getSemanticsProvidingExpr();
1874+
1875+
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(innerBody)) {
1876+
innerBody = openExistential->getSubExpr();
1877+
}
1878+
18691879
if (auto *outerCall = dyn_cast<ApplyExpr>(innerBody)) {
18701880
if (auto *innerCall = dyn_cast<ApplyExpr>(outerCall->getFn())) {
18711881
if (auto *declRef = dyn_cast<DeclRefExpr>(innerCall->getFn())) {

lib/IDE/SourceEntityWalker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,11 @@ std::pair<bool, Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
276276
OpAccess)))
277277
return stopTraversal;
278278

279-
return { true, E };
279+
return doSkipChildren();
280280
}
281281
}
282+
283+
return { true, E };
282284
}
283285

284286
if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {

test/Index/expressions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,13 @@ func test2<X: AP>(x: X) {
5858
// CHECK: [[@LINE+1]]:19 | type-alias/associated-type/Swift | A | [[AP_P_USR]] | Ref,RelCont | rel: 1
5959
_ = type(of: x).A.self
6060
}
61+
62+
protocol Disposable {
63+
func dispose()
64+
}
65+
66+
func useDisposable(_ d: Disposable?) {
67+
// CHECK: [[@LINE+1]]:26 | instance-method/Swift | dispose() | s:14swift_ide_test10DisposableP7disposeyyF | Ref,RelCont | rel: 1
68+
guard let dispose = d?.dispose else { return }
69+
_ = dispose
70+
}

0 commit comments

Comments
 (0)