mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
If the query facet type has more than one interface, we must find an impl that provides that interface for the query type for each interface. This just looks like a for loop over the interfaces and ensuring we found one impl witness for every one. However the impl matching must change since it can't look at the constant value of the entire query facet type for comparison with the impl, as that query facet type may be for multiple interfaces and we are looking to match an impl of a single interface. To do this we break the query facet type up into each interface and make sure the interface ids match. Then ensure that the impl was able to deduce any generic parameters using the specific of the single query interface. There are some TODOs left here: 1. If the facet type for the query or the impl constraint has "other_requirements" then we can't verify that they match since they are lost. We fall back to comparing the constant id of the query to the impl's constraint (after deducing generics in the impl). This correctly eliminates mismatches but eagerly eliminates impls that could match the query interface as well when there's more than one interface in the query. 2. We don't return a witness for every interface in the query facet type. Since we can't demonstrate any use of the witness there yet, for cases that can have more than one interface in the query facet type, this doesn't break anything that was previously working. The return value is currently treated as a bool for cases with multiple interfaces in the facet type (as a test for "can this be converted") but the converted-to facet value's witnesses are unused. --------- Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>