Skip to content

AST: Tweak a concrete-nested-type-of-archetype hack slightly [4.0] #10440

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

Conversation

slavapestov
Copy link
Contributor

  • Description: There is a long-standing representational issue where SubstitutionMaps have a hard time dealing with associated types that are constrained to concrete types, but themselves have nested associated types. We put in a workaround in 3.1. In 4.0, I made the workaround slightly narrower so that we can test the conformance lookup logic better. Unfortunately I missed a case in 4.0 where we should have applied the workaround but didn't. This patch brings back the workaround in that specific case.

  • Scope of the issue: Affects an open source project in the source compatibility test suite (JSQDataSourcesKit).

  • Origination: Regression in 4.0.

  • Risk: Very low, this just performs a module-based lookup in one more case that wasn't being done before, and this should always work.

  • Tested: Reduced test case added.

  • Reviewed by: @DougGregor

  • Radar: rdar://problem/32773028

When an archetype conforms to a protocol abstractly (ie, it is
not class-constrained and we don't have any further information
other than that it conforms), we can recover nested types,
but we cannot recover the conformance of those nested types
to protocols if those conformances are concrete (the nested
type might be concrete, or it might be a class-constrained
archetype).

To work around this, we added a hack where if the conformance
lookup in the SubstitutionMap fails, we fall back to the module.

This is horrible and unprincipled, but has to remain in place
until more infrastructure is plumbed through.

Commit 620db5f made this
workaround apply in fewer cases, so that we could still catch
cases where the SubstitutionMap was constructed with missing
conformances.

Unfortunately this workaround didn't handle the case where the
nested type was an archetype with a superclass constraint.

This will all go away soon, but for now tweak the logic a bit,
since I really want to keep the "narrow" workaround in place
and not the general fallback, otherwise we run the risk of
SubstitutionMap conformance lookup bitrotting completely.

Fixes <https://bugs.swift.org/browse/SR-4088> and
<rdar://problem/32773028>.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Sadness. LGTM

@slavapestov slavapestov changed the title Abstract conformance versus concrete nested type ugh not again [4.0] AST: Tweak a concrete-nested-type-of-archetype hack slightly [4.0] Jun 21, 2017
@tkremenek tkremenek merged commit 3e8e3fb into swiftlang:swift-4.0-branch Jun 21, 2017
@jessesquires
Copy link

Thanks @slavapestov and @DougGregor 🙌 👏 🎉

@gistya
Copy link

gistya commented Oct 30, 2017

What about 3.2? I am getting these all the time in a Swift 3.2 project on Xcode 9.0.1 and 9.1 beta 3.

@DougGregor
Copy link
Member

@gistya This pull request went in to Xcode 9. Have you filed a bug for the issue you're seeing?

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.

5 participants