Include the complete type witness for a class in its SemIR output. (#4599)

This seems slightly redundant for a locally-defined class, where there
will be a complete_type_witness instruction earlier in the class, but is
important for imported classes, where we're currently doing the wrong
thing in a way that's invisible in formatted SemIR.
This commit is contained in:
Richard Smith
2024-11-27 23:45:20 +00:00
committed by GitHub
parent d6ec885eb3
commit 4a10d29b99
225 changed files with 955 additions and 0 deletions
@@ -104,6 +104,7 @@ fn Class(F:! type).Inner.G() -> i32 { return F(); }
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%Class.2
// CHECK:STDOUT: .Inner = %Inner.decl
// CHECK:STDOUT: complete_type_witness = %.loc11
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -144,6 +145,7 @@ fn Class(F:! type).Inner.G() -> i32 { return F(); }
// CHECK:STDOUT: .Self = constants.%Inner.2
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: complete_type_witness = %.loc10
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -199,6 +199,7 @@ extern library "basic" fn F();
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: complete_type_witness = %.loc15
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F();
@@ -157,6 +157,7 @@ fn CallFAndGIncomplete() {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%D
// CHECK:STDOUT: complete_type_witness = %.loc37
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @ReturnCUnused() -> %C;
@@ -189,6 +190,8 @@ fn CallFAndGIncomplete() {
// CHECK:STDOUT: %ReturnDUnused.type: type = fn_type @ReturnDUnused [template]
// CHECK:STDOUT: %ReturnDUnused: %ReturnDUnused.type = struct_value () [template]
// CHECK:STDOUT: %D: type = class_type @D [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %ReturnDUsed.type: type = fn_type @ReturnDUsed [template]
// CHECK:STDOUT: %ReturnDUsed: %ReturnDUsed.type = struct_value () [template]
// CHECK:STDOUT: }
@@ -224,6 +227,7 @@ fn CallFAndGIncomplete() {
// CHECK:STDOUT: class @D {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%import_ref.8
// CHECK:STDOUT: complete_type_witness = constants.%.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @CallFAndGIncomplete() {
@@ -229,6 +229,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C) {
@@ -280,6 +281,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo[](%a.param_patt: %C) {
@@ -328,6 +330,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C);
@@ -376,6 +379,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C) {
@@ -428,6 +432,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C);
@@ -438,6 +443,8 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template]
@@ -480,6 +487,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%import_ref.5
// CHECK:STDOUT: complete_type_witness = constants.%.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C) {
@@ -536,6 +544,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C);
@@ -589,6 +598,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C);
@@ -644,6 +654,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Foo(%a.loc7_8.1: %C) {
@@ -718,6 +729,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() -> %return: %C {
@@ -759,6 +771,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C);
@@ -767,6 +780,8 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: }
@@ -799,6 +814,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%import_ref.3
// CHECK:STDOUT: complete_type_witness = constants.%.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %C) {
@@ -851,6 +867,7 @@ fn Foo(a: const (const C)) {}
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a.param_patt: %.3);
@@ -572,6 +572,7 @@ fn CallImplicitNotDeducible() {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%A
// CHECK:STDOUT: complete_type_witness = %.loc4
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @ExplicitAndAlsoDeduced(%T.loc6_27.1: type) {
@@ -156,6 +156,7 @@ fn CallSpecific(x: C) -> C {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc16
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Function(%T.loc4_13.1: type) {
@@ -370,6 +371,7 @@ fn CallSpecific(x: C) -> C {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc16
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Function(%T.loc4_13.1: type) {
@@ -156,6 +156,7 @@ fn H() {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: complete_type_witness = %.loc6
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @H() {
@@ -109,6 +109,7 @@ fn G() {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%Wrap.2
// CHECK:STDOUT: .Make = %Make.decl
// CHECK:STDOUT: complete_type_witness = %.loc13
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -125,6 +126,7 @@ fn G() {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: .arr = %.loc15_18
// CHECK:STDOUT: complete_type_witness = %.loc15_32
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Make(@Wrap.%T.loc11_12.1: type) {