Przeglądaj źródła

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. :)
Jon Ross-Perkins 1 rok temu
rodzic
commit
1ffd56ac3e

+ 2 - 5
toolchain/check/handle_choice.cpp

@@ -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
toolchain/check/handle_class.cpp

@@ -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
toolchain/check/handle_interface.cpp

@@ -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