mirror of
https://github.com/apple/swift.git
synced 2026-11-30 09:15:01 +01:00
When an extension adds a conditional conformance that can't be printed in the
interface, we reserve it with a dummy extension constrained by
`_ConstraintThatIsNotPartOfTheAPIOfThisLibrary` so that no other module can
declare a conflicting conformance. The set of protocols to reserve was
collected from the existential layout of each inherited type, but that layout
synthesizes entries for every invertible protocol the type doesn't suppress.
An extension like
extension X: InternalP where T == Int {}
would therefore also reserve a conformance to Escapable, which the extension
never declared. Reserving an invertible protocol produces an interface that
can't be read back, since a conditional conformance to a suppressible protocol
is not allowed to depend on an arbitrary requirement. Conformances to
invertible protocols are always re-inferred from the interface anyway, so skip
them when collecting, as we already do when printing synthesized extensions.
Dropping the invertible protocols also means the extension emitted for the
remaining ones can no longer be empty, so the logic that split them into
separate extensions is no longer needed. That split was the source of a second
bug: with nothing left to print, it emitted `extension X : where ...` with no
protocol at all.
Resolves rdar://183466980.