mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Store an InstId instead of a TypeId in UnboundElementType. (#5260)
This gives a slightly simpler representation for `UnboundElementType`s in eval blocks, and in principle allows us to preserve the spelling of a field's type into the `UnboundElementType` and thereby into a field reference, although as of right now this doesn't affect our diagnostic output in any way. During error recovery for a field with a non-concrete type, preserve the type in the `UnboundElementType` regardless. It's not really problematic to have a non-concrete type there, and this makes it easier to track the instruction used to specify the type. This is a step towards switching symbolic types to always be abstract during type checking.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
#include "toolchain/sem_ir/pattern.h"
|
||||
#include "toolchain/sem_ir/typed_insts.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
@@ -141,11 +142,15 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
|
||||
return context.emitter().Build(type_node, AbstractTypeInFieldDecl,
|
||||
cast_type_id);
|
||||
});
|
||||
if (cast_type_id == SemIR::ErrorInst::SingletonTypeId) {
|
||||
cast_type_inst_id = SemIR::ErrorInst::SingletonInstId;
|
||||
}
|
||||
auto binding_id =
|
||||
context.parse_tree().As<Parse::VarBindingPatternId>(node_id);
|
||||
auto& class_info = context.classes().Get(parent_class_decl->class_id);
|
||||
auto field_type_id =
|
||||
GetUnboundElementType(context, class_info.self_type_id, cast_type_id);
|
||||
auto field_type_id = GetUnboundElementType(
|
||||
context, context.types().GetInstId(class_info.self_type_id),
|
||||
cast_type_inst_id);
|
||||
auto field_id =
|
||||
AddInst<SemIR::FieldDecl>(context, binding_id,
|
||||
{.type_id = field_type_id,
|
||||
|
||||
Reference in New Issue
Block a user