Perform member lookup on FacetAccessType (#5058)

The name scope lookup and member name lookup both need to handle the
case where the base inst is a FacetAccessType. Then we move from the
FacetAccessType to the FacetType which is the type of the instruction
inside the FacetAccessType.

We do name lookup on FacetType already, so "unwrapping" the
FacetAccessType to the FacetType just makes use of that path. Similarly
we do member access on FacetType already, so we can reuse that codepath
with the FacetType found in the FacetAccessType.
This commit is contained in:
Dana Jansens
2025-03-03 20:17:36 +00:00
committed by GitHub
parent 84b978e40d
commit 2d1bfcac2e
3 changed files with 164 additions and 11 deletions
+13
View File
@@ -248,6 +248,19 @@ auto AppendLookupScopesForConstant(Context& context, SemIR::LocId loc_id,
-> bool {
auto base_id = context.constant_values().GetInstId(base_const_id);
auto base = context.insts().Get(base_id);
if (auto base_as_facet_access_type = base.TryAs<SemIR::FacetAccessType>()) {
// Move from the symbolic facet value up in typish-ness to its FacetType to
// find a lookup scope.
auto facet_type_type_id =
context.insts()
.Get(base_as_facet_access_type->facet_value_inst_id)
.type_id();
base_const_id = context.types().GetConstantId(facet_type_type_id);
base_id = context.constant_values().GetInstId(base_const_id);
base = context.insts().Get(base_id);
}
if (auto base_as_namespace = base.TryAs<SemIR::Namespace>()) {
scopes->push_back(
LookupScope{.name_scope_id = base_as_namespace->name_scope_id,