Deduce facet values for arguments to generic fns receiving a facet type #4865
+861
−12
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 fn receiving a facet type needs to deduce a type from a FacetAccessType, which is the SemIR type representing the parameter type that is a generic parameter. For example:
Here T is a generic parameter that is a facet value, but the
val
parameter's type is the facet value converted from a FacetType to a TypeType, withas type
. The result of that conversion is a FacetAccessType. So the deduction code sees a FacetAccessType for the type ofval
.We make deduction undo the
as type
conversion to move back to theT
parameter declaration, which has type FacetType in order to deduce the required facet value (which is itself a type constrained by the FacetType). And when we have a facet value (of type FacetType) to be deduced, we will also convert the argument if it is of an appropriate type to a FacetValue that matches the FacetType using the changes from PR #4863.Tests with
impl forall
can cause impl deduction to recurse forever and crash, so those tests are omitted in this PR and they will come in follow-up work that address the infinite recursion.This PR is written on top of #4863.