Skip to content

Conversation

@DougGregor
Copy link
Member

Reimplement the RequirementSource class, which captures how
a particular requirement is satisfied by a generic signature. The
primary goal of this rework is to keep the complete path one follows
in a generic signature to get from some explicit requirement in the
generic signature to some derived requirement or type, e.g.,

  1. Start at an explicit requirement "C: Collection"
  2. Go to the inherited protocol Sequence,
  3. Get the "Iterator" associated type
  4. Get its conformance to "IteratorProtocol"
  5. Get the "Element" associated type

We don't currently capture all of the information we want in the path,
but the basic structure is there, and should also allow us to capture
more source-location information, find the "optimal" path, etc. There are
are a number of potential uses:

  • IRGen could eventually use this to dig out the witness tables and
    type metadata it needs, instead of using its own fulfillment
    strategy
  • SubstitutionMap could use this to lookup conformances, rather than
    it's egregious hacks
  • The canonical generic signature builder could use this to lookup
    conformances as needed, e.g., for the recursive-conformances case.

... and probably more simplifications, once we get this right.

@DougGregor DougGregor changed the title [GenericSig Builder] Rework RequirementSource to describe requirement path [WIP] [GenericSig Builder] Rework RequirementSource to describe requirement path Feb 17, 2017
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@slavapestov
Copy link
Contributor

So IRGen's code is a "fulfillment strategy" and SubstitutionMap is just "egregious hacks"? That hurts, man, that hurts! ;-)

… path.

Reimplement the RequirementSource class, which captures how
a particular requirement is satisfied by a generic signature. The
primary goal of this rework is to keep the complete path one follows
in a generic signature to get from some explicit requirement in the
generic signature to some derived requirement or type, e.g.,

1) Start at an explicit requirement "C: Collection"
2) Go to the inherited protocol Sequence,
3) Get the "Iterator" associated type
4) Get its conformance to "IteratorProtocol"
5) Get the "Element" associated type

We don't currently capture all of the information we want in the path,
but the basic structure is there, and should also allow us to capture
more source-location information, find the "optimal" path, etc. There are
are a number of potential uses:

* IRGen could eventually use this to dig out the witness tables and
  type metadata it needs, instead of using its own fulfillment
  strategy
* SubstitutionMap could use this to lookup conformances, rather than
  it's egregious hacks
* The canonical generic signature builder could use this to lookup
  conformances as needed, e.g., for the recursive-conformances case.

... and probably more simplifications, once we get this right.
@DougGregor DougGregor changed the title [WIP] [GenericSig Builder] Rework RequirementSource to describe requirement path [GenericSig Builder] Rework RequirementSource to describe requirement path Feb 17, 2017
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit e4f23a3 into swiftlang:master Feb 17, 2017
@DougGregor DougGregor deleted the requirement-source branch February 17, 2017 22:54
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