Skip to content

Commit b65d8c2

Browse files
committed
[Index] Avoid forming relations to non-indexed decls
If we shouldn't index the related decl, don't record it as a relation.
1 parent e22ac14 commit b65d8c2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Index/Index.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
544544

545545
bool addRelation(IndexSymbol &Info, SymbolRoleSet RelationRoles, Decl *D) {
546546
assert(D);
547+
if (auto *VD = dyn_cast<ValueDecl>(D)) {
548+
if (!shouldIndex(VD, /*IsRef*/ true))
549+
return true;
550+
}
547551
auto Match = std::find_if(Info.Relations.begin(), Info.Relations.end(),
548552
[D](IndexRelation R) { return R.decl == D; });
549553
if (Match != Info.Relations.end()) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %empty-directory(%t)
2+
//
3+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Mod.swiftmodule -module-name Mod %s
4+
// RUN: %target-swift-ide-test -print-indexed-symbols -module-to-print Mod -source-filename %s -I %t | %FileCheck %s
5+
6+
public class C {
7+
fileprivate func foo() {}
8+
}
9+
public class D: C {
10+
public override func foo() {}
11+
}
12+
13+
// Make sure we don't report the override of the private member in the base class.
14+
//CHECK: instance-method/Swift | foo() | s:3Mod1DC3fooyyF | Def,Dyn,RelChild | rel: 1
15+
//CHECK-NEXT: RelChild | class/Swift | D | s:3Mod1DC

0 commit comments

Comments
 (0)