Implement ...where .Self impls... (#5238)

* Also remove facet type deduction, since we decided against it on
[2025-04-02](https://docs.google.com/document/d/1Iut5f2TQBrtBNIduF4vJYOKfw7MbS8xH_J01_Q4e6Rk/edit?pli=1&resourcekey=0-mc_vh5UzrzXfU4kO-3tOjA&tab=t.0#heading=h.95phmuvxog9n).

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
josh11b
2025-04-07 20:45:45 +00:00
committed by GitHub
co-authored by Josh L Dana Jansens
parent 87f0e9723f
commit 4af0c8f8d1
27 changed files with 1409 additions and 399 deletions
+4 -10
View File
@@ -306,19 +306,13 @@ static auto LookupMemberNameInScope(Context& context, SemIR::LocId loc_id,
// First look for `assoc_interface` in the type of the base. If it is
// found, get the witness that the interface is implemented from
// `base_id`.
const auto& facet_type_info =
context.facet_types().Get(facet_type->facet_type_id);
auto identified_id = RequireIdentifiedFacetType(context, *facet_type);
const auto& identified =
context.identified_facet_types().Get(identified_id);
// Witness that `T` implements the `assoc_interface`.
SemIR::InstId witness_inst_id = SemIR::InstId::None;
// TODO: This assumes `impls_constraints` are in the same order as
// `CompleteFacetType::required_interfaces`, and come first in the list.
// Once we add support for named constraints there may be more
// interfaces in the `CompleteFacetType`, and we will require those
// additional interfaces in the `CompleteFacetType` to come after the
// ones we see in `impls_constraints` in order to not invalidate the
// index computed here.
for (auto [index, base_interface] :
llvm::enumerate(facet_type_info.impls_constraints)) {
llvm::enumerate(identified.required_interfaces())) {
// Get the witness that `T` implements `base_type_id`.
if (base_interface == assoc_interface) {
witness_inst_id = GetOrAddInst(