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>
This commit is contained in:
Dana Jansens
2025-03-19 03:59:04 +00:00
committed by GitHub
co-authored by josh11b
parent 1d08b731da
commit 5724407e4d
+8 -1
View File
@@ -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;