Skip to content

[4.1] [IDE] Teach type checker about conditional conformance extensions. #14634

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

huonw
Copy link
Contributor

@huonw huonw commented Feb 14, 2018

Explanation: The IDE type checker previously didn't understand that some extensions from which it copies items for documentation purposes (e.g. extension Proto1 { ... }) might only be conditionally enabled (i.e. a conditional conformance like extension Foo: Proto1 where T: Proto2 and that the archetypes needed to understand the types of the new items might be different to the archetypes of the nominal type decl (i.e. the archetype for T has to conform to Proto2 for things to make sense). This resulted in some substs failing, and so canonical types not being remapped to the correct user-facing type for things like inclusion in documentation (meaning it can include things like var last: τ_0_0.Element? { get }).
Scope of Issue: Only major code changes are in the IDE support code/SourceKit, and those were mostly mechanical.
Origination: Missed place that needed updating for conditional conformances.
Risk: Low: the changes are somewhat large (although only ~550 of the 1100 listed added/deleted lines are just changes to generated expected output for a test), but mostly mechanical change, defensively programmed.
Reviewed By: @DougGregor
Testing: Compiler regression tests, manual verification of toolchain in Xcode
Radar / SR: rdar://problem/36553066

No point in getting rid of the sugar so early.
Before conditional conformances, the archetypes in conformance
extensions (i.e. extension Foo: SomeProtocol) were equivalent to those
in the type decl, with the same protocol bounds and so on. The code for
printing "synthesized" members relied on this fact. This commit teaches
that code to deal with archetypes in the conditional conformance
extension when required.

Fixes rdar://problem/36553066 and SR-6930.
@huonw
Copy link
Contributor Author

huonw commented Feb 14, 2018

@swift-ci please test

@huonw huonw force-pushed the doc-conditional-conformances-4.1 branch from 3948e63 to f883c48 Compare February 15, 2018 06:58
@huonw
Copy link
Contributor Author

huonw commented Feb 15, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3948e63329cccdd335c405800e1b112f82036e25

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3948e63329cccdd335c405800e1b112f82036e25

@huonw
Copy link
Contributor Author

huonw commented Feb 15, 2018

Oh, whoops, didn't mean to nominate this one just yet. Don't merge please!

@huonw
Copy link
Contributor Author

huonw commented Feb 16, 2018

@swift-ci please nominate

@AnnaZaks AnnaZaks merged commit 2bc8470 into swiftlang:swift-4.1-branch Feb 16, 2018
@huonw huonw deleted the doc-conditional-conformances-4.1 branch February 16, 2018 01:17
Copy link
Contributor

@akyrtzi akyrtzi left a comment

Choose a reason for hiding this comment

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

When adding new code to test/SourceKit/DocSupport tests, could you add them at the end of the file ? That way you will avoid all the change churn with updating offsets for the existing code that comes after your additions.

Otherwise LGTM.

@huonw
Copy link
Contributor Author

huonw commented Feb 16, 2018

I thought I did add them at the end of the file? Maybe I added them to the wrong file?

@akyrtzi
Copy link
Contributor

akyrtzi commented Feb 16, 2018

Apologies, I misunderstood, LGTM.

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