Skip to content
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

[SymbolGraphGen] improve handling of underscored protocols #77251

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://124483146, resolves rdar://128143861

This PR aims to improve SymbolGraphGen's handling of "underscored protocols". These protocols are meant to be treated as an implementation detail and not surfaced in public documentation themselves, even if their methods are meant to be public. An example is the standard library's _ArrayProtocol, which a handful of types conform to as part of their Collection conformances. Currently, the symbols that are synthesized as part of _ArrayProtocol contain sourceOrigin information that surfaces this protocol, which Swift-DocC then uses to sort these symbols under an _ArrayProtocol Implementations collection page. These methods should instead be treated as native children of the conforming type, discarding any trace of the actual protocol itself.

In addition, extensions on these underscored protocols are discarded due to their owning extension adding them to a "private" symbol. We should treat these symbols as natively public and add them to documentation.

This PR also changes the "synthesized symbols" behavior to add synthesized symbols for underscored protocols, even when the user has asked to ignore synthesized symbols or protocol implementations. This should improve the handling of projects that build with -skip-protocol-implementations but use underscored protocols, even indirectly via Foundation or the like.

Children of underscored protocols should be treated as native children
of their conforming types. To accomplish this, ignore underscored
protocols in the isInherentlyPrivate check.

rdar://124483146
Comment on lines +348 to +352
ExtensionAnalyzer.forEachExtensionMergeGroup(
MergeGroupKind, [&](ArrayRef<ExtensionInfo> ExtensionInfos) {
const auto StdlibModule =
OwningNominal->getASTContext().getStdlibModule(
/*loadIfAbsent=*/true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git clang-format somewhat mangled this block of code, but i left the change in so that future clang-format runs wouldn't have to deal with it.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@daniel-grumberg daniel-grumberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants