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
+5 -5
View File
@@ -219,7 +219,7 @@ class Derived {
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
// CHECK:STDOUT: %Modifiers.ref: <namespace> = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers]
// CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%import_ref.1 [template = constants.%Base]
// CHECK:STDOUT: %.loc8: %.5 = base_decl %Base, element0 [template]
// CHECK:STDOUT: %.loc8: %.5 = base_decl %Base.ref, element0 [template]
// CHECK:STDOUT: %.loc9: <witness> = complete_type_witness %.6 [template = constants.%.7]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
@@ -336,7 +336,7 @@ class Derived {
// CHECK:STDOUT:
// CHECK:STDOUT: class @A2 {
// CHECK:STDOUT: %A1.ref: type = name_ref A1, file.%A1.decl [template = constants.%A1]
// CHECK:STDOUT: %.loc9: %.5 = base_decl %A1, element0 [template]
// CHECK:STDOUT: %.loc9: %.5 = base_decl %A1.ref, element0 [template]
// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
// CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.6 [template = constants.%.7]
// CHECK:STDOUT:
@@ -405,7 +405,7 @@ class Derived {
// CHECK:STDOUT:
// CHECK:STDOUT: class @B2 {
// CHECK:STDOUT: %B1.ref: type = name_ref B1, file.%B1.decl [template = constants.%B1]
// CHECK:STDOUT: %.loc9: %.5 = base_decl %B1, element0 [template]
// CHECK:STDOUT: %.loc9: %.5 = base_decl %B1.ref, element0 [template]
// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
// CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.6 [template = constants.%.7]
// CHECK:STDOUT:
@@ -418,7 +418,7 @@ class Derived {
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: %B2.ref: type = name_ref B2, file.%B2.decl [template = constants.%B2]
// CHECK:STDOUT: %.loc14: %.10 = base_decl %B2, element0 [template]
// CHECK:STDOUT: %.loc14: %.10 = base_decl %B2.ref, element0 [template]
// CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.3 [template = constants.%F.3] {} {}
// CHECK:STDOUT: %.loc16: <witness> = complete_type_witness %.11 [template = constants.%.12]
// CHECK:STDOUT:
@@ -660,7 +660,7 @@ class Derived {
// CHECK:STDOUT:
// CHECK:STDOUT: class @Derived {
// CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
// CHECK:STDOUT: %.loc8: %.4 = base_decl %Base, element1 [template]
// CHECK:STDOUT: %.loc8: %.4 = base_decl %Base.ref, element1 [template]
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
// CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %.6 [template = constants.%.7]
// CHECK:STDOUT: