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] move "protocol implementations" check into isImplicitlyPrivate #64867

Merged
merged 2 commits into from
Apr 5, 2023

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://107432084

The original implementation of -skip-protocol-implementations focused on dropping symbols that matched the description of "protocol implementation", but didn't extend the check to any extra relationships that can show up. This meant that if a "protocol implementation" symbol is a type that adds a protocol implementation via an extension, that protocol conformance still ends up in the symbol graph, creating a malformed graph where a relationship references a symbol that doesn't exist. This PR moves the "protocol implementation" check into SymbolGraph::isImplictlyPrivate, alongside the other checks for dropping a symbol, to catch these scenarios.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

namespace {

const ValueDecl *getProtocolRequirement(const ValueDecl *VD) {
auto reqs = VD->getSatisfiedProtocolRequirements();
Copy link
Contributor

Choose a reason for hiding this comment

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

mega nit, llvm code bases tend to do locals in ThisKindOfCamelCase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code's copy/pasted from Symbol::getProtocolRequirement, which (IIRC) was itself a refactoring of existing code. I can change it if you want, but i'd be touching some other places too.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah don't worry about it then.

@@ -45,3 +49,15 @@ public struct SomeStruct: SomeProtocol {
/// Local docs
public func otherFunc() {}
}

// Make sure that protocol conformances added in extensions don't create bogus symbol relationships (rdar://107432084)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a test that checks that we are still emitting it for one that has it's own doc comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a commit that adds this to the test.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

@QuietMisdreavus QuietMisdreavus merged commit ff5c531 into main Apr 5, 2023
@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus/skip-protocol-extensions branch April 5, 2023 15:53
QuietMisdreavus added a commit that referenced this pull request Apr 5, 2023
QuietMisdreavus added a commit that referenced this pull request Apr 14, 2023
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