// 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 // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/generic/template/convert.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/generic/template/convert.carbon // --- convert.carbon library "[[@TEST_NAME]]"; fn F[template T:! type](x: T) -> i32 { return x; } fn Test1(n: i32) -> i32 { return F(n); } class C { var n: i32; impl as Core.ImplicitAs(i32) { fn Convert[self: Self]() -> i32 { return self.n; } } } fn Test2(c: C) -> i32 { return F(c); } // --- fail_cannot_convert.carbon library "[[@TEST_NAME]]"; fn F[template T:! type](x: T) -> i32 { // CHECK:STDERR: fail_cannot_convert.carbon:[[@LINE+6]]:3: error: cannot implicitly convert expression of type `D` to `i32` [ConversionFailure] // CHECK:STDERR: return x; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_cannot_convert.carbon:[[@LINE+3]]:3: note: type `D` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote] // CHECK:STDERR: return x; // CHECK:STDERR: ^~~~~~~~~ return x; } class D {} fn Test(d: D) -> i32 { // CHECK:STDERR: fail_cannot_convert.carbon:[[@LINE+4]]:10: note: in `F(D)` used here [ResolvingSpecificHere] // CHECK:STDERR: return F(d); // CHECK:STDERR: ^ // CHECK:STDERR: return F(d); } // CHECK:STDOUT: --- convert.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0, template [template] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] // CHECK:STDOUT: %F: %F.type = struct_value () [concrete] // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete] // CHECK:STDOUT: %complete_type.f8a: = complete_type_witness %i32.builtin [concrete] // CHECK:STDOUT: %require_complete.4ae: = require_complete_type %T [template] // CHECK:STDOUT: %Test1.type: type = fn_type @Test1 [concrete] // CHECK:STDOUT: %Test1: %Test1.type = struct_value () [concrete] // CHECK:STDOUT: %F.specific_fn.501: = specific_function %F, @F(%i32) [concrete] // CHECK:STDOUT: %C: type = class_type @C [concrete] // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [concrete] // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete] // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete] // CHECK:STDOUT: %ImplicitAs.impl_witness.96d: = impl_witness @C.%ImplicitAs.impl_witness_table [concrete] // CHECK:STDOUT: %Convert.type.dae: type = fn_type @Convert.2 [concrete] // CHECK:STDOUT: %Convert.937: %Convert.type.dae = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value %C, (%ImplicitAs.impl_witness.96d) [concrete] // CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %i32} [concrete] // CHECK:STDOUT: %complete_type.54b: = complete_type_witness %struct_type.n [concrete] // CHECK:STDOUT: %Test2.type: type = fn_type @Test2 [concrete] // CHECK:STDOUT: %Test2: %Test2.type = struct_value () [concrete] // CHECK:STDOUT: %F.specific_fn.04a: = specific_function %F, @F(%C) [concrete] // CHECK:STDOUT: %inst.as_compatible.d73: = inst_value [concrete] { // CHECK:STDOUT: %.0b2: %i32 = as_compatible @F.%x.ref // CHECK:STDOUT: } // CHECK:STDOUT: %inst.splice_block.c18: = inst_value [concrete] { // CHECK:STDOUT: %.dc6: %i32 = splice_block %.0b2 {} // CHECK:STDOUT: } // CHECK:STDOUT: %inst.as_compatible.c0a: = inst_value [concrete] { // CHECK:STDOUT: %.fbe: %C = as_compatible @F.%x.ref // CHECK:STDOUT: } // CHECK:STDOUT: %.2ce: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete] // CHECK:STDOUT: %inst.splice_block.1fd: = inst_value [concrete] { // CHECK:STDOUT: %.96d: %i32 = splice_block %.521 { // CHECK:STDOUT: %impl.elem0: %.2ce = impl_witness_access %ImplicitAs.impl_witness.96d, element0 [concrete = %Convert.937] // CHECK:STDOUT: %bound_method: = bound_method %.fbe, %impl.elem0 // CHECK:STDOUT: %Convert.call: init %i32 = call %bound_method(%.fbe) // CHECK:STDOUT: %.fa7: %i32 = value_of_initializer %Convert.call // CHECK:STDOUT: %.521: %i32 = converted %.fbe, %.fa7 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { // CHECK:STDOUT: .Int = %Core.Int // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [concrete] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Test1 = %Test1.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .Test2 = %Test2.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %T.patt.loc4_15.1: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)] // CHECK:STDOUT: %x.patt: @F.%T.loc4_15.2 (%T) = binding_pattern x // CHECK:STDOUT: %x.param_patt: @F.%T.loc4_15.2 (%T) = value_param_pattern %x.patt, call_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1 // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: %x.param: @F.%T.loc4_15.2 (%T) = value_param call_param0 // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [template = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: %x: @F.%T.loc4_15.2 (%T) = bind_name x, %x.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %Test1.decl: %Test1.type = fn_decl @Test1 [concrete = constants.%Test1] { // CHECK:STDOUT: %n.patt: %i32 = binding_pattern n // CHECK:STDOUT: %n.param_patt: %i32 = value_param_pattern %n.patt, call_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1 // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32.loc8_21: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc8_21: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %n.param: %i32 = value_param call_param0 // CHECK:STDOUT: %.loc8: type = splice_block %i32.loc8_13 [concrete = constants.%i32] { // CHECK:STDOUT: %int_32.loc8_13: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc8_13: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %n: %i32 = bind_name n, %n.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} // CHECK:STDOUT: %Test2.decl: %Test2.type = fn_decl @Test2 [concrete = constants.%Test2] { // CHECK:STDOUT: %c.patt: %C = binding_pattern c // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, call_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1 // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %c.param: %C = value_param call_param0 // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %c: %C = bind_name c, %c.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl.4e3: %Self.ref as %ImplicitAs.type { // CHECK:STDOUT: %Convert.decl: %Convert.type.dae = fn_decl @Convert.2 [concrete = constants.%Convert.937] { // CHECK:STDOUT: %self.patt: %C = binding_pattern self // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, call_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1 // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %self.param: %C = value_param call_param0 // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C] // CHECK:STDOUT: %self: %C = bind_name self, %self.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Convert = %Convert.decl // CHECK:STDOUT: witness = @C.%ImplicitAs.impl_witness // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %.loc13: %C.elem = field_decl n, element0 [concrete] // CHECK:STDOUT: impl_decl @impl.4e3 [concrete] {} { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C] // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %ImplicitAs.ref: %ImplicitAs.type.cc7 = name_ref ImplicitAs, imports.%Core.ImplicitAs [concrete = constants.%ImplicitAs.generic] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%i32)> [concrete = constants.%ImplicitAs.type.205] // CHECK:STDOUT: } // CHECK:STDOUT: %ImplicitAs.impl_witness_table = impl_witness_table (@impl.4e3.%Convert.decl), @impl.4e3 [concrete] // CHECK:STDOUT: %ImplicitAs.impl_witness: = impl_witness %ImplicitAs.impl_witness_table [concrete = constants.%ImplicitAs.impl_witness.96d] // CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %i32} [concrete = constants.%struct_type.n] // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [concrete = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: .n = %.loc13 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @F(%T.loc4_15.1: type) { // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc4_15.2: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete: = require_complete_type %T.loc4_15.2 [template = %require_complete (constants.%require_complete.4ae)] // CHECK:STDOUT: %.loc5_11.3: = refine_type_action %x.ref, %T.loc4_15.2 [template] // CHECK:STDOUT: %.loc5_11.4: = convert_to_value_action %.loc5_11.1, constants.%i32 [template] // CHECK:STDOUT: // CHECK:STDOUT: fn(%x.param: @F.%T.loc4_15.2 (%T)) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: @F.%T.loc4_15.2 (%T) = name_ref x, %x // CHECK:STDOUT: %.loc5_11.1: @F.%T.loc4_15.2 (%T) = splice_inst %.loc5_11.3 // CHECK:STDOUT: %.loc5_11.2: %i32 = splice_inst %.loc5_11.4 // CHECK:STDOUT: return %.loc5_11.2 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Test1(%n.param: %i32) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F] // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%i32) [concrete = constants.%F.specific_fn.501] // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%n.ref) // CHECK:STDOUT: %.loc9_14.1: %i32 = value_of_initializer %F.call // CHECK:STDOUT: %.loc9_14.2: %i32 = converted %F.call, %.loc9_14.1 // CHECK:STDOUT: return %.loc9_14.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Convert.2(%self.param: %C) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %C = name_ref self, %self // CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc13 [concrete = @C.%.loc13] // CHECK:STDOUT: %.loc15_50.1: ref %i32 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc15_50.2: %i32 = bind_value %.loc15_50.1 // CHECK:STDOUT: return %.loc15_50.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Test2(%c.param: %C) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F] // CHECK:STDOUT: %c.ref: %C = name_ref c, %c // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%C) [concrete = constants.%F.specific_fn.04a] // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%c.ref) // CHECK:STDOUT: %.loc20_14.1: %i32 = value_of_initializer %F.call // CHECK:STDOUT: %.loc20_14.2: %i32 = converted %F.call, %.loc20_14.1 // CHECK:STDOUT: return %.loc20_14.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%T) { // CHECK:STDOUT: %T.loc4_15.2 => constants.%T // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%i32) { // CHECK:STDOUT: %T.loc4_15.2 => constants.%i32 // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a // CHECK:STDOUT: %.loc5_11.3 => constants.%inst.as_compatible.d73 // CHECK:STDOUT: %.loc5_11.4 => constants.%inst.splice_block.c18 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%C) { // CHECK:STDOUT: %T.loc4_15.2 => constants.%C // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete => constants.%complete_type.54b // CHECK:STDOUT: %.loc5_11.3 => constants.%inst.as_compatible.c0a // CHECK:STDOUT: %.loc5_11.4 => constants.%inst.splice_block.1fd // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_cannot_convert.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0, template [template] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] // CHECK:STDOUT: %F: %F.type = struct_value () [concrete] // CHECK:STDOUT: %require_complete.4ae: = require_complete_type %T [template] // CHECK:STDOUT: %D: type = class_type @D [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %Test.type: type = fn_type @Test [concrete] // CHECK:STDOUT: %Test: %Test.type = struct_value () [concrete] // CHECK:STDOUT: %F.specific_fn: = specific_function %F, @F(%D) [concrete] // CHECK:STDOUT: %inst.as_compatible: = inst_value [concrete] { // CHECK:STDOUT: %.63b: %D = as_compatible @F.%x.ref // CHECK:STDOUT: } // CHECK:STDOUT: %inst.splice_block: = inst_value [concrete] { // CHECK:STDOUT: %.593: = splice_block [concrete = ] { // CHECK:STDOUT: %.16e: %i32 = converted %.63b, [concrete = ] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { // CHECK:STDOUT: .Int = %Core.Int // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [concrete] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .Test = %Test.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %T.patt.loc4_15.1: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)] // CHECK:STDOUT: %x.patt: @F.%T.loc4_15.2 (%T) = binding_pattern x // CHECK:STDOUT: %x.param_patt: @F.%T.loc4_15.2 (%T) = value_param_pattern %x.patt, call_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1 // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: %x.param: @F.%T.loc4_15.2 (%T) = value_param call_param0 // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [template = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: %x: @F.%T.loc4_15.2 (%T) = bind_name x, %x.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {} // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [concrete = constants.%Test] { // CHECK:STDOUT: %d.patt: %D = binding_pattern d // CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, call_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1 // CHECK:STDOUT: } { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %d.param: %D = value_param call_param0 // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D] // CHECK:STDOUT: %d: %D = bind_name d, %d.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @D { // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%D // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @F(%T.loc4_15.1: type) { // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc4_15.2: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete: = require_complete_type %T.loc4_15.2 [template = %require_complete (constants.%require_complete.4ae)] // CHECK:STDOUT: %.loc11_11.3: = refine_type_action %x.ref, %T.loc4_15.2 [template] // CHECK:STDOUT: %.loc11_11.4: = convert_to_value_action %.loc11_11.1, constants.%i32 [template] // CHECK:STDOUT: // CHECK:STDOUT: fn(%x.param: @F.%T.loc4_15.2 (%T)) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: @F.%T.loc4_15.2 (%T) = name_ref x, %x // CHECK:STDOUT: %.loc11_11.1: @F.%T.loc4_15.2 (%T) = splice_inst %.loc11_11.3 // CHECK:STDOUT: %.loc11_11.2: %i32 = splice_inst %.loc11_11.4 // CHECK:STDOUT: return %.loc11_11.2 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Test(%d.param: %D) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F] // CHECK:STDOUT: %d.ref: %D = name_ref d, %d // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%D) [concrete = constants.%F.specific_fn] // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%d.ref) // CHECK:STDOUT: %.loc21_14.1: %i32 = value_of_initializer %F.call // CHECK:STDOUT: %.loc21_14.2: %i32 = converted %F.call, %.loc21_14.1 // CHECK:STDOUT: return %.loc21_14.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%T) { // CHECK:STDOUT: %T.loc4_15.2 => constants.%T // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%D) { // CHECK:STDOUT: %T.loc4_15.2 => constants.%D // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete => constants.%complete_type.357 // CHECK:STDOUT: %.loc11_11.3 => constants.%inst.as_compatible // CHECK:STDOUT: %.loc11_11.4 => constants.%inst.splice_block // CHECK:STDOUT: } // CHECK:STDOUT: