Don't elide Self when dumping the interface/constraint (#6297)

We give `Self` in an interface/constraint a location so it's not elided
when trying to dump the interface/constraint. We use the location of the
start of the definition, which is the scope for which the `Self` is
constructed and is available in.
This commit is contained in:
Dana Jansens
2025-10-30 20:47:16 +00:00
committed by GitHub
parent 656150593c
commit f272198ce5
54 changed files with 481 additions and 478 deletions
+7 -7
View File
@@ -223,19 +223,19 @@ auto GetTypeForSpecificAssociatedEntity(Context& context, SemIR::LocId loc_id,
CARBON_FATAL("Unexpected kind for associated constant {0}", decl);
}
auto AddSelfGenericParameter(Context& context, SemIR::TypeId type_id,
SemIR::NameScopeId scope_id, bool is_template)
-> SemIR::InstId {
auto AddSelfGenericParameter(Context& context, SemIR::LocId definition_loc_id,
SemIR::TypeId type_id, SemIR::NameScopeId scope_id,
bool is_template) -> SemIR::InstId {
auto entity_name_id = context.entity_names().AddSymbolicBindingName(
SemIR::NameId::SelfType, scope_id,
context.scope_stack().AddCompileTimeBinding(), is_template);
// Because there is no equivalent non-symbolic value, we use `None` as
// the `value_id` on the `SymbolicBinding`.
auto self_param_inst_id =
AddInst(context, SemIR::LocIdAndInst::NoLoc<SemIR::SymbolicBinding>(
{.type_id = type_id,
.entity_name_id = entity_name_id,
.value_id = SemIR::InstId::None}));
AddInst<SemIR::SymbolicBinding>(context, definition_loc_id,
{.type_id = type_id,
.entity_name_id = entity_name_id,
.value_id = SemIR::InstId::None});
context.scope_stack().PushCompileTimeBinding(self_param_inst_id);
context.name_scopes().AddRequiredName(scope_id, SemIR::NameId::SelfType,
self_param_inst_id);