Skip to content

Commit 632f0a3

Browse files
don't emit symbols and protocols from unconditionally unavailable extensions (#67539)
rdar://112137607
1 parent 1d7288e commit 632f0a3

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ void SymbolGraph::recordConformanceRelationships(Symbol S) {
493493
});
494494
} else {
495495
for (const auto *Conformance : NTD->getAllConformances()) {
496+
// Check to make sure that this conformance wasn't declared via an
497+
// unconditionally-unavailable extension. If so, don't add that to the graph.
498+
if (const auto *ED = dyn_cast_or_null<ExtensionDecl>(Conformance->getDeclContext())) {
499+
if (isUnconditionallyUnavailableOnAllPlatforms(ED)) {
500+
continue;
501+
}
502+
}
496503
recordEdge(
497504
S, Symbol(this, Conformance->getProtocol(), nullptr),
498505
RelationshipKind::ConformsTo(),

lib/SymbolGraphGen/SymbolGraphASTWalker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
162162
return false;
163163
}
164164

165+
if (SG->isUnconditionallyUnavailableOnAllPlatforms(Extension)) {
166+
return false;
167+
}
168+
165169
if (isUnavailableOrObsoleted(ExtendedNominal)) {
166170
return false;
167171
}
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 Unavailable -emit-module -emit-module-path %t/
3+
// RUN: %target-swift-symbolgraph-extract -module-name Unavailable -I %t -pretty-print -output-dir %t
4+
// RUN: %FileCheck %s --input-file %t/Unavailable.symbols.json
5+
6+
public class MyClass {}
7+
8+
@available(*, unavailable)
9+
extension MyClass: Sendable {}
10+
11+
// CHECK-NOT: conformsTo
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -module-name UnavailableExtension -emit-module -emit-module-path %t/
3+
// RUN: %target-swift-symbolgraph-extract -module-name UnavailableExtension -I %t -pretty-print -output-dir %t
4+
// RUN: %FileCheck %s --input-file %t/UnavailableExtension.symbols.json
5+
6+
public class MyClass {}
7+
8+
@available(*, unavailable)
9+
public extension MyClass {
10+
func myFunc() {}
11+
}
12+
13+
// CHECK-NOT: myFunc

0 commit comments

Comments
 (0)