Skip to content

ASTPrinter: handle inverses in compositions #73770

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

Conversation

kavon
Copy link
Member

@kavon kavon commented May 21, 2024

The basic inheritance clause emission in ASTPrinter operates on InheritedEntry's, but does not canonicalize types. It's been designed to consider an entire composition unprintable because one member is unprintable (e.g., the protocol is not public).

This rejection is what was causing ~Copyable in some compositions to be missing from interface files (rdar://126090425). Fixing that is the purpose of this patch.

What happens, then, if you mix public and nonpublic protocols in a composition? A second facility called the InheritedProtocolCollector later does find the public protocols, and emits extensions at the end of the interface file to declare the additional conformances the ininitial declaration printer missed.

We can't generally emit ~Copyable on an extension, so the fix can't happening there. Refactoring things so there's one source of truth about the protocols being printed is a sizable refactoring that I will defer for another time.

resolves rdar://126090425

The basic inheritance clause emission in ASTPrinter operates on
InheritedEntry's, but does not canonicalize types. It's been
designed to consider an entire composition unprintable because one
member is unprintable (e.g., the protocol is not public).

This rejection is what was causing `~Copyable` in some compositions to
be missing from interface files (rdar://126090425). Fixing that is the
purpose of this patch.

What happens, then, if you mix public and nonpublic protocols in a
composition? A second facility called the InheritedProtocolCollector
later does find the public protocols, and emits extensions at the end of
the interface file to declare the additional conformances the ininitial
declaration printer missed.

We can't generally emit `~Copyable` on an extension, so the fix can't
happening there. Refactoring things so there's one source of truth about
the protocols being printed is a sizable refactoring that I will defer
for another time.

resolves rdar://126090425
@kavon
Copy link
Member Author

kavon commented May 21, 2024

@swift-ci smoke test

@kavon
Copy link
Member Author

kavon commented May 21, 2024

@swift-ci smoke test Linux

1 similar comment
@etcwilde
Copy link
Member

@swift-ci smoke test Linux

@kavon kavon enabled auto-merge May 21, 2024 05:54
@kavon
Copy link
Member Author

kavon commented May 21, 2024

@swift-ci test Linux

@kavon
Copy link
Member Author

kavon commented May 21, 2024

@swift-ci smoke test linux

@kavon kavon merged commit 6e25d8b into swiftlang:main May 21, 2024
3 of 4 checks passed
@kavon kavon deleted the tilde-copyable-printing-interface-rdar126090425 branch May 21, 2024 19:44
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