Skip to content

Commit 160eb6c

Browse files
rockbrunoCodaFi
authored andcommitted
Update index test response to cover unavailable calls
1 parent ca74aca commit 160eb6c

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

lib/Index/Index.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
301301
bool handleSourceOrModuleFile(SourceFileOrModule SFOrMod);
302302

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

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)