Use the correct type for Self in generic classes and generic interfaces (#4087)

In a `class C(T:! type)`, the type `Self` should be `C(T)`, not merely
`C`. Similarly, in an `interface I(T:! type)`, the type of self should
be `I(T)`, not merely `I`.
This commit is contained in:
Richard Smith
2024-06-28 20:20:40 +00:00
committed by GitHub
parent 19c5596fd8
commit 10a198a9e6
24 changed files with 395 additions and 224 deletions
+2 -2
View File
@@ -260,8 +260,8 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId node_id,
// declaration.
auto& class_info = context.classes().Get(class_decl.class_id);
if (class_info.is_generic()) {
// TODO: Build generic arguments representing the parameters.
auto instance_id = SemIR::GenericInstanceId::Invalid;
auto instance_id =
MakeGenericSelfInstance(context, class_info.generic_id);
class_info.self_type_id = context.GetTypeIdForTypeConstant(
TryEvalInst(context, SemIR::InstId::Invalid,
SemIR::ClassType{.type_id = SemIR::TypeId::TypeType,