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
+1 -4
View File
@@ -102,11 +102,8 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
SemIR::ClassElementAccess inst) -> void {
// Find the class that we're performing access into.
auto class_type_id = context.sem_ir().insts().Get(inst.base_id).type_id();
auto class_type =
context.sem_ir().types().GetAs<SemIR::ClassType>(class_type_id);
const auto& class_info = context.sem_ir().classes().Get(class_type.class_id);
SemIR::TypeId object_repr_id =
class_info.GetObjectRepr(context.sem_ir(), class_type.specific_id);
context.sem_ir().types().GetObjectRepr(class_type_id);
// Translate the class field access into a struct access on the object
// representation.