Skip to content

[AST] Progress toward handling indirect conformances in witness tables #7943

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

Make some progress toward handling "indirect conformances", e.g., those that are introduced via where clauses on associated types, in IRGen. This currently has two independent pieces:

  • Teach requirement sources that involve protocol requirements to keep track of the dependent type that we're looking through to find the conformance we want. This will allow us to find the conformance later, but we're not using it yet.
  • Reimplement NormalProtocolConformance::getAssocated{Type|Conformance} to make them handle indirect conformances properly.

The second part lets us emit witness tables involving indirect conformances, but we need to wire up the first part before we can actually use them.

For a protocol requirement element within a requirement source, track
both the protocol in which the requirement was introduced as well as
the dependent type (relative to that protocol) on which the
requirement was introduced. This information is important when
reconstructing the path from a requirement-as-written to the location
of a desired protocol conformance.
Reimplement these methods, making use of Type::subst() for
the former and the stored protocol conformances that correspond to the
protocol's requirement signature for the latter. This is enough to
emit witness tables with indirect conformance requirements in them.
@DougGregor
Copy link
Member Author

Adding this to the new test:

func useQ<T: Q>(_: T) { }
func useP3<T: P3>(_ t: T) {
  useQ(t.getAssocP3().getAssocP2())
}

will assert in access-path computation because we're not using requirement sources there.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

@rjmccall you'll be interested in this.

@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 d1ea199 into swiftlang:master Mar 6, 2017
@DougGregor DougGregor deleted the witness-table-indirect-conformances branch March 6, 2017 23:58
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