mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
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:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "common/find.h"
|
||||
#include "toolchain/check/merge.h"
|
||||
#include "toolchain/check/type.h"
|
||||
#include "toolchain/check/type_completion.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/pattern.h"
|
||||
@@ -93,8 +94,7 @@ auto CheckFunctionTypeMatches(Context& context,
|
||||
|
||||
auto CheckFunctionReturnType(Context& context, SemIR::LocId loc_id,
|
||||
const SemIR::Function& function,
|
||||
SemIR::SpecificId specific_id)
|
||||
-> SemIR::ReturnTypeInfo {
|
||||
SemIR::SpecificId specific_id) -> SemIR::TypeId {
|
||||
auto return_info = SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(),
|
||||
function, specific_id);
|
||||
|
||||
@@ -125,7 +125,14 @@ auto CheckFunctionReturnType(Context& context, SemIR::LocId loc_id,
|
||||
}
|
||||
}
|
||||
|
||||
return return_info;
|
||||
if (return_info.init_repr.kind == SemIR::InitRepr::Incomplete ||
|
||||
return_info.init_repr.kind == SemIR::InitRepr::Abstract) {
|
||||
return SemIR::ErrorInst::TypeId;
|
||||
}
|
||||
if (!return_info.type_id.has_value()) {
|
||||
return GetTupleType(context, {});
|
||||
}
|
||||
return return_info.type_id;
|
||||
}
|
||||
|
||||
auto CheckFunctionDefinitionSignature(Context& context,
|
||||
|
||||
Reference in New Issue
Block a user