Skip to content

Commit 922e230

Browse files
authored
Merge pull request #59521 from apple/revert-59480-QuietMisdreavus/underscored-protocols
Revert "consider requirements of an underscored protocol to also be underscored"
2 parents 21d3510 + 5e065f0 commit 922e230

File tree

2 files changed

+3
-63
lines changed

2 files changed

+3
-63
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -574,56 +574,6 @@ SymbolGraph::serializeDeclarationFragments(StringRef Key, Type T,
574574
T->print(Printer, Options);
575575
}
576576

577-
namespace {
578-
579-
/// Returns the first satisfied protocol requirement for the given decl.
580-
const ValueDecl *getProtocolRequirement(const ValueDecl *VD) {
581-
auto reqs = VD->getSatisfiedProtocolRequirements();
582-
583-
if (!reqs.empty())
584-
return reqs.front();
585-
else
586-
return nullptr;
587-
}
588-
589-
/// Returns the protocol that the given decl is a requirement or conformance of, if any.
590-
const ProtocolDecl *getSourceProtocol(const Decl *D) {
591-
const auto *DC = D->getDeclContext();
592-
593-
// First check to see whether it's declared directly in the protocol decl
594-
if (const auto *P = dyn_cast<ProtocolDecl>(DC))
595-
return P;
596-
597-
// Next look at whether it's an extension on a protocol
598-
if (const auto *Extension = dyn_cast<ExtensionDecl>(DC)) {
599-
if (const auto *ExtendedProtocol = Extension->getExtendedProtocolDecl()) {
600-
return ExtendedProtocol;
601-
}
602-
}
603-
604-
// Then check to see whether it's an implementation of a protocol requirement
605-
if (const auto *VD = dyn_cast<ValueDecl>(D)) {
606-
if (const auto *Requirement = getProtocolRequirement(VD)) {
607-
if (const auto *P = dyn_cast<ProtocolDecl>(Requirement->getDeclContext())) {
608-
return P;
609-
}
610-
}
611-
}
612-
613-
// If all those didn't work, there's no protocol to fetch
614-
return nullptr;
615-
}
616-
617-
/// Returns whether the given decl is from a protocol, and that protocol has an underscored name.
618-
bool isFromUnderscoredProtocol(const Decl *D) {
619-
if (const auto *P = getSourceProtocol(D))
620-
return P->hasUnderscoredNaming();
621-
622-
return false;
623-
}
624-
625-
}
626-
627577
bool SymbolGraph::isImplicitlyPrivate(const Decl *D,
628578
bool IgnoreContext) const {
629579
// Don't record unconditionally private declarations
@@ -632,7 +582,7 @@ bool SymbolGraph::isImplicitlyPrivate(const Decl *D,
632582
}
633583

634584
// Don't record effectively internal declarations if specified
635-
if (D->hasUnderscoredNaming() || isFromUnderscoredProtocol(D)) {
585+
if (D->hasUnderscoredNaming()) {
636586
// Some implicit decls from Clang with underscored names sneak in, so throw those out
637587
if (const auto *clangD = D->getClangDecl()) {
638588
if (clangD->isImplicit())

test/SymbolGraph/Symbols/SkipsPublicUnderscore.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ public class SomeClass {
2222

2323
// PUBLIC-NOT: precise:{{.*}}_ProtocolShouldntAppear
2424
// PUBLIC-NOT: precise:{{.*}}PublicProtocol
25-
// PUBLIC-NOT: precise:{{.*}}someHiddenVar
2625
@_show_in_interface
27-
public protocol _ProtocolShouldntAppear {
28-
static var someHiddenVar: String { get }
29-
}
26+
public protocol _ProtocolShouldntAppear {}
3027

3128
// PUBLIC-NOT: _ShouldntAppear
3229
// INTERNAL-DAG: _ShouldntAppear
@@ -49,18 +46,11 @@ public struct _ShouldntAppear: PublicProtocol, _ProtocolShouldntAppear {
4946
// INTERNAL-DAG: InnerInnerShouldntAppear
5047
public struct InnerInnerShouldntAppear {}
5148
}
52-
53-
// INTERNAL-DAG: "precise": "s:21SkipsPublicUnderscore15_ShouldntAppearV13someHiddenVarSSvpZ"
54-
public static var someHiddenVar: String { "someHiddenVar" }
5549
}
5650

5751
// A public type's relationship to an "internal" protocol
5852
// shouldn't cause it to be included.
59-
public struct ShouldAppear {}
60-
61-
extension ShouldAppear: _ProtocolShouldntAppear {
62-
public static var someHiddenVar: String { "someHiddenVar" }
63-
}
53+
public struct ShouldAppear: _ProtocolShouldntAppear {}
6454

6555
public struct PublicOuter {
6656
// Nor should an "internal" type's relationship to a "public" protocol.

0 commit comments

Comments
 (0)