File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
test/SymbolGraph/Relationships/DefaultImplementationOf Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -426,6 +426,17 @@ void SymbolGraph::recordDefaultImplementationRelationships(Symbol S) {
426
426
recordEdge (Symbol (this , VD, nullptr ),
427
427
Symbol (this , MemberVD, nullptr ),
428
428
RelationshipKind::DefaultImplementationOf ());
429
+
430
+ // If P is from a different module, and it's being added to a type
431
+ // from the current module, add a `memberOf` relation to the extended
432
+ // protocol.
433
+ if (MemberVD->getModuleContext () != &M && VD->getDeclContext ()) {
434
+ if (auto *ExP = VD->getDeclContext ()->getSelfNominalTypeDecl ()) {
435
+ recordEdge (Symbol (this , VD, nullptr ),
436
+ Symbol (this , ExP, nullptr ),
437
+ RelationshipKind::MemberOf ());
438
+ }
439
+ }
429
440
}
430
441
}
431
442
}
Original file line number Diff line number Diff line change
1
+ public protocol RemoteP {
2
+ func someFunc( )
3
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-build-swift %S/Inputs/RemoteP.swift -module-name RemoteP -emit-module -emit-module-path %t/
3
+ // RUN: %target-build-swift %s -module-name Remote -emit-module -emit-module-path %t/ -I %t
4
+ // RUN: %target-swift-symbolgraph-extract -module-name Remote -I %t -pretty-print -output-dir %t
5
+ // RUN: %FileCheck %s --input-file %t/Remote.symbols.json
6
+ // RUN: %FileCheck %s --input-file %t/Remote.symbols.json --check-prefix MEMBER
7
+
8
+ import RemoteP
9
+
10
+ public protocol LocalP : RemoteP { }
11
+
12
+ public extension LocalP {
13
+ func someFunc( ) { }
14
+ }
15
+
16
+ // default implementations that are for protocols in a different module should have a `memberOf`
17
+ // relation linking them to a local symbol, if one exists
18
+
19
+ // CHECK: "kind": "defaultImplementationOf"
20
+ // CHECK-NEXT: "source": "s:6Remote6LocalPPAAE8someFuncyyF"
21
+ // CHECK-NEXT: "target": "s:7RemotePAAP8someFuncyyF"
22
+ // CHECK-NEXT: "targetFallback": "RemoteP.RemoteP.someFunc()"
23
+
24
+ // MEMBER: "kind": "memberOf"
25
+ // MEMBER-NEXT: "source": "s:6Remote6LocalPPAAE8someFuncyyF"
26
+ // MEMBER-NEXT: "target": "s:6Remote6LocalPP"
You can’t perform that action at this time.
0 commit comments