Skip to content

Commit d1ee927

Browse files
add sourceOrigin info for all protocol implementations
rdar://78680450
1 parent 1d189de commit d1ee927

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/SymbolGraphGen/Edge.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ void Edge::serialize(llvm::json::OStream &OS) const {
7979
}
8080

8181
const ValueDecl *InheritingDecl = nullptr;
82-
if (const auto *ID = Source.getDeclInheritingDocs()) {
83-
if (Target.getSymbolDecl() == ID || Source.getSynthesizedBaseTypeDecl())
84-
InheritingDecl = ID;
85-
}
82+
if (const auto *ID = Source.getDeclInheritingDocs())
83+
InheritingDecl = ID;
84+
8685

8786
if (!InheritingDecl && Source.getSynthesizedBaseTypeDecl())
8887
InheritingDecl = Source.getSymbolDecl();

test/SymbolGraph/Relationships/Synthesized/InheritedDocs.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes BONUS
88
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes BONUS-DOCS
99
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes EXTRA
10+
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes LOCAL
1011

1112
// RUN: %target-swift-symbolgraph-extract -module-name InheritedDocs -I %t -pretty-print -output-dir %t -skip-inherited-docs
1213
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes CHECK,SKIP
1314
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes IMPL
1415
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes BONUS
1516
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes BONUS-SKIP
1617
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes EXTRA
18+
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes LOCAL
1719

1820
// RUN: %empty-directory(%t)
1921
// RUN: %target-build-swift %s -module-name InheritedDocs -emit-module -emit-module-path %t/InheritedDocs.swiftmodule -emit-symbol-graph -emit-symbol-graph-dir %t/ -skip-inherited-docs
@@ -56,10 +58,21 @@
5658
// EXTRA-NEXT: "identifier": "s:13InheritedDocs1PPAAE9extraFuncyyF"
5759
// EXTRA-NEXT: "displayName": "P.extraFunc()"
5860

61+
// local implementations of a local protocol still need to a relation to that protocol
62+
63+
// LOCAL: "source": "s:13InheritedDocs1SV9localFuncyyF"
64+
// LOCAL-NEXT: "target": "s:13InheritedDocs1SV"
65+
// LOCAL-NEXT: "sourceOrigin"
66+
// LOCAL-NEXT: "identifier": "s:13InheritedDocs1PP9localFuncyyF"
67+
// LOCAL-NEXT: "displayName": "P.localFunc()"
68+
5969
/// Protocol P
6070
public protocol P {
6171
/// Some Function
6272
func someFunc()
73+
74+
/// It's a local function!
75+
func localFunc()
6376
}
6477

6578
public extension P {
@@ -72,4 +85,5 @@ public extension P {
7285
}
7386

7487
public struct S: P {
88+
public func localFunc() {}
7589
}

0 commit comments

Comments
 (0)