Add ExternDecl and ExternType for extern classes. (#3893)

This expands `extern` handling for most cases.
This commit is contained in:
Jon Ross-Perkins
2024-04-22 15:04:16 +00:00
committed by GitHub
parent 459c41ab3c
commit 5694dd152e
18 changed files with 332 additions and 308 deletions
+10
View File
@@ -897,6 +897,15 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst)
return RebuildIfFieldsAreConstant(context, inst,
&SemIR::BoundMethod::object_id,
&SemIR::BoundMethod::function_id);
case CARBON_KIND(SemIR::ExternDecl extern_decl): {
// Return an extern form of the declaration's constant value.
auto non_extern_type_id = context.GetTypeIdForTypeConstant(
context.constant_values().Get(extern_decl.decl_id));
return MakeConstantResult(
context,
SemIR::ExternType{SemIR::TypeId::TypeType, non_extern_type_id},
Phase::Template);
}
case SemIR::InterfaceWitness::Kind:
return RebuildIfFieldsAreConstant(context, inst,
&SemIR::InterfaceWitness::elements_id);
@@ -975,6 +984,7 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst)
}
case SemIR::ClassType::Kind:
case SemIR::ExternType::Kind:
case SemIR::InterfaceType::Kind:
CARBON_FATAL() << inst.kind()
<< " is only created during corresponding Decl handling.";