Remove SelfParam, add an AddrPattern instead. (#3506)

This is intended to make the representation of a `self` pattern be more
similar to other patterns.
This commit is contained in:
Richard Smith
2023-12-14 20:53:51 +00:00
committed by GitHub
parent de0c02ddae
commit fbb4ecf319
22 changed files with 152 additions and 101 deletions
+7 -3
View File
@@ -241,6 +241,13 @@ auto HandleFunctionDefinitionStart(Context& context, Parse::NodeId parse_node)
context.inst_blocks().Get(function.param_refs_id))) {
auto param = context.insts().Get(param_id);
// Find the parameter in the pattern.
// TODO: More general pattern handling?
if (auto addr_pattern = param.TryAs<SemIR::AddrPattern>()) {
param_id = addr_pattern->inner_id;
param = context.insts().Get(param_id);
}
// The parameter types need to be complete.
context.TryToCompleteType(param.type_id(), [&] {
CARBON_DIAGNOSTIC(
@@ -255,9 +262,6 @@ auto HandleFunctionDefinitionStart(Context& context, Parse::NodeId parse_node)
if (auto fn_param = param.TryAs<SemIR::Param>()) {
context.AddNameToLookup(fn_param->parse_node, fn_param->name_id,
param_id);
} else if (auto self_param = param.TryAs<SemIR::SelfParam>()) {
context.AddNameToLookup(self_param->parse_node, SemIR::NameId::SelfValue,
param_id);
} else {
CARBON_FATAL() << "Unexpected kind of parameter in function definition "
<< param;