Skip to content

[SymbolGraphGen] don't emit symbols and protocols from unconditionally unavailable extensions #67539

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
merged 1 commit into from
Jul 26, 2023
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
7 changes: 7 additions & 0 deletions lib/SymbolGraphGen/SymbolGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ void SymbolGraph::recordConformanceRelationships(Symbol S) {
});
} else {
for (const auto *Conformance : NTD->getAllConformances()) {
// Check to make sure that this conformance wasn't declared via an
// unconditionally-unavailable extension. If so, don't add that to the graph.
if (const auto *ED = dyn_cast_or_null<ExtensionDecl>(Conformance->getDeclContext())) {
if (isUnconditionallyUnavailableOnAllPlatforms(ED)) {
continue;
}
}
recordEdge(
S, Symbol(this, Conformance->getProtocol(), nullptr),
RelationshipKind::ConformsTo(),
Expand Down
4 changes: 4 additions & 0 deletions lib/SymbolGraphGen/SymbolGraphASTWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
return false;
}

if (SG->isUnconditionallyUnavailableOnAllPlatforms(Extension)) {
return false;
}

if (isUnavailableOrObsoleted(ExtendedNominal)) {
return false;
}
Expand Down
11 changes: 11 additions & 0 deletions test/SymbolGraph/Relationships/ConformsTo/Unavailable.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 Unavailable -emit-module -emit-module-path %t/
// RUN: %target-swift-symbolgraph-extract -module-name Unavailable -I %t -pretty-print -output-dir %t
// RUN: %FileCheck %s --input-file %t/Unavailable.symbols.json

public class MyClass {}

@available(*, unavailable)
extension MyClass: Sendable {}

// CHECK-NOT: conformsTo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -module-name UnavailableExtension -emit-module -emit-module-path %t/
// RUN: %target-swift-symbolgraph-extract -module-name UnavailableExtension -I %t -pretty-print -output-dir %t
// RUN: %FileCheck %s --input-file %t/UnavailableExtension.symbols.json

public class MyClass {}

@available(*, unavailable)
public extension MyClass {
func myFunc() {}
}

// CHECK-NOT: myFunc