Skip to content

[Serialization] Keep indirect conformances knowledge with safety #65267

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 1 commit into from
Apr 19, 2023

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Apr 18, 2023

Given a scenario where a public type A, conforms to an internal protocol B, which conforms to a public protocol C. A conforms indirectly to C through a protocol that's hidden from the clients.

This is handled in module interface by printing the indirect conformance of A to C explicitly at the end of the swiftinterface.

We have the same problem with deserialization safety that used to hide the internal protocols from clients, thus breaking the knowledge of the indirect dependency. To keep the indirect conformances, let's consider all protocols as safe and preserve extensions declaring conformances.

rdar://105241772

Given a scenario where a public type A, conforms to an internal protocol
B, which conforms to a public protocol C. A conforms indirectly to C
through a protocol that's hidden from the clients.

This is handled in module interface by printing the indirect conformance
of A to C explicitly at the end of the swiftinterface.

We have the same problem with deserialization safety that used to hide
the internal protocols from clients, thus breaking the knowledge of the
indirect dependency. To keep the indirect conformances, let's consider
all protocols as safe and preserve their conformance information.

rdar://105241772
@xymus xymus requested a review from bnbarham April 18, 2023 21:16
@xymus
Copy link
Contributor Author

xymus commented Apr 18, 2023

@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Apr 18, 2023

Testing against the source compatibility suite with deserialization safety enabled showed no regressions from this change: #65084

@xymus xymus merged commit cc0f42f into swiftlang:main Apr 19, 2023
@xymus xymus deleted the serial-indirect-conformances branch April 19, 2023 17:52
tshortli added a commit to tshortli/swift that referenced this pull request Aug 30, 2023
In swiftlang#65267 deserialization safety was made
more conservative, allowing deserialization of any protocol and
deserialization of any extension declaring an explicit conformance to any
protocol. We can refine this to only allow deserialization of safe protocols
and deserialization of extensions declaring conformances to safe protocols.
Importantly, though, we must look up all conformances declared by the
extension, not just the explicit ones.

Resolves rdar://114673761
tshortli added a commit to tshortli/swift that referenced this pull request Aug 30, 2023
In swiftlang#65267 deserialization safety was made
more conservative, allowing deserialization of any protocol and
deserialization of any extension declaring an explicit conformance to any
protocol. We can refine this to only allow deserialization of safe protocols
and deserialization of extensions declaring conformances to safe protocols.
Importantly, though, we must look up all conformances declared by the
extension, not just the explicit ones.

Resolves rdar://114673761
tshortli added a commit to tshortli/swift that referenced this pull request Aug 30, 2023
In swiftlang#65267 deserialization safety was made
more conservative, allowing deserialization of any protocol and
deserialization of any extension declaring an explicit conformance to any
protocol. We can refine this to only allow deserialization of safe protocols
and deserialization of extensions declaring conformances to safe protocols.
Importantly, though, we must look up all conformances declared by the
extension, not just the explicit ones.

Resolves rdar://114673761
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.

1 participant