Skip to content

Never use a protocol's requirement signature as a generic signature #10711

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

The protocol's requirement signature is not suitable for use as a complete generic signature, because it (intentionally) omits the root Self: MyProtocol requirement that makes the set of requirements sensible. Stop using generic signatures for requirement signatures---it's just a flat set of requirements.

The only nontrivial change here is to conformance access paths. When we didn't have a requirement signature to use when constructing a requirement source (i.e., due to recursive protocols), we need to recanonicalize the path based on the now-computed requirement signature. This was canonicalizing using the generic signature formed from the requirement signature; use the protocol's generic signature instead, with a slight adjustment at the root of the requirement source.

All of this to eliminate the penultimate use of ArchetypeResolutionKind::AlwaysPartial.

When a requirement signature could not be used to construct the
requirement sources in a conformance access path (due to recursive
protocols), we rebuild the path based on knowledge of the
protocol. Instead of using the requirement signature for this (which
depends on a canonicalized generic signature that breaks our intended
invariants w.r.t. unresolved nested types), use the protocol's generic
signature instead. This requires one small adjustment at the root of
the path, but is otherwise NFC.

Eliminates the penultimate use of AlwaysPartial.
Rather than pretend that the requirement signature of a protocol is a
full, well-formed generic signature that one can meaningfully query,
treat it as a flat set of requirements. Nearly all clients already did
this, but make it official. NFC
@DougGregor DougGregor force-pushed the requirement-signature-improvements branch from 910c2cf to 8f9618b Compare June 29, 2017 21:29
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

The outside representation already went to a flat set of requirements;
make the internal representation match so we aren't tempted to use the
requirement signature as inputs to a generic signature.
@DougGregor DougGregor force-pushed the requirement-signature-improvements branch from 8f9618b to 5bacc08 Compare June 29, 2017 21:36
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 97f2f8b into swiftlang:master Jun 29, 2017
@DougGregor DougGregor deleted the requirement-signature-improvements branch June 29, 2017 22:04
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