mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:41:04 +01:00
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:
@@ -277,18 +277,8 @@ static auto BuildFunctionDecl(Context& context,
|
||||
FinishGenericRedecl(context, decl_id, function_info.generic_id);
|
||||
// TODO: Validate that the redeclaration doesn't set an access modifier.
|
||||
}
|
||||
function_decl.type_id = context.GetFunctionType(function_decl.function_id);
|
||||
|
||||
// TODO: Temporarily replace the return type with the canonical return type.
|
||||
// This is a placeholder to avoid breaking tests before generic type
|
||||
// substitution is ready.
|
||||
if (return_storage_id.is_valid()) {
|
||||
auto return_storage = context.insts().Get(return_storage_id);
|
||||
return_storage.SetType(SemIR::GetTypeInInstance(
|
||||
context.sem_ir(), SemIR::GenericInstanceId::Invalid,
|
||||
return_storage.type_id()));
|
||||
context.sem_ir().insts().Set(return_storage_id, return_storage);
|
||||
}
|
||||
function_decl.type_id = context.GetFunctionType(
|
||||
function_decl.function_id, context.scope_stack().PeekSpecificId());
|
||||
|
||||
// Write the function ID into the FunctionDecl.
|
||||
context.ReplaceInstBeforeConstantUse(decl_id, function_decl);
|
||||
@@ -312,7 +302,7 @@ static auto BuildFunctionDecl(Context& context,
|
||||
}
|
||||
|
||||
if (SemIR::IsEntryPoint(context.sem_ir(), function_decl.function_id)) {
|
||||
auto return_type_id = function_info.declared_return_type(context.sem_ir());
|
||||
auto return_type_id = function_info.GetDeclaredReturnType(context.sem_ir());
|
||||
// TODO: Update this once valid signatures for the entry point are decided.
|
||||
if (function_info.implicit_param_refs_id.is_valid() ||
|
||||
!function_info.param_refs_id.is_valid() ||
|
||||
@@ -357,7 +347,8 @@ static auto HandleFunctionDefinitionAfterSignature(
|
||||
context.AddCurrentCodeBlockToFunction();
|
||||
|
||||
// Check the return type is complete.
|
||||
CheckFunctionReturnType(context, function.return_storage_id, function);
|
||||
CheckFunctionReturnType(context, function.return_storage_id, function,
|
||||
SemIR::GenericInstanceId::Invalid);
|
||||
|
||||
// Check the parameter types are complete.
|
||||
for (auto param_id : llvm::concat<const SemIR::InstId>(
|
||||
@@ -497,7 +488,7 @@ static auto IsValidBuiltinDeclaration(Context& context,
|
||||
}
|
||||
|
||||
// Get the return type. This is `()` if none was specified.
|
||||
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()) {
|
||||
return_type_id = context.GetTupleType({});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user