Skip to content

[ABI] Mangle retroactive conformances as part of bound generic types. #14296

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

DougGregor
Copy link
Member

A "retroactive" protocol conformance is a conformance that is provided
by a module that is neither the module that defines the protocol nor
the module that defines the conforming type. It is possible for such
conformances to conflict at runtime, if defined in different modules
that were not both visible to the compiler at the same time.

When mangling a bound generic type, also mangle retroactive protocol
conformances that were needed to satisfy the generic requirements of
the generic type. This prevents name collisions between (e.g.) types
formed using retroactive conformances from different modules. The
impact on the size of the mangling is expected to be relatively small,
because most conformances are not retroactive.

Make this use of protocol-conformance substitutable, since we are likely to see the same retroactive conformances in multiple places in the same mangled name.

Fixes the ABI part of rdar://problem/14375889.

@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - de1a6524d840b009f50d4c449715ecbf99dccf9c

@DougGregor DougGregor force-pushed the mangle-retroactive-conformances branch from de1a652 to ad5746f Compare January 31, 2018 06:00
@DougGregor
Copy link
Member Author

Whoops.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - de1a6524d840b009f50d4c449715ecbf99dccf9c

@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - de1a6524d840b009f50d4c449715ecbf99dccf9c

@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - ad5746f56f4b0fdde301f63a1830b1429b13061c

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

LGTM, even all the fiddly remangling bits.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ad5746f56f4b0fdde301f63a1830b1429b13061c

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

@DougGregor
Copy link
Member Author

This mangled name from a SwiftPM test:

 $SSS12PackageGraph0A19ContainerConstraintV11RequirementOySS_SSAA0aC10Identifier11TestSupportg_GACySSAHg_Gs5Error_pIgxxozo_SS9container_AI11requirementtAJsAK_pIgirzo_TR

illustrates that my attempt to make substitutions for some protocol-conformance productions (but not all of them) isn't going to work.

A "retroactive" protocol conformance is a conformance that is provided
by a module that is neither the module that defines the protocol nor
the module that defines the conforming type. It is possible for such
conformances to conflict at runtime, if defined in different modules
that were not both visible to the compiler at the same time.

When mangling a bound generic type, also mangle retroactive protocol
conformances that were needed to satisfy the generic requirements of
the generic type. This prevents name collisions between (e.g.) types
formed using retroactive conformances from different modules. The
impact on the size of the mangling is expected to be relatively small,
because most conformances are not retroactive.

Fixes the ABI part of rdar://problem/14375889.
@DougGregor DougGregor force-pushed the mangle-retroactive-conformances branch from ad5746f to 28c489c Compare January 31, 2018 17:53
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

I'll come back to making protocol conformances substitutable in a bit.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit fedbd53 into swiftlang:master Jan 31, 2018
@DougGregor DougGregor deleted the mangle-retroactive-conformances branch January 31, 2018 19:15
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.

4 participants