mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Generate thunks for functions in impls (#5390)
Generate a thunk when a function in an `impl` has a different signature than the function in the interface. This follows the design in [#3763](https://docs.carbon-lang.dev/proposals/p3763.html#impl-members-vs-interface-members), although some of the checks described there are not yet implemented. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
4f5d11a28b
commit
95903dc624
@@ -70,23 +70,16 @@ auto Function::GetParamPatternInfoFromPatternId(const File& sem_ir,
|
||||
auto inst_id = pattern_id;
|
||||
auto inst = sem_ir.insts().Get(inst_id);
|
||||
|
||||
if (auto addr_pattern = inst.TryAs<AddrPattern>()) {
|
||||
inst_id = addr_pattern->inner_id;
|
||||
inst = sem_ir.insts().Get(inst_id);
|
||||
}
|
||||
|
||||
auto param_pattern_inst = inst.TryAs<AnyParamPattern>();
|
||||
if (!param_pattern_inst) {
|
||||
sem_ir.insts().TryUnwrap(inst, inst_id, &AddrPattern::inner_id);
|
||||
auto [param_pattern, param_pattern_id] =
|
||||
sem_ir.insts().TryUnwrap(inst, inst_id, &AnyParamPattern::subpattern_id);
|
||||
if (!param_pattern) {
|
||||
return std::nullopt;
|
||||
}
|
||||
auto param_pattern_id = inst_id;
|
||||
|
||||
inst_id = param_pattern_inst->subpattern_id;
|
||||
inst = sem_ir.insts().Get(inst_id);
|
||||
|
||||
auto binding_pattern = inst.As<AnyBindingPattern>();
|
||||
return {{.inst_id = param_pattern_id,
|
||||
.inst = *param_pattern_inst,
|
||||
.inst = *param_pattern,
|
||||
.entity_name_id = binding_pattern.entity_name_id}};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user