Files
carbon-lang/toolchain/check/testdata/class/generic/self.carbon
T
Chandler Carruthandjosh11b 7871237c15 Move self to the explicit () parameter list (proposal #7016) (#7272)
Implements proposal #7016: `self` moves from the deduced implicit list
(`fn F[self: Self]()`) to the front of the explicit list. Its type may
be written explicitly (`fn F(self: Self)`) or omitted, in which case it
defaults to `Self` (`fn F(self)`, `fn F(ref self)`); `self` in the
implicit list is rejected.

Throughout checking, `self` is modeled as the first explicit parameter.
Because a method is just a function whose first parameter is `self`, it
can also be called as an ordinary function with the receiver passed
explicitly (`Type.M(obj, ...)`), not only as `obj.M(...)`. A new
`SemIR::CallArgParamPatterns` helper chooses the parameters matched
against the explicit arguments, excluding a leading `self` only when it
is supplied as a method-call receiver; arity checking, conversion, and
generic deduction use it. The resulting SemIR and lowering are
unchanged: `self` is still `call_param0`, and witnesses, thunks, and
vtables are unaffected.

An omitted `self` type is parsed as a `SelfBindingPattern` node with no
type expression; checking synthesizes the `Self` type so it behaves
exactly like `self: Self`. However, the exact spelling used must match
between a forward declaration and a definition, following #3763's rules
around declaration matching.

Generated functions, thunks, and C++ interop import/export build `self`
as the first explicit parameter, and the `self`-type override (e.g.
Derived->Base for a virtual override) applies to the explicit `self`.
Placement is validated by new diagnostics: `SelfInImplicitParamList`,
`SelfNotFirstParam`, and `SelfOutsideParamList`. The benchmark source
generator and the documentation adopt the `(self)` shorthand; the
prelude, the examples, and the test data are migrated in the following
commits.

Assisted-by: Claude Code with Claude Opus 4.7

---------

Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
2026-06-10 15:30:43 +00:00

283 lines
23 KiB
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/destroy.carbon
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/self.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/self.carbon
class Class(T:! type) {
// `Self` is the same as `Class(T)` here.
// TODO: Find a better way to test two types are the same.
fn MakeSelf() -> Self { return {}; }
fn MakeClass() -> Class(T) { return {}; }
fn F() {
var unused c: Class(T) = MakeSelf();
var unused s: Self = MakeClass();
}
}
// CHECK:STDOUT: --- self.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
// CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
// CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [concrete]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [concrete]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic]
// CHECK:STDOUT: %.030: Core.Form = init_form %Class [symbolic]
// CHECK:STDOUT: %pattern_type.36e: type = pattern_type %Class [symbolic]
// CHECK:STDOUT: %Class.MakeSelf.type: type = fn_type @Class.MakeSelf, @Class(%T) [symbolic]
// CHECK:STDOUT: %Class.MakeSelf: %Class.MakeSelf.type = struct_value () [symbolic]
// CHECK:STDOUT: %Class.MakeClass.type: type = fn_type @Class.MakeClass, @Class(%T) [symbolic]
// CHECK:STDOUT: %Class.MakeClass: %Class.MakeClass.type = struct_value () [symbolic]
// CHECK:STDOUT: %Class.F.type: type = fn_type @Class.F, @Class(%T) [symbolic]
// CHECK:STDOUT: %Class.F: %Class.F.type = struct_value () [symbolic]
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Class [symbolic]
// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
// CHECK:STDOUT: %Class.val: %Class = struct_value () [symbolic]
// CHECK:STDOUT: %Class.MakeSelf.specific_fn: <specific function> = specific_function %Class.MakeSelf, @Class.MakeSelf(%T) [symbolic]
// CHECK:STDOUT: %Class.MakeClass.specific_fn: <specific function> = specific_function %Class.MakeClass, @Class.MakeClass(%T) [symbolic]
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
// CHECK:STDOUT: %Destroy.lookup_impl_witness: <witness> = lookup_impl_witness %Class, @Destroy [symbolic]
// CHECK:STDOUT: %Destroy.facet.86d: %Destroy.type = facet_value %Class, (%Destroy.lookup_impl_witness) [symbolic]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.297: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.86d) [symbolic]
// CHECK:STDOUT: %.73f: type = fn_type_with_self_type %Destroy.WithSelf.Op.type.297, %Destroy.facet.86d [symbolic]
// CHECK:STDOUT: %impl.elem0: %.73f = impl_witness_access %Destroy.lookup_impl_witness, element0 [symbolic]
// CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @Destroy.WithSelf.Op(%Destroy.facet.86d) [symbolic]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Destroy = %Core.Destroy
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .Class = %Class.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [concrete = constants.%Class.generic] {
// CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc15_17.1: type = splice_block %.loc15_17.2 [concrete = type] {
// CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
// CHECK:STDOUT: %.loc15_17.2: type = type_literal type [concrete = type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %T.loc15_14.2: type = symbolic_binding T, 0 [symbolic = %T.loc15_14.1 (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic class @Class(%T.loc15_14.2: type) {
// CHECK:STDOUT: %T.loc15_14.1: type = symbolic_binding T, 0 [symbolic = %T.loc15_14.1 (constants.%T)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %Class.MakeSelf.type: type = fn_type @Class.MakeSelf, @Class(%T.loc15_14.1) [symbolic = %Class.MakeSelf.type (constants.%Class.MakeSelf.type)]
// CHECK:STDOUT: %Class.MakeSelf: @Class.%Class.MakeSelf.type (%Class.MakeSelf.type) = struct_value () [symbolic = %Class.MakeSelf (constants.%Class.MakeSelf)]
// CHECK:STDOUT: %Class.MakeClass.type: type = fn_type @Class.MakeClass, @Class(%T.loc15_14.1) [symbolic = %Class.MakeClass.type (constants.%Class.MakeClass.type)]
// CHECK:STDOUT: %Class.MakeClass: @Class.%Class.MakeClass.type (%Class.MakeClass.type) = struct_value () [symbolic = %Class.MakeClass (constants.%Class.MakeClass)]
// CHECK:STDOUT: %Class.F.type: type = fn_type @Class.F, @Class(%T.loc15_14.1) [symbolic = %Class.F.type (constants.%Class.F.type)]
// CHECK:STDOUT: %Class.F: @Class.%Class.F.type (%Class.F.type) = struct_value () [symbolic = %Class.F (constants.%Class.F)]
// CHECK:STDOUT:
// CHECK:STDOUT: class {
// CHECK:STDOUT: %Class.MakeSelf.decl: @Class.%Class.MakeSelf.type (%Class.MakeSelf.type) = fn_decl @Class.MakeSelf [symbolic = @Class.%Class.MakeSelf (constants.%Class.MakeSelf)] {
// CHECK:STDOUT: %return.param_patt: @Class.MakeSelf.%pattern_type (%pattern_type.36e) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.MakeSelf.%pattern_type (%pattern_type.36e) = return_slot_pattern %return.param_patt, %Self.ref [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc18_20.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc18_20.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc18_20.3: Core.Form = init_form %Self.ref [symbolic = %.loc18_20.1 (constants.%.030)]
// CHECK:STDOUT: %return.param: ref @Class.MakeSelf.%Class (%Class) = out_param call_param0
// CHECK:STDOUT: %return: ref @Class.MakeSelf.%Class (%Class) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.MakeClass.decl: @Class.%Class.MakeClass.type (%Class.MakeClass.type) = fn_decl @Class.MakeClass [symbolic = @Class.%Class.MakeClass (constants.%Class.MakeClass)] {
// CHECK:STDOUT: %return.param_patt: @Class.MakeClass.%pattern_type (%pattern_type.36e) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.MakeClass.%pattern_type (%pattern_type.36e) = return_slot_pattern %return.param_patt, %Class.loc19_28.2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
// CHECK:STDOUT: %T.ref: type = name_ref T, @Class.%T.loc15_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %Class.loc19_28.2: type = class_type @Class, @Class(constants.%T) [symbolic = %Class.loc19_28.1 (constants.%Class)]
// CHECK:STDOUT: %.loc19_28.2: Core.Form = init_form %Class.loc19_28.2 [symbolic = %.loc19_28.1 (constants.%.030)]
// CHECK:STDOUT: %return.param: ref @Class.MakeClass.%Class.loc19_28.1 (%Class) = out_param call_param0
// CHECK:STDOUT: %return: ref @Class.MakeClass.%Class.loc19_28.1 (%Class) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.F.decl: @Class.%Class.F.type (%Class.F.type) = fn_decl @Class.F [symbolic = @Class.%Class.F (constants.%Class.F)] {} {}
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%Class
// CHECK:STDOUT: .MakeSelf = %Class.MakeSelf.decl
// CHECK:STDOUT: .Class = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: .MakeClass = %Class.MakeClass.decl
// CHECK:STDOUT: .F = %Class.F.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Class.MakeSelf(@Class.%T.loc15_14.2: type) {
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc18_20.1: Core.Form = init_form %Class [symbolic = %.loc18_20.1 (constants.%.030)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %Class [symbolic = %pattern_type (constants.%pattern_type.36e)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Class [symbolic = %require_complete (constants.%require_complete)]
// CHECK:STDOUT: %Class.val: @Class.MakeSelf.%Class (%Class) = struct_value () [symbolic = %Class.val (constants.%Class.val)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() -> out %return.param: @Class.MakeSelf.%Class (%Class) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc18_35.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc18_35.2: init @Class.MakeSelf.%Class (%Class) to %return.param = class_init () [symbolic = %Class.val (constants.%Class.val)]
// CHECK:STDOUT: %.loc18_36: init @Class.MakeSelf.%Class (%Class) = converted %.loc18_35.1, %.loc18_35.2 [symbolic = %Class.val (constants.%Class.val)]
// CHECK:STDOUT: return %.loc18_36 to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Class.MakeClass(@Class.%T.loc15_14.2: type) {
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %Class.loc19_28.1: type = class_type @Class, @Class(%T) [symbolic = %Class.loc19_28.1 (constants.%Class)]
// CHECK:STDOUT: %.loc19_28.1: Core.Form = init_form %Class.loc19_28.1 [symbolic = %.loc19_28.1 (constants.%.030)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %Class.loc19_28.1 [symbolic = %pattern_type (constants.%pattern_type.36e)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Class.loc19_28.1 [symbolic = %require_complete (constants.%require_complete)]
// CHECK:STDOUT: %Class.val: @Class.MakeClass.%Class.loc19_28.1 (%Class) = struct_value () [symbolic = %Class.val (constants.%Class.val)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() -> out %return.param: @Class.MakeClass.%Class.loc19_28.1 (%Class) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc19_40.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc19_40.2: init @Class.MakeClass.%Class.loc19_28.1 (%Class) to %return.param = class_init () [symbolic = %Class.val (constants.%Class.val)]
// CHECK:STDOUT: %.loc19_41: init @Class.MakeClass.%Class.loc19_28.1 (%Class) = converted %.loc19_40.1, %.loc19_40.2 [symbolic = %Class.val (constants.%Class.val)]
// CHECK:STDOUT: return %.loc19_41 to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Class.F(@Class.%T.loc15_14.2: type) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %Class.loc21_26.2: type = class_type @Class, @Class(%T) [symbolic = %Class.loc21_26.2 (constants.%Class)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Class.loc21_26.2 [symbolic = %require_complete (constants.%require_complete)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %Class.loc21_26.2 [symbolic = %pattern_type (constants.%pattern_type.36e)]
// CHECK:STDOUT: %Class.MakeSelf.type: type = fn_type @Class.MakeSelf, @Class(%T) [symbolic = %Class.MakeSelf.type (constants.%Class.MakeSelf.type)]
// CHECK:STDOUT: %Class.MakeSelf: @Class.F.%Class.MakeSelf.type (%Class.MakeSelf.type) = struct_value () [symbolic = %Class.MakeSelf (constants.%Class.MakeSelf)]
// CHECK:STDOUT: %Class.MakeSelf.specific_fn.loc21_30.2: <specific function> = specific_function %Class.MakeSelf, @Class.MakeSelf(%T) [symbolic = %Class.MakeSelf.specific_fn.loc21_30.2 (constants.%Class.MakeSelf.specific_fn)]
// CHECK:STDOUT: %Class.MakeClass.type: type = fn_type @Class.MakeClass, @Class(%T) [symbolic = %Class.MakeClass.type (constants.%Class.MakeClass.type)]
// CHECK:STDOUT: %Class.MakeClass: @Class.F.%Class.MakeClass.type (%Class.MakeClass.type) = struct_value () [symbolic = %Class.MakeClass (constants.%Class.MakeClass)]
// CHECK:STDOUT: %Class.MakeClass.specific_fn.loc22_26.2: <specific function> = specific_function %Class.MakeClass, @Class.MakeClass(%T) [symbolic = %Class.MakeClass.specific_fn.loc22_26.2 (constants.%Class.MakeClass.specific_fn)]
// CHECK:STDOUT: %Destroy.lookup_impl_witness: <witness> = lookup_impl_witness %Class.loc21_26.2, @Destroy [symbolic = %Destroy.lookup_impl_witness (constants.%Destroy.lookup_impl_witness)]
// CHECK:STDOUT: %Destroy.facet.loc22_5.2: %Destroy.type = facet_value %Class.loc21_26.2, (%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.loc22_5.2) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.297)]
// CHECK:STDOUT: %.loc22_5.3: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet.loc22_5.2 [symbolic = %.loc22_5.3 (constants.%.73f)]
// CHECK:STDOUT: %impl.elem0.loc22_5.2: @Class.F.%.loc22_5.3 (%.73f) = impl_witness_access %Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc22_5.2: <specific function> = specific_impl_function %impl.elem0.loc22_5.2, @Destroy.WithSelf.Op(%Destroy.facet.loc22_5.2) [symbolic = %specific_impl_fn.loc22_5.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %c.patt: @Class.F.%pattern_type (%pattern_type.36e) = ref_binding_pattern c [concrete]
// CHECK:STDOUT: %c.var_patt: @Class.F.%pattern_type (%pattern_type.36e) = var_pattern %c.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c.var: ref @Class.F.%Class.loc21_26.2 (%Class) = var %c.var_patt
// CHECK:STDOUT: %.loc21_30: @Class.F.%Class.MakeSelf.type (%Class.MakeSelf.type) = specific_constant @Class.%Class.MakeSelf.decl, @Class(constants.%T) [symbolic = %Class.MakeSelf (constants.%Class.MakeSelf)]
// CHECK:STDOUT: %MakeSelf.ref: @Class.F.%Class.MakeSelf.type (%Class.MakeSelf.type) = name_ref MakeSelf, %.loc21_30 [symbolic = %Class.MakeSelf (constants.%Class.MakeSelf)]
// CHECK:STDOUT: %Class.MakeSelf.specific_fn.loc21_30.1: <specific function> = specific_function %MakeSelf.ref, @Class.MakeSelf(constants.%T) [symbolic = %Class.MakeSelf.specific_fn.loc21_30.2 (constants.%Class.MakeSelf.specific_fn)]
// CHECK:STDOUT: %.loc21_5.1: ref @Class.F.%Class.loc21_26.2 (%Class) = splice_block %c.var {}
// CHECK:STDOUT: %Class.MakeSelf.call: init @Class.F.%Class.loc21_26.2 (%Class) to %.loc21_5.1 = call %Class.MakeSelf.specific_fn.loc21_30.1()
// CHECK:STDOUT: assign %c.var, %Class.MakeSelf.call
// CHECK:STDOUT: %.loc21_26: type = splice_block %Class.loc21_26.1 [symbolic = %Class.loc21_26.2 (constants.%Class)] {
// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
// CHECK:STDOUT: %T.ref: type = name_ref T, @Class.%T.loc15_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %Class.loc21_26.1: type = class_type @Class, @Class(constants.%T) [symbolic = %Class.loc21_26.2 (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c: ref @Class.F.%Class.loc21_26.2 (%Class) = ref_binding c, %c.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %s.patt: @Class.F.%pattern_type (%pattern_type.36e) = ref_binding_pattern s [concrete]
// CHECK:STDOUT: %s.var_patt: @Class.F.%pattern_type (%pattern_type.36e) = var_pattern %s.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %s.var: ref @Class.F.%Class.loc21_26.2 (%Class) = var %s.var_patt
// CHECK:STDOUT: %.loc22_26: @Class.F.%Class.MakeClass.type (%Class.MakeClass.type) = specific_constant @Class.%Class.MakeClass.decl, @Class(constants.%T) [symbolic = %Class.MakeClass (constants.%Class.MakeClass)]
// CHECK:STDOUT: %MakeClass.ref: @Class.F.%Class.MakeClass.type (%Class.MakeClass.type) = name_ref MakeClass, %.loc22_26 [symbolic = %Class.MakeClass (constants.%Class.MakeClass)]
// CHECK:STDOUT: %Class.MakeClass.specific_fn.loc22_26.1: <specific function> = specific_function %MakeClass.ref, @Class.MakeClass(constants.%T) [symbolic = %Class.MakeClass.specific_fn.loc22_26.2 (constants.%Class.MakeClass.specific_fn)]
// CHECK:STDOUT: %.loc22_5.1: ref @Class.F.%Class.loc21_26.2 (%Class) = splice_block %s.var {}
// CHECK:STDOUT: %Class.MakeClass.call: init @Class.F.%Class.loc21_26.2 (%Class) to %.loc22_5.1 = call %Class.MakeClass.specific_fn.loc22_26.1()
// CHECK:STDOUT: assign %s.var, %Class.MakeClass.call
// CHECK:STDOUT: %.loc22_19.1: type = splice_block %Self.ref [symbolic = %Class.loc21_26.2 (constants.%Class)] {
// CHECK:STDOUT: %.loc22_19.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class.loc21_26.2 (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc22_19.2 [symbolic = %Class.loc21_26.2 (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %s: ref @Class.F.%Class.loc21_26.2 (%Class) = ref_binding s, %s.var
// CHECK:STDOUT: %impl.elem0.loc22_5.1: @Class.F.%.loc22_5.3 (%.73f) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc22_5.1: <bound method> = bound_method %s.var, %impl.elem0.loc22_5.1
// CHECK:STDOUT: %Destroy.facet.loc22_5.1: %Destroy.type = facet_value constants.%Class, (constants.%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %.loc22_5.2: %Destroy.type = converted constants.%Class, %Destroy.facet.loc22_5.1 [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %specific_impl_fn.loc22_5.1: <specific function> = specific_impl_function %impl.elem0.loc22_5.1, @Destroy.WithSelf.Op(constants.%Destroy.facet.86d) [symbolic = %specific_impl_fn.loc22_5.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc22_5.2: <bound method> = bound_method %s.var, %specific_impl_fn.loc22_5.1
// CHECK:STDOUT: %Destroy.WithSelf.Op.call.loc22: init %empty_tuple.type = call %bound_method.loc22_5.2(%s.var)
// CHECK:STDOUT: %impl.elem0.loc21: @Class.F.%.loc22_5.3 (%.73f) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc21_5.1: <bound method> = bound_method %c.var, %impl.elem0.loc21
// CHECK:STDOUT: %Destroy.facet.loc21: %Destroy.type = facet_value constants.%Class, (constants.%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %.loc21_5.2: %Destroy.type = converted constants.%Class, %Destroy.facet.loc21 [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %specific_impl_fn.loc21: <specific function> = specific_impl_function %impl.elem0.loc21, @Destroy.WithSelf.Op(constants.%Destroy.facet.86d) [symbolic = %specific_impl_fn.loc22_5.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc21_5.2: <bound method> = bound_method %c.var, %specific_impl_fn.loc21
// CHECK:STDOUT: %Destroy.WithSelf.Op.call.loc21: init %empty_tuple.type = call %bound_method.loc21_5.2(%c.var)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op(%self.param: ref %empty_struct_type) = "no_op";
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class(constants.%T) {
// CHECK:STDOUT: %T.loc15_14.1 => constants.%T
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %Class.MakeSelf.type => constants.%Class.MakeSelf.type
// CHECK:STDOUT: %Class.MakeSelf => constants.%Class.MakeSelf
// CHECK:STDOUT: %Class.MakeClass.type => constants.%Class.MakeClass.type
// CHECK:STDOUT: %Class.MakeClass => constants.%Class.MakeClass
// CHECK:STDOUT: %Class.F.type => constants.%Class.F.type
// CHECK:STDOUT: %Class.F => constants.%Class.F
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.MakeSelf(constants.%T) {
// CHECK:STDOUT: %T => constants.%T
// CHECK:STDOUT: %Class => constants.%Class
// CHECK:STDOUT: %.loc18_20.1 => constants.%.030
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.36e
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%require_complete
// CHECK:STDOUT: %Class.val => constants.%Class.val
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.MakeClass(constants.%T) {
// CHECK:STDOUT: %T => constants.%T
// CHECK:STDOUT: %Class.loc19_28.1 => constants.%Class
// CHECK:STDOUT: %.loc19_28.1 => constants.%.030
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.36e
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%require_complete
// CHECK:STDOUT: %Class.val => constants.%Class.val
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.F(constants.%T) {}
// CHECK:STDOUT: