Skip to content

Commit e03e130

Browse files
author
Nathan Hawes
authored
Merge pull request #30989 from CodaFi/of-no-avail
[Index][SR-9567] Allow unavailable decls to be walked
2 parents 99356cd + 160eb6c commit e03e130

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

lib/Index/Index.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
301301
bool handleSourceOrModuleFile(SourceFileOrModule SFOrMod);
302302

303303
bool walkToDeclPre(Decl *D, CharSourceRange Range) override {
304-
// Do not handle unavailable decls.
305-
if (AvailableAttr::isUnavailable(D))
304+
// Do not handle unavailable decls from other modules.
305+
if (IsModuleFile && AvailableAttr::isUnavailable(D))
306306
return false;
307307

308308
if (!handleCustomAttrInitRefs(D))

test/Index/expressions.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ func test2<X: AP>(x: X) {
5959
_ = type(of: x).A.self
6060
}
6161

62+
@available(*, unavailable, renamed: "test")
63+
func test2(_ o: S1?) {
64+
// CHECK: [[@LINE-1]]:6 | function/Swift | test2(_:) | [[test2_unavailable_USR:.*]] | Def
65+
// CHECK: [[@LINE-2]]:17 | struct/Swift | S1 | [[S1_USR]] | Ref
66+
test(o) // CHECK: [[@LINE]]:3 | function/Swift | test(_:) | {{.*}} | Ref,Call,RelCall,RelCont | rel: 1
67+
// CHECK-NEXT: RelCall,RelCont | function/Swift | test2(_:) | [[test2_unavailable_USR]]
68+
}
69+
6270
protocol Disposable {
6371
func dispose()
6472
}
@@ -67,4 +75,4 @@ func useDisposable(_ d: Disposable?) {
6775
// CHECK: [[@LINE+1]]:26 | instance-method/Swift | dispose() | s:14swift_ide_test10DisposableP7disposeyyF | Ref,RelCont | rel: 1
6876
guard let dispose = d?.dispose else { return }
6977
_ = dispose
70-
}
78+
}

test/SourceKit/Indexing/index.swift.response

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,27 @@
15201520
}
15211521
]
15221522
},
1523+
{
1524+
key.kind: source.lang.swift.decl.class,
1525+
key.name: "AlwaysUnavailableClass",
1526+
key.usr: <usr>,
1527+
key.line: 184,
1528+
key.column: 7,
1529+
key.entities: [
1530+
{
1531+
key.kind: source.lang.swift.decl.function.constructor,
1532+
key.usr: <usr>,
1533+
key.line: 184,
1534+
key.column: 7,
1535+
key.is_implicit: 1
1536+
}
1537+
],
1538+
key.attributes: [
1539+
{
1540+
key.attribute: source.decl.attribute.available
1541+
}
1542+
]
1543+
},
15231544
{
15241545
key.kind: source.lang.swift.decl.class,
15251546
key.name: "ConditionalUnavailableClass1",

0 commit comments

Comments
 (0)