mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 20:55:01 +01:00
When a function has a generic FacetType parameter, it can depend on other FacetTypes bound as earlier parameters. To deduce the FacetValue, we need to know the impl to attach to it, which requires knowing the full type signature of the generic FacetType parameter. To do this, after deducing other arguments to determine the value of non-generic FacetType parameters, we substitute them sequentially into later symbolic parameters to get their full facet types, then converts the arguments to those full facet types to get the FacetValue. For example: ``` fn F(T: type, U: Interface(T)); ``` Here the `T` binding is deduced to the be the caller's argument type. But the Interface(T) can not be properly deduced to a FacetValue in the first pass, and it will just be the caller's argument type directly. After the first deduce pass, we will substitute the deduced T binding into Interface(T), at which point the argument type can and will be converted to a matching FacetValue as long as an impl can be found. Closes #4868 This is based on PRs #4881 and #4863 --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>