mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user