mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 18:06:42 +00:00
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: ``` fn F[T: Interface](val: T); ``` 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, with `as type`. The result of that conversion is a FacetAccessType. So the deduction code sees a FacetAccessType for the type of `val`. We make deduction undo the `as type` conversion to move back to the `T` 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. Rebased on top of PR #4885