Simplify interface for getting an instruction from a type. (#3455)

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2023-12-08 21:50:33 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 5897e57c21
commit cef7eb5522
14 changed files with 211 additions and 172 deletions
+3 -7
View File
@@ -144,9 +144,8 @@ auto HandleClassDefinitionStart(Context& context, Parse::NodeId parse_node)
context.PushScope(class_decl_id, class_info.scope_id);
// Introduce `Self`.
context.AddNameToLookup(
parse_node, SemIR::NameId::SelfType,
context.sem_ir().GetTypeAllowBuiltinTypes(class_info.self_type_id));
context.AddNameToLookup(parse_node, SemIR::NameId::SelfType,
context.types().GetInstId(class_info.self_type_id));
context.inst_block_stack().Push();
context.node_stack().Push(parse_node, class_id);
@@ -227,10 +226,7 @@ auto HandleBaseDecl(Context& context, Parse::NodeId parse_node) -> bool {
// declaration as being final classes.
// TODO: Once we have a better idea of which types are considered to be
// classes, produce a better diagnostic for deriving from a non-class type.
auto base_class =
context.insts()
.Get(context.sem_ir().GetTypeAllowBuiltinTypes(base_type_id))
.TryAs<SemIR::ClassType>();
auto base_class = context.types().TryGetAs<SemIR::ClassType>(base_type_id);
if (!base_class ||
context.classes().Get(base_class->class_id).inheritance_kind ==
SemIR::Class::Final) {