Move TypeCompleter and closely related helper functions to their own file (#4922)

context.cpp is getting large, so I'm looking at a few ways to cut out
clusters of functions. This felt like a logical cluster of functions to
move to their own file.

Note I have two commits in this PR: one moving the functionality to a
new file, and one specifically changing TypeCompleter to use out-of-line
function implementations. This is to assist reviewability.
This commit is contained in:
Jon Ross-Perkins
2025-02-11 18:51:46 +00:00
committed by GitHub
parent 2fef1cb713
commit 0a55081c5d
14 changed files with 746 additions and 627 deletions
+11 -9
View File
@@ -12,6 +12,7 @@
#include "toolchain/check/generic.h"
#include "toolchain/check/import_ref.h"
#include "toolchain/check/interface.h"
#include "toolchain/check/type_completion.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/sem_ir/generic.h"
#include "toolchain/sem_ir/ids.h"
@@ -107,15 +108,16 @@ auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl)
context.interfaces().Get(interface_type->interface_id);
// TODO: This should be done as part of facet type resolution.
if (!context.RequireDefinedType(
facet_type_id, context.insts().GetLocId(impl.latest_decl_id()), [&] {
CARBON_DIAGNOSTIC(ImplOfUndefinedInterface, Error,
"implementation of undefined interface {0}",
SemIR::NameId);
return context.emitter().Build(impl.latest_decl_id(),
ImplOfUndefinedInterface,
interface.name_id);
})) {
if (!RequireDefinedType(context, facet_type_id,
context.insts().GetLocId(impl.latest_decl_id()), [&] {
CARBON_DIAGNOSTIC(
ImplOfUndefinedInterface, Error,
"implementation of undefined interface {0}",
SemIR::NameId);
return context.emitter().Build(
impl.latest_decl_id(), ImplOfUndefinedInterface,
interface.name_id);
})) {
return SemIR::ErrorInst::SingletonInstId;
}