AST: Change signature of LookupConformanceFn #81202
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The primitive form of subst() takes a pair of callbacks, to substitute generic parameters and conformances, respectively. We then implement substitution of arbitrary types in terms of these callbacks.
The LookupConformanceFn callback used to take both the original type and the substituted type of the conformance, so to perform a substitution on a dependent member type
T.[P]A
, we would first recursively substituteT
, and then invoke LookupConformanceFn withT
, the substituted type forT
, andP
. This returns a conformance, and we then project the type witness forA
to get the final result.While
LookUpConformanceInModule
needs the substitutedT
for example,LookUpConformanceInSubstitutionMap
does not; it callsSubstitutionMap::lookupConformance()
, which only needs the originalT
and theP
. To avoid this unnecessary bit of computation in the common case where we're calling subst() with a pair of callbacks that look into a substitution map, let's change the callback's signature to receive theInFlightSubstitution &
instead of the substitutedT
. The substituted type can then be recovered by callingsubst(IFS)
on the original typeT
.Also, remove an ancient hack in
SubstitutionMap::lookupConformance()
that is no longer necessary, now that we track subject types in abstract conformances. Previously, if any of the steps in a conformance path were abstract, we would fall back to global conformance lookup here, because we didn't have enough information to proceed. We do now.