Skip to content

Extension Block Symbols: Fix inheritsFrom Relationship #61951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/SymbolGraphGen/SymbolGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NominalTypeDecl>(VD)) {
for (const auto &InheritanceLoc : NTD->getInherited()) {
auto Ty = InheritanceLoc.getType();
Expand All @@ -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());
}
Expand Down
11 changes: 0 additions & 11 deletions test/SymbolGraph/Relationships/InheritsFrom.swift

This file was deleted.

11 changes: 11 additions & 0 deletions test/SymbolGraph/Relationships/InheritsFrom/Basic.swift
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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/[email protected] --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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public class Base {}
public class Derived: Base {}