mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:41:04 +01:00
Add 'let' handling for ImportRefUsed. (#3700)
- File::StringifyTypeExpr now has a case that hits the ImportRefUsed TODO, so implementing that. I think the `static` approach will be helpful in ensuring there aren't access bugs, particularly when future support is added. - `let` wasn't adding to exports because it doesn't use `decl_name_stack` the way `var` does. This now adds to exports, but we might want to unify logic for issues such as this. - BuildImportRefUsedValueRepr is now called for another inst kind, and it seemed like calling back to BuildValueRepr was the best way to resolve this. I don't *think* that's going to cause recursion.
This commit is contained in:
+14
-12
@@ -712,17 +712,9 @@ class TypeCompleter {
|
||||
return value_rep;
|
||||
};
|
||||
|
||||
auto BuildImportRefUsedValueRepr(SemIR::TypeId type_id,
|
||||
SemIR::ImportRefUsed import_ref) const
|
||||
-> SemIR::ValueRepr {
|
||||
CARBON_CHECK(import_ref.inst_id.is_builtin())
|
||||
<< "TODO: Handle non-builtin ImportRefUsed cases, such as functions, "
|
||||
"classes, and interfaces";
|
||||
|
||||
const auto& import_ir = context_.import_irs().Get(import_ref.ir_id);
|
||||
auto import_inst = import_ir->insts().Get(import_ref.inst_id);
|
||||
|
||||
switch (import_inst.As<SemIR::Builtin>().builtin_kind) {
|
||||
auto BuildBuiltinValueRepr(SemIR::TypeId type_id,
|
||||
SemIR::Builtin builtin) const -> SemIR::ValueRepr {
|
||||
switch (builtin.builtin_kind) {
|
||||
case SemIR::BuiltinKind::TypeType:
|
||||
case SemIR::BuiltinKind::Error:
|
||||
case SemIR::BuiltinKind::Invalid:
|
||||
@@ -743,6 +735,16 @@ class TypeCompleter {
|
||||
llvm_unreachable("All builtin kinds were handled above");
|
||||
}
|
||||
|
||||
auto BuildImportRefUsedValueRepr(SemIR::TypeId type_id,
|
||||
SemIR::ImportRefUsed import_ref) const
|
||||
-> SemIR::ValueRepr {
|
||||
const auto& import_ir = context_.import_irs().Get(import_ref.ir_id);
|
||||
auto import_inst = import_ir->insts().Get(import_ref.inst_id);
|
||||
CARBON_CHECK(import_inst.kind() != SemIR::InstKind::ImportRefUsed)
|
||||
<< "If ImportRefUsed can point at another, this would be recursive.";
|
||||
return BuildValueRepr(type_id, import_inst);
|
||||
}
|
||||
|
||||
auto BuildStructOrTupleValueRepr(std::size_t num_elements,
|
||||
SemIR::TypeId elementwise_rep,
|
||||
bool same_as_object_rep) const
|
||||
@@ -928,7 +930,7 @@ class TypeCompleter {
|
||||
return MakeEmptyValueRepr();
|
||||
|
||||
case SemIR::Builtin::Kind:
|
||||
CARBON_FATAL() << "Builtins should be named as ImportRefUsed";
|
||||
return BuildBuiltinValueRepr(type_id, inst.As<SemIR::Builtin>());
|
||||
|
||||
case SemIR::BindSymbolicName::Kind:
|
||||
case SemIR::PointerType::Kind:
|
||||
|
||||
Reference in New Issue
Block a user