Decouple PerformCallToFunction from ReturnTypeInfo (#6572)

`ReturnTypeInfo` is built around the assumption that a function call
results in exactly one initializing expression, but with `ref` returns
there may be zero, and in the future composite return forms will enable
there to be more than one. This change removes some usages of
`ReturnTypeInfo`, and restructures the calling code to be prepared for
multiple initializing returns.
This commit is contained in:
Geoff Romer
2026-01-09 23:04:54 +00:00
committed by GitHub
parent 9727c628c4
commit 87b4ca54e6
8 changed files with 65 additions and 55 deletions
+11 -6
View File
@@ -629,17 +629,22 @@ auto CallerPatternMatch(Context& context, SemIR::SpecificId specific_id,
SemIR::InstBlockId return_patterns_id,
SemIR::InstId self_arg_id,
llvm::ArrayRef<SemIR::InstId> arg_refs,
SemIR::InstId return_slot_arg_id,
llvm::ArrayRef<SemIR::InstId> return_arg_ids,
bool is_operator_syntax) -> SemIR::InstBlockId {
MatchContext match(MatchKind::Caller, specific_id);
auto return_patterns = context.inst_blocks().GetOrEmpty(return_patterns_id);
// Track the return storage, if present.
if (return_slot_arg_id.has_value()) {
CARBON_CHECK(return_patterns.size() == 1,
"TODO: implement support for multiple return patterns");
match.AddWork(
{.pattern_id = return_patterns[0], .scrutinee_id = return_slot_arg_id});
for (auto [return_pattern_id, return_arg_id] :
llvm::zip_equal(return_patterns, return_arg_ids)) {
if (return_arg_id.has_value()) {
match.AddWork(
{.pattern_id = return_pattern_id, .scrutinee_id = return_arg_id});
} else {
CARBON_CHECK(return_arg_ids.size() == 1,
"TODO: do the match even if return_arg_id is None, so that "
"subsequent args are at the right index in the arg block");
}
}
// Check type conversions per-element.