Restructure ArgAndKind as a type-safe generic ID. (#7172)

The key changes here are:
- Relocating and renaming it to align with `IdKind` (and relocating
`ToRaw` and `FromRaw` to follow it).
- Adding a `Dispatch` method that provides a generic overload-based API
for expressing per-ID-kind dispatch, and rewriting existing code to use
it.

Note in particular that using overloads instead of switch cases makes it
possible to generically handle all specializations of a templated ID
type, e.g. `SomeIdType<T>` for all `T`. We have no such templated ID
types yet, but I'm introducing one in a follow-up PR that needs this
capability.
This commit is contained in:
Geoff Romer
2026-05-07 00:13:52 +00:00
committed by GitHub
parent db24042fe5
commit daebbf32fa
10 changed files with 236 additions and 218 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ class DeductionWorklist {
}
// Adds a (param, arg) pair for an instruction argument, given its kind.
auto AddInstArg(SemIR::Inst::ArgAndKind param, int32_t arg) -> void {
auto AddInstArg(SemIR::IdAndKind param, int32_t arg) -> void {
CARBON_KIND_SWITCH(param) {
case SemIR::IdKind::None:
case SemIR::IdKind::For<SemIR::ClassId>: