Skip to content

Commit 2ee2b2f

Browse files
authored
Move the FacetAccessType special case out of name lookup, and generalize it (#6163)
The `AppendLookupScopesForConstant` function had a special case for `facet as type` which was overly broad (applying to all callers to the function when only one caller needs it), and was confusingly overly specific (applying to `facet as type` but not to `facet` constants). We clarify all of this by moving it out to member access, and applying it only to the case of looking into the type of `base_id`. In that case we are doing member lookup into the facet itself, but since it's symbolic we don't know the type to look into. And we don't defer the lookup with a symbolic instruction, so we do the lookup into the facet's type instead. We add a helper function in member access, `ExtractFacetTypeForFacet` to encapsulate this slightly-odd operation. It's odd because it ends up getting *the type of the type* when the `base_id` has a facet as its type. The helper is now built on top of GetCanonicalFacetOrTypeValue() instead of explicitly looking for FacetAccessType, which makes it work more generally for any type instructions that represent a facet, including SymbolicBindingType in the future. While here document and improve clarity throughout the `PerformActionHelper` for member access.
1 parent fe020ee commit 2ee2b2f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

toolchain/check/impl_lookup.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,9 @@ auto EvalLookupSingleImplWitness(Context& context, SemIR::LocId loc_id,
882882
}
883883
}
884884

885+
// Ensure specifics don't substitute in weird things for the query self.
886+
CARBON_CHECK(context.types().IsFacetType(
887+
context.insts().Get(eval_query.query_self_inst_id).type_id()));
885888
SemIR::ConstantId query_self_const_id =
886889
context.constant_values().Get(eval_query.query_self_inst_id);
887890

0 commit comments

Comments
 (0)