Track the type as written in BaseDecl and AdaptDecl. (#4564)

Represent the type as an `InstId` rather than as a `TypeId` to preserve
how it was written and better support tracking its value in a generic.
Add accessors to `Class` to get the base and adapted type to reduce code
duplication, and add `TypeStore::GetObjectRepr` to make it easier to map
from a type to its possibly-adapted object representation type. In
passing, also move `GetIntTypeInfo` and `GetUnqualifiedType` into
`TypeStore`.

This fixes specifics of generic adapters to properly look at the
specific adapted type, and also fixes importing of adapters.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2024-11-27 22:26:30 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent e0db74a2a1
commit d6ec885eb3
51 changed files with 1530 additions and 415 deletions
+2 -2
View File
@@ -23,8 +23,8 @@ auto PerformPointerDereference(
//
// to convert to a pointer value.
base_id = ConvertToValueExpr(context, base_id);
auto type_id =
context.GetUnqualifiedType(context.insts().Get(base_id).type_id());
auto type_id = context.types().GetUnqualifiedType(
context.insts().Get(base_id).type_id());
auto result_type_id = SemIR::TypeId::Error;
if (auto pointer_type =
context.types().TryGetAs<SemIR::PointerType>(type_id)) {