mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 20:25:55 +01:00
When the parameter is a deduced symbolic FacetValue, refering to a BindSymbolicName, and the argument is a concrete FacetValue that would match the FacetType requirements on the BindSymbolicName's type, we currently do not deduce that the argument matches the parameter. The argument is not _converted_ to the parameter type because they are both FacetValues of the same FacetType type. However they are also not equal constant values so the argument is not saved as a deduced match for the parameter. In order to accept the FacetValue, we need to consider them as `deduce_through`, which attempts to deduce each of the fields in the argument FacetValue against the fields in the parameter FacetValue. This deduces that the argument's concrete type matches the symbolic BindSymbolicName and its witnesses are the same. Since the parameter is a FacetValue, its argument is not the type that needs to be recorded as the deduced type for the binding. The BindSymbolicName inside the parameter is the place that we need to find the deduced type for the binding. So simply walking into the FacetValue gets us to that position, where we eventually record the deduced argument type as being the concrete type from the original argument FacetValue. Similarly, when determining what interfaces are satisfied by a FacetValue for deduce, we want to use the full type available in the FacetValue rather than just those from its FacetType. Determining availability of interfaces here is equivalent to converting, and we want converting a FacetValue to always work on the full available type info. Only API access (member lookup) is restricted by a FacetValue to the interfaces provided by its FacetType type. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>