Skip to content

[Index][SR-9567] Allow unavailable decls to be walked #30989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Index/Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
bool handleSourceOrModuleFile(SourceFileOrModule SFOrMod);

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

if (!handleCustomAttrInitRefs(D))
Expand Down
10 changes: 9 additions & 1 deletion test/Index/expressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ func test2<X: AP>(x: X) {
_ = type(of: x).A.self
}

@available(*, unavailable, renamed: "test")
func test2(_ o: S1?) {
// CHECK: [[@LINE-1]]:6 | function/Swift | test2(_:) | [[test2_unavailable_USR:.*]] | Def
// CHECK: [[@LINE-2]]:17 | struct/Swift | S1 | [[S1_USR]] | Ref
test(o) // CHECK: [[@LINE]]:3 | function/Swift | test(_:) | {{.*}} | Ref,Call,RelCall,RelCont | rel: 1
// CHECK-NEXT: RelCall,RelCont | function/Swift | test2(_:) | [[test2_unavailable_USR]]
}

protocol Disposable {
func dispose()
}
Expand All @@ -67,4 +75,4 @@ func useDisposable(_ d: Disposable?) {
// CHECK: [[@LINE+1]]:26 | instance-method/Swift | dispose() | s:14swift_ide_test10DisposableP7disposeyyF | Ref,RelCont | rel: 1
guard let dispose = d?.dispose else { return }
_ = dispose
}
}
21 changes: 21 additions & 0 deletions test/SourceKit/Indexing/index.swift.response
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,27 @@
}
]
},
{
key.kind: source.lang.swift.decl.class,
key.name: "AlwaysUnavailableClass",
key.usr: <usr>,
key.line: 184,
key.column: 7,
key.entities: [
{
key.kind: source.lang.swift.decl.function.constructor,
key.usr: <usr>,
key.line: 184,
key.column: 7,
key.is_implicit: 1
}
],
key.attributes: [
{
key.attribute: source.decl.attribute.available
}
]
},
{
key.kind: source.lang.swift.decl.class,
key.name: "ConditionalUnavailableClass1",
Expand Down