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
+5 -5
View File
@@ -29,8 +29,8 @@ class Class(T:! type) {
// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template]
// CHECK:STDOUT: %Class.2: type = class_type @Class [template]
// CHECK:STDOUT: %.2: type = ptr_type %Class.2 [template]
// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic]
// CHECK:STDOUT: %.2: type = ptr_type %Class.2 [symbolic]
// CHECK:STDOUT: %.3: type = ptr_type %T [symbolic]
// CHECK:STDOUT: %GetAddr.type: type = fn_type @GetAddr [template]
// CHECK:STDOUT: %GetAddr: %GetAddr.type = struct_value () [template]
@@ -56,8 +56,8 @@ class Class(T:! type) {
// CHECK:STDOUT: class @Class
// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] {
// CHECK:STDOUT: %GetAddr.decl: %GetAddr.type = fn_decl @GetAddr [template = constants.%GetAddr] {
// CHECK:STDOUT: %Self.ref.loc12: type = name_ref Self, constants.%Class.2 [template = constants.%Class.2]
// CHECK:STDOUT: %.loc12_29: type = ptr_type %Class.2 [template = constants.%.2]
// CHECK:STDOUT: %Self.ref.loc12: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2]
// CHECK:STDOUT: %.loc12_29: type = ptr_type %Class.2 [symbolic = constants.%.2]
// CHECK:STDOUT: %self.loc12_19.1: %.2 = param self
// CHECK:STDOUT: %self.loc12_19.3: %.2 = bind_name self, %self.loc12_19.1
// CHECK:STDOUT: %.loc12_14: %.2 = addr_pattern %self.loc12_19.3
@@ -66,7 +66,7 @@ class Class(T:! type) {
// CHECK:STDOUT: %return.var.loc12: ref %.3 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %GetValue.decl: %GetValue.type = fn_decl @GetValue [template = constants.%GetValue] {
// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class.2 [template = constants.%Class.2]
// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2]
// CHECK:STDOUT: %self.loc17_15.1: %Class.2 = param self
// CHECK:STDOUT: %self.loc17_15.2: %Class.2 = bind_name self, %self.loc17_15.1
// CHECK:STDOUT: %T.ref.loc17: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T]