Skip to content

Commit ddf5cf9

Browse files
authored
fix symbol graph bug where enabling extension block format caused inheritsFrom relationships of extended symbols to be emitted in extension graphs (#61951)
1 parent fc954d2 commit ddf5cf9

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ void SymbolGraph::recordConformanceSynthesizedMemberRelationships(Symbol S) {
377377

378378
void
379379
SymbolGraph::recordInheritanceRelationships(Symbol S) {
380-
const auto VD = S.getSymbolDecl();
380+
const auto VD = S.getLocalSymbolDecl();
381381
if (const auto *NTD = dyn_cast<NominalTypeDecl>(VD)) {
382382
for (const auto &InheritanceLoc : NTD->getInherited()) {
383383
auto Ty = InheritanceLoc.getType();
@@ -390,7 +390,7 @@ SymbolGraph::recordInheritanceRelationships(Symbol S) {
390390
continue;
391391
}
392392

393-
recordEdge(Symbol(this, VD, nullptr),
393+
recordEdge(Symbol(this, NTD, nullptr),
394394
Symbol(this, InheritedTypeDecl, nullptr),
395395
RelationshipKind::InheritsFrom());
396396
}

test/SymbolGraph/Relationships/InheritsFrom.swift

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -module-name Basic -emit-module -emit-module-path %t/
3+
// RUN: %target-swift-symbolgraph-extract -module-name Basic -I %t -pretty-print -output-dir %t
4+
// RUN: %FileCheck %s --input-file %t/Basic.symbols.json
5+
6+
public class Base {}
7+
public class Derived: Base {}
8+
9+
// CHECK: "kind": "inheritsFrom"
10+
// CHECK-NEXT: "source": "s:5Basic7DerivedC"
11+
// CHECK-NEXT: "target": "s:5Basic4BaseC"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %S/Inputs/Base.swift -module-name Base -emit-module -emit-module-path %t/
3+
// RUN: %target-build-swift %s -module-name ExtensionBlockSymbol -emit-module -emit-module-path %t/ -I %t
4+
// RUN: %target-swift-symbolgraph-extract -module-name ExtensionBlockSymbol -I %t -pretty-print -output-dir %t -emit-extension-block-symbols
5+
// RUN: %target-swift-symbolgraph-extract -module-name Base -I %t -pretty-print -output-dir %t -emit-extension-block-symbols
6+
// RUN: %FileCheck %s --input-file %t/Base.symbols.json --check-prefix BASE
7+
// RUN: %FileCheck %s --input-file %t/ExtensionBlockSymbol.symbols.json --check-prefix LOCAL
8+
// RUN: %FileCheck %s --input-file %t/[email protected] --check-prefix EXTENSION
9+
10+
import Base
11+
12+
public extension Derived {
13+
func foo() {}
14+
}
15+
16+
// BASE: "kind": "inheritsFrom"
17+
// BASE-NEXT: "source": "s:4Base7DerivedC"
18+
// BASE-NEXT: "target": "s:4BaseAAC"
19+
20+
// LOCAL-DAG: "symbols": []
21+
// LOCAL-DAG: "relationships": []
22+
23+
// EXTENSION-NOT: "kind": "inheritsFrom"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public class Base {}
2+
public class Derived: Base {}

0 commit comments

Comments
 (0)