Skip to content

Commit 4b068ac

Browse files
Merge pull request #37248 from apple/QuietMisdreavus/synthesized-sourceOrigin
[SymbolGraph] add sourceOrigin for synthesized symbols even if no docs exist
2 parents b63727d + d81d5d5 commit 4b068ac

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/SymbolGraphGen/Edge.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ void Edge::serialize(llvm::json::OStream &OS) const {
6363
if (Target.getSymbolDecl() == ID || Source.getSynthesizedBaseTypeDecl())
6464
InheritingDecl = ID;
6565
}
66+
67+
if (!InheritingDecl && Source.getSynthesizedBaseTypeDecl())
68+
InheritingDecl = Source.getSymbolDecl();
6669

6770
// If our source symbol is a inheriting decl, write in information about
6871
// where it's inheriting docs from.

test/SymbolGraph/Relationships/Synthesized/InheritedDocs.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes IMPL
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
9+
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json --check-prefixes EXTRA
910

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

1618
// RUN: %empty-directory(%t)
1719
// 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
@@ -46,6 +48,14 @@
4648
// BONUS-NEXT: "identifier": "s:13InheritedDocs1PPAAE9bonusFuncyyF"
4749
// BONUS-NEXT: "displayName": "P.bonusFunc()"
4850

51+
// synthesized symbols that don't have docs to inherit still need to have the sourceOrigin field
52+
53+
// EXTRA: "source": "s:13InheritedDocs1PPAAE9extraFuncyyF::SYNTHESIZED::s:13InheritedDocs1SV"
54+
// EXTRA-NEXT: "target": "s:13InheritedDocs1SV"
55+
// EXTRA-NEXT: "sourceOrigin"
56+
// EXTRA-NEXT: "identifier": "s:13InheritedDocs1PPAAE9extraFuncyyF"
57+
// EXTRA-NEXT: "displayName": "P.extraFunc()"
58+
4959
/// Protocol P
5060
public protocol P {
5161
/// Some Function
@@ -57,6 +67,8 @@ public extension P {
5767

5868
/// Bonus docs!
5969
func bonusFunc() {}
70+
71+
func extraFunc() {} // no docs, but still needs sourceOrigin
6072
}
6173

6274
public struct S: P {

0 commit comments

Comments
 (0)