mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:40:10 +01:00
Support importing associated constant declarations (#4794)
Co-authored-by: Josh L <josh11b@users.noreply.github.com>
This commit is contained in:
@@ -1336,6 +1336,28 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
|
||||
.element_type_id = element_type_id});
|
||||
}
|
||||
|
||||
static auto TryResolveTypedInst(ImportRefResolver& resolver,
|
||||
SemIR::AssociatedConstantDecl inst,
|
||||
SemIR::InstId import_inst_id) -> ResolveResult {
|
||||
auto type_const_id = GetLocalConstantId(resolver, inst.type_id);
|
||||
if (resolver.HasNewWork()) {
|
||||
return ResolveResult::Retry();
|
||||
}
|
||||
|
||||
auto type_id =
|
||||
resolver.local_context().GetTypeIdForTypeConstant(type_const_id);
|
||||
|
||||
// Create a corresponding instruction to represent the declaration.
|
||||
auto inst_id = resolver.local_context().AddInstInNoBlock(
|
||||
resolver.local_context()
|
||||
.MakeImportedLocAndInst<SemIR::AssociatedConstantDecl>(
|
||||
AddImportIRInst(resolver, import_inst_id),
|
||||
{.type_id = type_id,
|
||||
.name_id = GetLocalNameId(resolver, inst.name_id)}));
|
||||
return ResolveResult::Done(resolver.local_constant_values().Get(inst_id),
|
||||
inst_id);
|
||||
}
|
||||
|
||||
static auto TryResolveTypedInst(ImportRefResolver& resolver,
|
||||
SemIR::AssociatedEntity inst) -> ResolveResult {
|
||||
auto type_const_id = GetLocalConstantId(resolver, inst.type_id);
|
||||
@@ -2574,6 +2596,9 @@ static auto TryResolveInstCanonical(ImportRefResolver& resolver,
|
||||
case CARBON_KIND(SemIR::ArrayType inst): {
|
||||
return TryResolveTypedInst(resolver, inst);
|
||||
}
|
||||
case CARBON_KIND(SemIR::AssociatedConstantDecl inst): {
|
||||
return TryResolveTypedInst(resolver, inst, inst_id);
|
||||
}
|
||||
case CARBON_KIND(SemIR::AssociatedEntity inst): {
|
||||
return TryResolveTypedInst(resolver, inst);
|
||||
}
|
||||
|
||||
+1216
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user