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
+4 -4
View File
@@ -73,7 +73,7 @@ var c_bad: C({.a = 3, .b = 4}) = F();
// CHECK:STDOUT: %S: %.11 = bind_symbolic_name S 0 [symbolic]
// CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
// CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
// CHECK:STDOUT: %C.2: type = class_type @C [template]
// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic]
// CHECK:STDOUT: %.12: type = struct_type {} [template]
// CHECK:STDOUT: %.13: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.14: i32 = int_literal 2 [template]
@@ -202,9 +202,9 @@ var c_bad: C({.a = 3, .b = 4}) = F();
// CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
// CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
// CHECK:STDOUT: %.10: type = struct_type {} [template]
// CHECK:STDOUT: %C.2: type = class_type @C [template]
// CHECK:STDOUT: %.11: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %S: %.11 = bind_symbolic_name S 0, <unexpected instref inst+100> [symbolic]
// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic]
// CHECK:STDOUT: %.12: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.13: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.14: type = ptr_type %.11 [template]
@@ -324,9 +324,9 @@ var c_bad: C({.a = 3, .b = 4}) = F();
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
// CHECK:STDOUT: %.2: type = struct_type {} [template]
// CHECK:STDOUT: %C.2: type = class_type @C [template]
// CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0, <unexpected instref inst+18> [symbolic]
// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic]
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.6: type = struct_type {.c: i32, .d: i32} [template]
@@ -387,9 +387,9 @@ var c_bad: C({.a = 3, .b = 4}) = F();
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
// CHECK:STDOUT: %.2: type = struct_type {} [template]
// CHECK:STDOUT: %C.2: type = class_type @C [template]
// CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0, <unexpected instref inst+18> [symbolic]
// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic]
// CHECK:STDOUT: %.4: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.5: i32 = int_literal 4 [template]
// CHECK:STDOUT: %.6: type = ptr_type %.3 [template]