Skip to content

[SymbolGraphGen] refactor protocol conformance inheritance checking #66012

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 2 commits into from
May 22, 2023

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://109418762

When a protocol has a class inheritance requirement, and a conformance to that protocol is added via an extension, the code that checks for additional protocols currently crashes due to assuming it will only need to handle protocols and protocol compositions. This PR updates that code to gracefully handle class inheritance requirements by simply skipping them - that information is already handled elsewhere.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@theMomax theMomax left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for fixing this!

It would be great if you could add a check in the test that connects the name of the symbols with their mangled name or at least annotate source and target with the readable names. Otherwise I can only guess what the target/source is.

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

You can also have a BoundGenericClassType or ParameterizedProtocolType:

protocol P: C<Int> {}
protocol Q: Iterator<Int> {}

But if you want a flat list of inherited protocols without the superclass or any sugar, call ProtocolDecl::getInheritedProtocols() instead of getInherited().

Similarly to get the “semantic” protocols for an ExtensionDecl, call getLocalConformances() and then getProtocol() on each element.

@QuietMisdreavus
Copy link
Contributor Author

It looks like ParameterizedProtocolTypes still resolve down to ProtocolDecls via the getAnyNominal that's called right before the code i added. However, that's a good catch on BoundGenericClassType. I'll take a look at the functions you mentioned. Thanks!

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

@QuietMisdreavus QuietMisdreavus changed the title [SymbolGraphGen] skip class types when handling protocol expansions [SymbolGraphGen] refactor protocol conformance inheritance checking May 19, 2023
@QuietMisdreavus QuietMisdreavus merged commit e120a82 into main May 22, 2023
@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus/proto-class-inheritance branch May 22, 2023 15:27
NuriAmari pushed a commit to NuriAmari/swift that referenced this pull request May 28, 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.

3 participants