Add form to Function (#6561)

... and use the form to implement support for `ref` returns.
This commit is contained in:
Geoff Romer
2026-01-08 18:55:53 +00:00
committed by GitHub
parent 28b01118d0
commit 11d407b4a0
24 changed files with 1554 additions and 1319 deletions
+11
View File
@@ -140,4 +140,15 @@ auto Function::GetDeclaredReturnType(const File& file,
GetConstantValueInSpecific(file, specific_id, return_type_inst_id));
}
auto Function::GetDeclaredReturnForm(const File& file,
SpecificId specific_id) const -> InstId {
if (!return_form_inst_id.has_value()) {
// Treat as equivalent to `-> ()`.
return InstId::None;
}
auto return_form_constant_id =
GetConstantValueInSpecific(file, specific_id, return_form_inst_id);
return file.constant_values().GetInstId(return_form_constant_id);
}
} // namespace Carbon::SemIR