Skip to content

Commit bcfbc3f

Browse files
committed
Discard non-indexed relations instead of entire references.
References for function calls where there would normally be a received-by relationship were being discarded. This happened when the receiver type is a non-indexed type, e.g. a private type in a system framework. The function call could be public or defined in any module though, so discarding it entirely because of the receiver type is not desirable. Follow up to refine the behavior of [previous commit](b65d8c2).
1 parent 63b7f05 commit bcfbc3f

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

lib/Index/Index.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,9 +1762,11 @@ bool IndexSwiftASTWalker::reportIsDynamicRef(ValueDecl *D, IndexSymbol &Info) {
17621762
SmallVector<NominalTypeDecl *, 1> Types;
17631763
ide::getReceiverType(BaseE, Types);
17641764
for (auto *ReceiverTy : Types) {
1765-
if (addRelation(Info, (SymbolRoleSet) SymbolRole::RelationReceivedBy,
1766-
ReceiverTy))
1767-
return true;
1765+
// Adding the received-by "fails" if the receiver type isn't indexed.
1766+
// Allow the relation to be silently discarded, while keeping the
1767+
// reference.
1768+
addRelation(Info, (SymbolRoleSet)SymbolRole::RelationReceivedBy,
1769+
ReceiverTy);
17681770
}
17691771

17701772
return false;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %s | %FileCheck %s
2+
3+
import SwiftUI
4+
5+
private struct Mod: ViewModifier {
6+
func body(content: Content) -> some View {
7+
content
8+
.background(Color.red)
9+
// CHECK: [[@LINE-1]]:8 | instance-method/Swift | background(_:ignoresSafeAreaEdges:) | {{.*}} | Ref,Call{{.*}} |
10+
.foregroundColor(.green)
11+
12+
}
13+
}
14+
15+
private struct V: View {
16+
var body: some View {
17+
Capsule()
18+
.fill(.red)
19+
.background(.green)
20+
// CHECK: [[@LINE-1]]:8 | instance-method/Swift | background(_:ignoresSafeAreaEdges:) | {{.*}} | Ref,Call{{.*}} |
21+
}
22+
}

0 commit comments

Comments
 (0)