When reentering an interface scope, reintroduce the Self parameter. (#4162)

This is not easy to test right now, because it should only really be
visible through `default fn` declarations, which we don't support
properly yet.
This commit is contained in:
Richard Smith
2024-07-24 22:31:24 +00:00
committed by GitHub
parent 07bad72d86
commit a0973f4f47
4 changed files with 203 additions and 44 deletions
+9
View File
@@ -213,6 +213,15 @@ static auto PushNameQualifierScope(Context& context,
context.scope_stack().Push(scope_inst_id, scope_id, instance_id, has_error);
// An interface also introduces its 'Self' parameter into scope, despite it
// not being redeclared as part of the qualifier.
if (auto interface_decl =
context.insts().TryGetAs<SemIR::InterfaceDecl>(scope_inst_id)) {
auto& interface = context.interfaces().Get(interface_decl->interface_id);
context.scope_stack().AddCompileTimeBinding();
context.scope_stack().PushCompileTimeBinding(interface.self_param_id);
}
// Enter a parameter scope in case the qualified name itself has parameters.
context.scope_stack().Push();
}