Support for calling non-generic methods in a specific class. (#4156)

Use the specific parameter types for checking, and the specific return
type as the type of the call.
This commit is contained in:
Richard Smith
2024-07-24 20:27:01 +00:00
committed by GitHub
parent 7ded56ef35
commit 07bad72d86
54 changed files with 1469 additions and 436 deletions
+3 -3
View File
@@ -58,7 +58,7 @@ auto CheckReturnedVar(Context& context, Parse::NodeId returned_node,
-> SemIR::InstId {
// A `returned var` requires an explicit return type.
auto& function = GetCurrentFunction(context);
auto return_type_id = function.declared_return_type(context.sem_ir());
auto return_type_id = function.GetDeclaredReturnType(context.sem_ir());
if (!return_type_id.is_valid()) {
CARBON_DIAGNOSTIC(ReturnedVarWithNoReturnType, Error,
"Cannot declare a `returned var` in this function.");
@@ -106,7 +106,7 @@ auto RegisterReturnedVar(Context& context, SemIR::InstId bind_id) -> void {
auto BuildReturnWithNoExpr(Context& context, Parse::ReturnStatementId node_id)
-> void {
const auto& function = GetCurrentFunction(context);
auto return_type_id = function.declared_return_type(context.sem_ir());
auto return_type_id = function.GetDeclaredReturnType(context.sem_ir());
if (return_type_id.is_valid()) {
CARBON_DIAGNOSTIC(ReturnStatementMissingExpr, Error,
@@ -124,7 +124,7 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id,
const auto& function = GetCurrentFunction(context);
auto returned_var_id = GetCurrentReturnedVar(context);
auto return_slot_id = SemIR::InstId::Invalid;
auto return_type_id = function.declared_return_type(context.sem_ir());
auto return_type_id = function.GetDeclaredReturnType(context.sem_ir());
if (!return_type_id.is_valid()) {
CARBON_DIAGNOSTIC(