diff --git a/lib/SymbolGraphGen/SymbolGraph.cpp b/lib/SymbolGraphGen/SymbolGraph.cpp index 7fc9d1e705812..1a62f6e0c42c1 100644 --- a/lib/SymbolGraphGen/SymbolGraph.cpp +++ b/lib/SymbolGraphGen/SymbolGraph.cpp @@ -376,7 +376,7 @@ void SymbolGraph::recordConformanceSynthesizedMemberRelationships(Symbol S) { void SymbolGraph::recordInheritanceRelationships(Symbol S) { - const auto VD = S.getSymbolDecl(); + const auto VD = S.getLocalSymbolDecl(); if (const auto *NTD = dyn_cast(VD)) { for (const auto &InheritanceLoc : NTD->getInherited()) { auto Ty = InheritanceLoc.getType(); @@ -389,7 +389,7 @@ SymbolGraph::recordInheritanceRelationships(Symbol S) { continue; } - recordEdge(Symbol(this, VD, nullptr), + recordEdge(Symbol(this, NTD, nullptr), Symbol(this, InheritedTypeDecl, nullptr), RelationshipKind::InheritsFrom()); } diff --git a/test/SymbolGraph/Relationships/InheritsFrom.swift b/test/SymbolGraph/Relationships/InheritsFrom.swift deleted file mode 100644 index 1a85389719aa6..0000000000000 --- a/test/SymbolGraph/Relationships/InheritsFrom.swift +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %empty-directory(%t) -// RUN: %target-build-swift %s -module-name InheritsFrom -emit-module -emit-module-path %t/ -// RUN: %target-swift-symbolgraph-extract -module-name InheritsFrom -I %t -pretty-print -output-dir %t -// RUN: %FileCheck %s --input-file %t/InheritsFrom.symbols.json - -public class Base {} -public class Derived: Base {} - -// CHECK: "kind": "inheritsFrom" -// CHECK-NEXT: "source": "s:12InheritsFrom7DerivedC" -// CHECK-NEXT: "target": "s:12InheritsFrom4BaseC" diff --git a/test/SymbolGraph/Relationships/InheritsFrom/Basic.swift b/test/SymbolGraph/Relationships/InheritsFrom/Basic.swift new file mode 100644 index 0000000000000..b63b638ff15fd --- /dev/null +++ b/test/SymbolGraph/Relationships/InheritsFrom/Basic.swift @@ -0,0 +1,11 @@ +// RUN: %empty-directory(%t) +// RUN: %target-build-swift %s -module-name Basic -emit-module -emit-module-path %t/ +// RUN: %target-swift-symbolgraph-extract -module-name Basic -I %t -pretty-print -output-dir %t +// RUN: %FileCheck %s --input-file %t/Basic.symbols.json + +public class Base {} +public class Derived: Base {} + +// CHECK: "kind": "inheritsFrom" +// CHECK-NEXT: "source": "s:5Basic7DerivedC" +// CHECK-NEXT: "target": "s:5Basic4BaseC" diff --git a/test/SymbolGraph/Relationships/InheritsFrom/ExtensionBlockSymbol.swift b/test/SymbolGraph/Relationships/InheritsFrom/ExtensionBlockSymbol.swift new file mode 100644 index 0000000000000..c458d01c19bfa --- /dev/null +++ b/test/SymbolGraph/Relationships/InheritsFrom/ExtensionBlockSymbol.swift @@ -0,0 +1,23 @@ +// RUN: %empty-directory(%t) +// RUN: %target-build-swift %S/Inputs/Base.swift -module-name Base -emit-module -emit-module-path %t/ +// RUN: %target-build-swift %s -module-name ExtensionBlockSymbol -emit-module -emit-module-path %t/ -I %t +// RUN: %target-swift-symbolgraph-extract -module-name ExtensionBlockSymbol -I %t -pretty-print -output-dir %t -emit-extension-block-symbols +// RUN: %target-swift-symbolgraph-extract -module-name Base -I %t -pretty-print -output-dir %t -emit-extension-block-symbols +// RUN: %FileCheck %s --input-file %t/Base.symbols.json --check-prefix BASE +// RUN: %FileCheck %s --input-file %t/ExtensionBlockSymbol.symbols.json --check-prefix LOCAL +// RUN: %FileCheck %s --input-file %t/ExtensionBlockSymbol@Base.symbols.json --check-prefix EXTENSION + +import Base + +public extension Derived { + func foo() {} +} + +// BASE: "kind": "inheritsFrom" +// BASE-NEXT: "source": "s:4Base7DerivedC" +// BASE-NEXT: "target": "s:4BaseAAC" + +// LOCAL-DAG: "symbols": [] +// LOCAL-DAG: "relationships": [] + +// EXTENSION-NOT: "kind": "inheritsFrom" diff --git a/test/SymbolGraph/Relationships/InheritsFrom/Inputs/Base.swift b/test/SymbolGraph/Relationships/InheritsFrom/Inputs/Base.swift new file mode 100644 index 0000000000000..f6f60b87e60ca --- /dev/null +++ b/test/SymbolGraph/Relationships/InheritsFrom/Inputs/Base.swift @@ -0,0 +1,2 @@ +public class Base {} +public class Derived: Base {}