Przeglądaj źródła

Delete the GetConstantValue overload for AbsoluteInstId (#5145)

This prevents conversion from an InstId which is its base class, and
documents that this is invalid in the code.

Also expand the comment on the AbsoluteInstBlockId, which I had locally
but seem to have not saved and included in #5141.

---------

Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
Dana Jansens 1 rok temu
rodzic
commit
5724407e4d
1 zmienionych plików z 8 dodań i 1 usunięć
  1. 8 1
      toolchain/check/eval.cpp

+ 8 - 1
toolchain/check/eval.cpp

@@ -348,6 +348,12 @@ static auto MakeFacetTypeResult(Context& context,
 // with constant phase, and if so, returns the corresponding constant value.
 // Overloads are provided for different kinds of ID.
 
+// AbsoluteInstId can not have its values substituted, so this overload is
+// deleted. This prevents conversion to InstId.
+static auto GetConstantValue(EvalContext& eval_context,
+                             SemIR::AbsoluteInstId inst_id, Phase* phase)
+    -> SemIR::InstId = delete;
+
 // If the given instruction is constant, returns its constant value.
 static auto GetConstantValue(EvalContext& eval_context, SemIR::InstId inst_id,
                              Phase* phase) -> SemIR::InstId {
@@ -375,7 +381,8 @@ static auto GetConstantValue(EvalContext& eval_context, SemIR::TypeId type_id,
   return eval_context.context().types().GetTypeIdForTypeConstantId(const_id);
 }
 
-// AbsoluteInstBlockId can not have its values substituted.
+// AbsoluteInstBlockId can not have its values substituted, so this overload is
+// deleted. This prevents conversion to InstBlockId.
 static auto GetConstantValue(EvalContext& eval_context,
                              SemIR::AbsoluteInstBlockId inst_block_id,
                              Phase* phase) -> SemIR::InstBlockId = delete;