Use Get*Type in a couple spots (#5257)

These seemed like spots that didn't need to call `TryEvalInst` directly.
I'm relying on tests for coverage. :)
This commit is contained in:
Jon Ross-Perkins
2025-04-07 22:41:27 +00:00
committed by GitHub
parent 4af0c8f8d1
commit 1ffd56ac3e
3 changed files with 5 additions and 14 deletions
+2 -5
View File
@@ -104,11 +104,8 @@ auto HandleParseNode(Context& context, Parse::ChoiceDefinitionStartId node_id)
// `Class` in the ValueStore.
SemIR::Class& mut_class = context.classes().Get(class_decl.class_id);
// Build the `Self` type using the resulting type constant.
auto self_type_id = context.types().GetTypeIdForTypeConstantId(
TryEvalInst(context, SemIR::InstId::None,
SemIR::ClassType{.type_id = SemIR::TypeType::SingletonTypeId,
.class_id = class_decl.class_id,
.specific_id = self_specific_id}));
auto self_type_id =
GetClassType(context, class_decl.class_id, self_specific_id);
mut_class.self_type_id = self_type_id;
// Enter the choice scope.
+1 -5
View File
@@ -267,11 +267,7 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId node_id,
auto specific_id =
context.generics().GetSelfSpecific(class_info.generic_id);
class_info.self_type_id =
context.types().GetTypeIdForTypeConstantId(TryEvalInst(
context, SemIR::InstId::None,
SemIR::ClassType{.type_id = SemIR::TypeType::SingletonTypeId,
.class_id = class_decl.class_id,
.specific_id = specific_id}));
GetClassType(context, class_decl.class_id, specific_id);
}
if (!is_definition && context.sem_ir().is_impl() && !is_extern) {
+2 -4
View File
@@ -171,10 +171,8 @@ auto HandleParseNode(Context& context,
context.args_type_info_stack().Push();
// Declare and introduce `Self`.
SemIR::FacetType facet_type =
FacetTypeFromInterface(context, interface_id, self_specific_id);
SemIR::TypeId self_type_id = context.types().GetTypeIdForTypeConstantId(
TryEvalInst(context, SemIR::InstId::None, facet_type));
SemIR::TypeId self_type_id =
GetInterfaceType(context, interface_id, self_specific_id);
// We model `Self` as a symbolic binding whose type is the interface.
// Because there is no equivalent non-symbolic value, we use `None` as