init.carbon 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/init.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/init.carbon
  12. // --- from_struct.carbon
  13. library "[[@TEST_NAME]]";
  14. class Class(T:! type) {
  15. var k: T;
  16. }
  17. //@dump-sem-ir-begin
  18. fn InitFromStructGeneric(T:! Core.Copy, x: T) -> T {
  19. var v: Class(T) = {.k = x};
  20. return v.k;
  21. }
  22. fn InitFromStructSpecific(x: i32) -> i32 {
  23. var v: Class(i32) = {.k = x};
  24. return v.k;
  25. }
  26. //@dump-sem-ir-end
  27. // --- adapt.carbon
  28. library "[[@TEST_NAME]]";
  29. class Adapt(T:! type) {
  30. adapt T;
  31. }
  32. //@dump-sem-ir-begin
  33. fn InitFromAdaptedGeneric(T:! Core.Copy, x: T) -> T {
  34. return (x as Adapt(T)) as T;
  35. }
  36. fn InitFromAdaptedSpecific(x: i32) -> i32 {
  37. return (x as Adapt(i32)) as i32;
  38. }
  39. //@dump-sem-ir-end
  40. // CHECK:STDOUT: --- from_struct.carbon
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: constants {
  43. // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [concrete]
  44. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  45. // CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [concrete]
  46. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  47. // CHECK:STDOUT: %Destroy.Op.type: type = fn_type @Destroy.Op [concrete]
  48. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  49. // CHECK:STDOUT: %T.578: %Copy.type = bind_symbolic_name T, 0 [symbolic]
  50. // CHECK:STDOUT: %pattern_type.ce2: type = pattern_type %Copy.type [concrete]
  51. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T.578 [symbolic]
  52. // CHECK:STDOUT: %pattern_type.f8cebc.1: type = pattern_type %T.as_type [symbolic]
  53. // CHECK:STDOUT: %InitFromStructGeneric.type: type = fn_type @InitFromStructGeneric [concrete]
  54. // CHECK:STDOUT: %InitFromStructGeneric: %InitFromStructGeneric.type = struct_value () [concrete]
  55. // CHECK:STDOUT: %require_complete.ecc: <witness> = require_complete_type %T.as_type [symbolic]
  56. // CHECK:STDOUT: %Class.b1d: type = class_type @Class, @Class(%T.as_type) [symbolic]
  57. // CHECK:STDOUT: %Class.elem.73a: type = unbound_element_type %Class.b1d, %T.as_type [symbolic]
  58. // CHECK:STDOUT: %struct_type.k.c03: type = struct_type {.k: %T.as_type} [symbolic]
  59. // CHECK:STDOUT: %require_complete.57f: <witness> = require_complete_type %Class.b1d [symbolic]
  60. // CHECK:STDOUT: %pattern_type.a8f: type = pattern_type %Class.b1d [symbolic]
  61. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  62. // CHECK:STDOUT: %Copy.lookup_impl_witness.3ba: <witness> = lookup_impl_witness %T.578, @Copy [symbolic]
  63. // CHECK:STDOUT: %Copy.facet.72e: %Copy.type = facet_value %T.as_type, (%Copy.lookup_impl_witness.3ba) [symbolic]
  64. // CHECK:STDOUT: %.671: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet.72e [symbolic]
  65. // CHECK:STDOUT: %impl.elem0.56e: %.671 = impl_witness_access %Copy.lookup_impl_witness.3ba, element0 [symbolic]
  66. // CHECK:STDOUT: %specific_impl_fn.fb7: <specific function> = specific_impl_function %impl.elem0.56e, @Copy.Op(%Copy.facet.72e) [symbolic]
  67. // CHECK:STDOUT: %Destroy.impl_witness.492: <witness> = impl_witness @Class.%Destroy.impl_witness_table, @Class.as.Destroy.impl(%T.as_type) [symbolic]
  68. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.type.637: type = fn_type @Class.as.Destroy.impl.Op, @Class.as.Destroy.impl(%T.as_type) [symbolic]
  69. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.598: %Class.as.Destroy.impl.Op.type.637 = struct_value () [symbolic]
  70. // CHECK:STDOUT: %Destroy.facet.744: %Destroy.type = facet_value %Class.b1d, (%Destroy.impl_witness.492) [symbolic]
  71. // CHECK:STDOUT: %.c08: type = fn_type_with_self_type %Destroy.Op.type, %Destroy.facet.744 [symbolic]
  72. // CHECK:STDOUT: %ptr.458: type = ptr_type %Class.b1d [symbolic]
  73. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.specific_fn.df2: <specific function> = specific_function %Class.as.Destroy.impl.Op.598, @Class.as.Destroy.impl.Op(%T.as_type) [symbolic]
  74. // CHECK:STDOUT: %require_complete.ec5: <witness> = require_complete_type %ptr.458 [symbolic]
  75. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  76. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  77. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  78. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic]
  79. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  80. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  81. // CHECK:STDOUT: %InitFromStructSpecific.type: type = fn_type @InitFromStructSpecific [concrete]
  82. // CHECK:STDOUT: %InitFromStructSpecific: %InitFromStructSpecific.type = struct_value () [concrete]
  83. // CHECK:STDOUT: %Class.247: type = class_type @Class, @Class(%i32) [concrete]
  84. // CHECK:STDOUT: %Class.elem.2d8: type = unbound_element_type %Class.247, %i32 [concrete]
  85. // CHECK:STDOUT: %struct_type.k.0bf: type = struct_type {.k: %i32} [concrete]
  86. // CHECK:STDOUT: %pattern_type.0fa: type = pattern_type %Class.247 [concrete]
  87. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.857: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  88. // CHECK:STDOUT: %Int.as.Copy.impl.Op.6aa: %Int.as.Copy.impl.Op.type.857 = struct_value () [symbolic]
  89. // CHECK:STDOUT: %Copy.impl_witness.f0b: <witness> = impl_witness imports.%Copy.impl_witness_table.f59, @Int.as.Copy.impl(%int_32) [concrete]
  90. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.af5: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  91. // CHECK:STDOUT: %Int.as.Copy.impl.Op.87e: %Int.as.Copy.impl.Op.type.af5 = struct_value () [concrete]
  92. // CHECK:STDOUT: %Copy.facet.26d: %Copy.type = facet_value %i32, (%Copy.impl_witness.f0b) [concrete]
  93. // CHECK:STDOUT: %.3c4: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet.26d [concrete]
  94. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.87e, @Int.as.Copy.impl.Op(%int_32) [concrete]
  95. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.type.ce6: type = fn_type @Class.as.Destroy.impl.Op, @Class.as.Destroy.impl(%i32) [concrete]
  96. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.831: %Class.as.Destroy.impl.Op.type.ce6 = struct_value () [concrete]
  97. // CHECK:STDOUT: %ptr.f7c: type = ptr_type %Class.247 [concrete]
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: imports {
  101. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  102. // CHECK:STDOUT: .Destroy = %Core.Destroy
  103. // CHECK:STDOUT: .Copy = %Core.Copy
  104. // CHECK:STDOUT: .Int = %Core.Int
  105. // CHECK:STDOUT: import Core//prelude
  106. // CHECK:STDOUT: import Core//prelude/...
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  109. // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
  110. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  111. // CHECK:STDOUT: %Core.import_ref.b3c: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.857) = import_ref Core//prelude/parts/int, loc17_31, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.6aa)]
  112. // CHECK:STDOUT: %Copy.impl_witness_table.f59 = impl_witness_table (%Core.import_ref.b3c), @Int.as.Copy.impl [concrete]
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: file {
  116. // CHECK:STDOUT: %InitFromStructGeneric.decl: %InitFromStructGeneric.type = fn_decl @InitFromStructGeneric [concrete = constants.%InitFromStructGeneric] {
  117. // CHECK:STDOUT: %T.patt: %pattern_type.ce2 = symbolic_binding_pattern T, 0 [concrete]
  118. // CHECK:STDOUT: %x.patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.f8cebc.1) = binding_pattern x [concrete]
  119. // CHECK:STDOUT: %x.param_patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.f8cebc.1) = value_param_pattern %x.patt, call_param0 [concrete]
  120. // CHECK:STDOUT: %return.patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.f8cebc.1) = return_slot_pattern [concrete]
  121. // CHECK:STDOUT: %return.param_patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.f8cebc.1) = out_param_pattern %return.patt, call_param1 [concrete]
  122. // CHECK:STDOUT: } {
  123. // CHECK:STDOUT: %T.ref.loc9_50: %Copy.type = name_ref T, %T.loc9_26.2 [symbolic = %T.loc9_26.1 (constants.%T.578)]
  124. // CHECK:STDOUT: %T.as_type.loc9_50: type = facet_access_type %T.ref.loc9_50 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)]
  125. // CHECK:STDOUT: %.loc9_50: type = converted %T.ref.loc9_50, %T.as_type.loc9_50 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)]
  126. // CHECK:STDOUT: %.loc9_34: type = splice_block %Copy.ref [concrete = constants.%Copy.type] {
  127. // CHECK:STDOUT: <elided>
  128. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  129. // CHECK:STDOUT: %Copy.ref: type = name_ref Copy, imports.%Core.Copy [concrete = constants.%Copy.type]
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %T.loc9_26.2: %Copy.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_26.1 (constants.%T.578)]
  132. // CHECK:STDOUT: %x.param: @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = value_param call_param0
  133. // CHECK:STDOUT: %.loc9_44.1: type = splice_block %.loc9_44.2 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)] {
  134. // CHECK:STDOUT: %T.ref.loc9_44: %Copy.type = name_ref T, %T.loc9_26.2 [symbolic = %T.loc9_26.1 (constants.%T.578)]
  135. // CHECK:STDOUT: %T.as_type.loc9_44.2: type = facet_access_type %T.ref.loc9_44 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)]
  136. // CHECK:STDOUT: %.loc9_44.2: type = converted %T.ref.loc9_44, %T.as_type.loc9_44.2 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: %x: @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = bind_name x, %x.param
  139. // CHECK:STDOUT: %return.param: ref @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = out_param call_param1
  140. // CHECK:STDOUT: %return: ref @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = return_slot %return.param
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %InitFromStructSpecific.decl: %InitFromStructSpecific.type = fn_decl @InitFromStructSpecific [concrete = constants.%InitFromStructSpecific] {
  143. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = binding_pattern x [concrete]
  144. // CHECK:STDOUT: %x.param_patt: %pattern_type.7ce = value_param_pattern %x.patt, call_param0 [concrete]
  145. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  146. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  147. // CHECK:STDOUT: } {
  148. // CHECK:STDOUT: %int_32.loc14_38: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  149. // CHECK:STDOUT: %i32.loc14_38: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  150. // CHECK:STDOUT: %x.param: %i32 = value_param call_param0
  151. // CHECK:STDOUT: %.loc14: type = splice_block %i32.loc14_30 [concrete = constants.%i32] {
  152. // CHECK:STDOUT: %int_32.loc14_30: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  153. // CHECK:STDOUT: %i32.loc14_30: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: %x: %i32 = bind_name x, %x.param
  156. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  157. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: generic fn @InitFromStructGeneric(%T.loc9_26.2: %Copy.type) {
  162. // CHECK:STDOUT: %T.loc9_26.1: %Copy.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_26.1 (constants.%T.578)]
  163. // CHECK:STDOUT: %T.as_type.loc9_44.1: type = facet_access_type %T.loc9_26.1 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)]
  164. // CHECK:STDOUT: %pattern_type.loc9: type = pattern_type %T.as_type.loc9_44.1 [symbolic = %pattern_type.loc9 (constants.%pattern_type.f8cebc.1)]
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: !definition:
  167. // CHECK:STDOUT: %require_complete.loc9: <witness> = require_complete_type %T.as_type.loc9_44.1 [symbolic = %require_complete.loc9 (constants.%require_complete.ecc)]
  168. // CHECK:STDOUT: %Class.loc10_17.2: type = class_type @Class, @Class(%T.as_type.loc9_44.1) [symbolic = %Class.loc10_17.2 (constants.%Class.b1d)]
  169. // CHECK:STDOUT: %require_complete.loc10_17: <witness> = require_complete_type %Class.loc10_17.2 [symbolic = %require_complete.loc10_17 (constants.%require_complete.57f)]
  170. // CHECK:STDOUT: %pattern_type.loc10: type = pattern_type %Class.loc10_17.2 [symbolic = %pattern_type.loc10 (constants.%pattern_type.a8f)]
  171. // CHECK:STDOUT: %struct_type.k: type = struct_type {.k: @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type)} [symbolic = %struct_type.k (constants.%struct_type.k.c03)]
  172. // CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc9_26.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.3ba)]
  173. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %T.as_type.loc9_44.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet (constants.%Copy.facet.72e)]
  174. // CHECK:STDOUT: %.loc10_27.2: type = fn_type_with_self_type constants.%Copy.Op.type, %Copy.facet [symbolic = %.loc10_27.2 (constants.%.671)]
  175. // CHECK:STDOUT: %impl.elem0.loc10_27.2: @InitFromStructGeneric.%.loc10_27.2 (%.671) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.56e)]
  176. // CHECK:STDOUT: %specific_impl_fn.loc10_27.2: <specific function> = specific_impl_function %impl.elem0.loc10_27.2, @Copy.Op(%Copy.facet) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.fb7)]
  177. // CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class.loc10_17.2, %T.as_type.loc9_44.1 [symbolic = %Class.elem (constants.%Class.elem.73a)]
  178. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness @Class.%Destroy.impl_witness_table, @Class.as.Destroy.impl(%T.as_type.loc9_44.1) [symbolic = %Destroy.impl_witness (constants.%Destroy.impl_witness.492)]
  179. // CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %Class.loc10_17.2, (%Destroy.impl_witness) [symbolic = %Destroy.facet (constants.%Destroy.facet.744)]
  180. // CHECK:STDOUT: %.loc10_3.2: type = fn_type_with_self_type constants.%Destroy.Op.type, %Destroy.facet [symbolic = %.loc10_3.2 (constants.%.c08)]
  181. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.type: type = fn_type @Class.as.Destroy.impl.Op, @Class.as.Destroy.impl(%T.as_type.loc9_44.1) [symbolic = %Class.as.Destroy.impl.Op.type (constants.%Class.as.Destroy.impl.Op.type.637)]
  182. // CHECK:STDOUT: %Class.as.Destroy.impl.Op: @InitFromStructGeneric.%Class.as.Destroy.impl.Op.type (%Class.as.Destroy.impl.Op.type.637) = struct_value () [symbolic = %Class.as.Destroy.impl.Op (constants.%Class.as.Destroy.impl.Op.598)]
  183. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %Class.as.Destroy.impl.Op, @Class.as.Destroy.impl.Op(%T.as_type.loc9_44.1) [symbolic = %Class.as.Destroy.impl.Op.specific_fn (constants.%Class.as.Destroy.impl.Op.specific_fn.df2)]
  184. // CHECK:STDOUT: %ptr: type = ptr_type %Class.loc10_17.2 [symbolic = %ptr (constants.%ptr.458)]
  185. // CHECK:STDOUT: %require_complete.loc10_3: <witness> = require_complete_type %ptr [symbolic = %require_complete.loc10_3 (constants.%require_complete.ec5)]
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: fn(%x.param: @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type)) -> @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) {
  188. // CHECK:STDOUT: !entry:
  189. // CHECK:STDOUT: name_binding_decl {
  190. // CHECK:STDOUT: %v.patt: @InitFromStructGeneric.%pattern_type.loc10 (%pattern_type.a8f) = binding_pattern v [concrete]
  191. // CHECK:STDOUT: %v.var_patt: @InitFromStructGeneric.%pattern_type.loc10 (%pattern_type.a8f) = var_pattern %v.patt [concrete]
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT: %v.var: ref @InitFromStructGeneric.%Class.loc10_17.2 (%Class.b1d) = var %v.var_patt
  194. // CHECK:STDOUT: %x.ref: @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = name_ref x, %x
  195. // CHECK:STDOUT: %.loc10_28.1: @InitFromStructGeneric.%struct_type.k (%struct_type.k.c03) = struct_literal (%x.ref)
  196. // CHECK:STDOUT: %impl.elem0.loc10_27.1: @InitFromStructGeneric.%.loc10_27.2 (%.671) = impl_witness_access constants.%Copy.lookup_impl_witness.3ba, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.56e)]
  197. // CHECK:STDOUT: %bound_method.loc10_27.1: <bound method> = bound_method %x.ref, %impl.elem0.loc10_27.1
  198. // CHECK:STDOUT: %specific_impl_fn.loc10_27.1: <specific function> = specific_impl_function %impl.elem0.loc10_27.1, @Copy.Op(constants.%Copy.facet.72e) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.fb7)]
  199. // CHECK:STDOUT: %bound_method.loc10_27.2: <bound method> = bound_method %x.ref, %specific_impl_fn.loc10_27.1
  200. // CHECK:STDOUT: %.loc10_27.1: init @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = call %bound_method.loc10_27.2(%x.ref)
  201. // CHECK:STDOUT: %.loc10_28.2: ref @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = class_element_access %v.var, element0
  202. // CHECK:STDOUT: %.loc10_28.3: init @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = initialize_from %.loc10_27.1 to %.loc10_28.2
  203. // CHECK:STDOUT: %.loc10_28.4: init @InitFromStructGeneric.%Class.loc10_17.2 (%Class.b1d) = class_init (%.loc10_28.3), %v.var
  204. // CHECK:STDOUT: %.loc10_3.1: init @InitFromStructGeneric.%Class.loc10_17.2 (%Class.b1d) = converted %.loc10_28.1, %.loc10_28.4
  205. // CHECK:STDOUT: assign %v.var, %.loc10_3.1
  206. // CHECK:STDOUT: %.loc10_17.1: type = splice_block %Class.loc10_17.1 [symbolic = %Class.loc10_17.2 (constants.%Class.b1d)] {
  207. // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
  208. // CHECK:STDOUT: %T.ref.loc10: %Copy.type = name_ref T, %T.loc9_26.2 [symbolic = %T.loc9_26.1 (constants.%T.578)]
  209. // CHECK:STDOUT: %T.as_type.loc10: type = facet_access_type %T.ref.loc10 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)]
  210. // CHECK:STDOUT: %.loc10_17.2: type = converted %T.ref.loc10, %T.as_type.loc10 [symbolic = %T.as_type.loc9_44.1 (constants.%T.as_type)]
  211. // CHECK:STDOUT: %Class.loc10_17.1: type = class_type @Class, @Class(constants.%T.as_type) [symbolic = %Class.loc10_17.2 (constants.%Class.b1d)]
  212. // CHECK:STDOUT: }
  213. // CHECK:STDOUT: %v: ref @InitFromStructGeneric.%Class.loc10_17.2 (%Class.b1d) = bind_name v, %v.var
  214. // CHECK:STDOUT: %v.ref: ref @InitFromStructGeneric.%Class.loc10_17.2 (%Class.b1d) = name_ref v, %v
  215. // CHECK:STDOUT: %k.ref: @InitFromStructGeneric.%Class.elem (%Class.elem.73a) = name_ref k, @Class.%.loc5 [concrete = @Class.%.loc5]
  216. // CHECK:STDOUT: %.loc11_11.1: ref @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = class_element_access %v.ref, element0
  217. // CHECK:STDOUT: %.loc11_11.2: @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = bind_value %.loc11_11.1
  218. // CHECK:STDOUT: %impl.elem0.loc11: @InitFromStructGeneric.%.loc10_27.2 (%.671) = impl_witness_access constants.%Copy.lookup_impl_witness.3ba, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.56e)]
  219. // CHECK:STDOUT: %bound_method.loc11_11.1: <bound method> = bound_method %.loc11_11.2, %impl.elem0.loc11
  220. // CHECK:STDOUT: %specific_impl_fn.loc11: <specific function> = specific_impl_function %impl.elem0.loc11, @Copy.Op(constants.%Copy.facet.72e) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.fb7)]
  221. // CHECK:STDOUT: %bound_method.loc11_11.2: <bound method> = bound_method %.loc11_11.2, %specific_impl_fn.loc11
  222. // CHECK:STDOUT: %.loc11_11.3: init @InitFromStructGeneric.%T.as_type.loc9_44.1 (%T.as_type) = call %bound_method.loc11_11.2(%.loc11_11.2)
  223. // CHECK:STDOUT: %impl.elem0.loc10_3: @InitFromStructGeneric.%.loc10_3.2 (%.c08) = impl_witness_access constants.%Destroy.impl_witness.492, element0 [symbolic = %Class.as.Destroy.impl.Op (constants.%Class.as.Destroy.impl.Op.598)]
  224. // CHECK:STDOUT: %bound_method.loc10_3.1: <bound method> = bound_method %v.var, %impl.elem0.loc10_3
  225. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0.loc10_3, @Class.as.Destroy.impl.Op(constants.%T.as_type) [symbolic = %Class.as.Destroy.impl.Op.specific_fn (constants.%Class.as.Destroy.impl.Op.specific_fn.df2)]
  226. // CHECK:STDOUT: %bound_method.loc10_3.2: <bound method> = bound_method %v.var, %specific_fn
  227. // CHECK:STDOUT: %addr: @InitFromStructGeneric.%ptr (%ptr.458) = addr_of %v.var
  228. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method.loc10_3.2(%addr)
  229. // CHECK:STDOUT: return %.loc11_11.3 to %return
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: fn @InitFromStructSpecific(%x.param: %i32) -> %i32 {
  234. // CHECK:STDOUT: !entry:
  235. // CHECK:STDOUT: name_binding_decl {
  236. // CHECK:STDOUT: %v.patt: %pattern_type.0fa = binding_pattern v [concrete]
  237. // CHECK:STDOUT: %v.var_patt: %pattern_type.0fa = var_pattern %v.patt [concrete]
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT: %v.var: ref %Class.247 = var %v.var_patt
  240. // CHECK:STDOUT: %x.ref: %i32 = name_ref x, %x
  241. // CHECK:STDOUT: %.loc15_30.1: %struct_type.k.0bf = struct_literal (%x.ref)
  242. // CHECK:STDOUT: %impl.elem0.loc15: %.3c4 = impl_witness_access constants.%Copy.impl_witness.f0b, element0 [concrete = constants.%Int.as.Copy.impl.Op.87e]
  243. // CHECK:STDOUT: %bound_method.loc15_29.1: <bound method> = bound_method %x.ref, %impl.elem0.loc15
  244. // CHECK:STDOUT: %specific_fn.loc15: <specific function> = specific_function %impl.elem0.loc15, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  245. // CHECK:STDOUT: %bound_method.loc15_29.2: <bound method> = bound_method %x.ref, %specific_fn.loc15
  246. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc15: init %i32 = call %bound_method.loc15_29.2(%x.ref)
  247. // CHECK:STDOUT: %.loc15_30.2: ref %i32 = class_element_access %v.var, element0
  248. // CHECK:STDOUT: %.loc15_30.3: init %i32 = initialize_from %Int.as.Copy.impl.Op.call.loc15 to %.loc15_30.2
  249. // CHECK:STDOUT: %.loc15_30.4: init %Class.247 = class_init (%.loc15_30.3), %v.var
  250. // CHECK:STDOUT: %.loc15_3: init %Class.247 = converted %.loc15_30.1, %.loc15_30.4
  251. // CHECK:STDOUT: assign %v.var, %.loc15_3
  252. // CHECK:STDOUT: %.loc15_19: type = splice_block %Class [concrete = constants.%Class.247] {
  253. // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
  254. // CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  255. // CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  256. // CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%i32) [concrete = constants.%Class.247]
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT: %v: ref %Class.247 = bind_name v, %v.var
  259. // CHECK:STDOUT: %v.ref: ref %Class.247 = name_ref v, %v
  260. // CHECK:STDOUT: %k.ref: %Class.elem.2d8 = name_ref k, @Class.%.loc5 [concrete = @Class.%.loc5]
  261. // CHECK:STDOUT: %.loc16_11.1: ref %i32 = class_element_access %v.ref, element0
  262. // CHECK:STDOUT: %.loc16_11.2: %i32 = bind_value %.loc16_11.1
  263. // CHECK:STDOUT: %impl.elem0.loc16: %.3c4 = impl_witness_access constants.%Copy.impl_witness.f0b, element0 [concrete = constants.%Int.as.Copy.impl.Op.87e]
  264. // CHECK:STDOUT: %bound_method.loc16_11.1: <bound method> = bound_method %.loc16_11.2, %impl.elem0.loc16
  265. // CHECK:STDOUT: %specific_fn.loc16: <specific function> = specific_function %impl.elem0.loc16, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  266. // CHECK:STDOUT: %bound_method.loc16_11.2: <bound method> = bound_method %.loc16_11.2, %specific_fn.loc16
  267. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc16: init %i32 = call %bound_method.loc16_11.2(%.loc16_11.2)
  268. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.bound: <bound method> = bound_method %v.var, constants.%Class.as.Destroy.impl.Op.831
  269. // CHECK:STDOUT: <elided>
  270. // CHECK:STDOUT: %bound_method.loc15_3: <bound method> = bound_method %v.var, %Class.as.Destroy.impl.Op.specific_fn
  271. // CHECK:STDOUT: %addr: %ptr.f7c = addr_of %v.var
  272. // CHECK:STDOUT: %Class.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method.loc15_3(%addr)
  273. // CHECK:STDOUT: return %Int.as.Copy.impl.Op.call.loc16 to %return
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: specific @InitFromStructGeneric(constants.%T.578) {
  277. // CHECK:STDOUT: %T.loc9_26.1 => constants.%T.578
  278. // CHECK:STDOUT: %T.as_type.loc9_44.1 => constants.%T.as_type
  279. // CHECK:STDOUT: %pattern_type.loc9 => constants.%pattern_type.f8cebc.1
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: --- adapt.carbon
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: constants {
  285. // CHECK:STDOUT: %Adapt.type: type = generic_class_type @Adapt [concrete]
  286. // CHECK:STDOUT: %Adapt.generic: %Adapt.type = struct_value () [concrete]
  287. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  288. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  289. // CHECK:STDOUT: %T.578: %Copy.type = bind_symbolic_name T, 0 [symbolic]
  290. // CHECK:STDOUT: %pattern_type.ce2: type = pattern_type %Copy.type [concrete]
  291. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T.578 [symbolic]
  292. // CHECK:STDOUT: %pattern_type.f8cebc.1: type = pattern_type %T.as_type [symbolic]
  293. // CHECK:STDOUT: %InitFromAdaptedGeneric.type: type = fn_type @InitFromAdaptedGeneric [concrete]
  294. // CHECK:STDOUT: %InitFromAdaptedGeneric: %InitFromAdaptedGeneric.type = struct_value () [concrete]
  295. // CHECK:STDOUT: %require_complete.ecc: <witness> = require_complete_type %T.as_type [symbolic]
  296. // CHECK:STDOUT: %Adapt.9d1: type = class_type @Adapt, @Adapt(%T.as_type) [symbolic]
  297. // CHECK:STDOUT: %require_complete.17e: <witness> = require_complete_type %Adapt.9d1 [symbolic]
  298. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  299. // CHECK:STDOUT: %Copy.lookup_impl_witness.3ba: <witness> = lookup_impl_witness %T.578, @Copy [symbolic]
  300. // CHECK:STDOUT: %Copy.facet.72e: %Copy.type = facet_value %T.as_type, (%Copy.lookup_impl_witness.3ba) [symbolic]
  301. // CHECK:STDOUT: %.671: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet.72e [symbolic]
  302. // CHECK:STDOUT: %impl.elem0.56e: %.671 = impl_witness_access %Copy.lookup_impl_witness.3ba, element0 [symbolic]
  303. // CHECK:STDOUT: %specific_impl_fn.fb7: <specific function> = specific_impl_function %impl.elem0.56e, @Copy.Op(%Copy.facet.72e) [symbolic]
  304. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  305. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  306. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  307. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic]
  308. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  309. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  310. // CHECK:STDOUT: %InitFromAdaptedSpecific.type: type = fn_type @InitFromAdaptedSpecific [concrete]
  311. // CHECK:STDOUT: %InitFromAdaptedSpecific: %InitFromAdaptedSpecific.type = struct_value () [concrete]
  312. // CHECK:STDOUT: %Adapt.526: type = class_type @Adapt, @Adapt(%i32) [concrete]
  313. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.857: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  314. // CHECK:STDOUT: %Int.as.Copy.impl.Op.6aa: %Int.as.Copy.impl.Op.type.857 = struct_value () [symbolic]
  315. // CHECK:STDOUT: %Copy.impl_witness.f0b: <witness> = impl_witness imports.%Copy.impl_witness_table.f59, @Int.as.Copy.impl(%int_32) [concrete]
  316. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.af5: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  317. // CHECK:STDOUT: %Int.as.Copy.impl.Op.87e: %Int.as.Copy.impl.Op.type.af5 = struct_value () [concrete]
  318. // CHECK:STDOUT: %Copy.facet.26d: %Copy.type = facet_value %i32, (%Copy.impl_witness.f0b) [concrete]
  319. // CHECK:STDOUT: %.3c4: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet.26d [concrete]
  320. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.87e, @Int.as.Copy.impl.Op(%int_32) [concrete]
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: imports {
  324. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  325. // CHECK:STDOUT: .Destroy = %Core.Destroy
  326. // CHECK:STDOUT: .Copy = %Core.Copy
  327. // CHECK:STDOUT: .Int = %Core.Int
  328. // CHECK:STDOUT: import Core//prelude
  329. // CHECK:STDOUT: import Core//prelude/...
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  332. // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
  333. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  334. // CHECK:STDOUT: %Core.import_ref.b3c: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.857) = import_ref Core//prelude/parts/int, loc17_31, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.6aa)]
  335. // CHECK:STDOUT: %Copy.impl_witness_table.f59 = impl_witness_table (%Core.import_ref.b3c), @Int.as.Copy.impl [concrete]
  336. // CHECK:STDOUT: }
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: file {
  339. // CHECK:STDOUT: %InitFromAdaptedGeneric.decl: %InitFromAdaptedGeneric.type = fn_decl @InitFromAdaptedGeneric [concrete = constants.%InitFromAdaptedGeneric] {
  340. // CHECK:STDOUT: %T.patt: %pattern_type.ce2 = symbolic_binding_pattern T, 0 [concrete]
  341. // CHECK:STDOUT: %x.patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.f8cebc.1) = binding_pattern x [concrete]
  342. // CHECK:STDOUT: %x.param_patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.f8cebc.1) = value_param_pattern %x.patt, call_param0 [concrete]
  343. // CHECK:STDOUT: %return.patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.f8cebc.1) = return_slot_pattern [concrete]
  344. // CHECK:STDOUT: %return.param_patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.f8cebc.1) = out_param_pattern %return.patt, call_param1 [concrete]
  345. // CHECK:STDOUT: } {
  346. // CHECK:STDOUT: %T.ref.loc9_51: %Copy.type = name_ref T, %T.loc9_27.2 [symbolic = %T.loc9_27.1 (constants.%T.578)]
  347. // CHECK:STDOUT: %T.as_type.loc9_51: type = facet_access_type %T.ref.loc9_51 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  348. // CHECK:STDOUT: %.loc9_51: type = converted %T.ref.loc9_51, %T.as_type.loc9_51 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  349. // CHECK:STDOUT: %.loc9_35: type = splice_block %Copy.ref [concrete = constants.%Copy.type] {
  350. // CHECK:STDOUT: <elided>
  351. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  352. // CHECK:STDOUT: %Copy.ref: type = name_ref Copy, imports.%Core.Copy [concrete = constants.%Copy.type]
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT: %T.loc9_27.2: %Copy.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_27.1 (constants.%T.578)]
  355. // CHECK:STDOUT: %x.param: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = value_param call_param0
  356. // CHECK:STDOUT: %.loc9_45.1: type = splice_block %.loc9_45.2 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)] {
  357. // CHECK:STDOUT: %T.ref.loc9_45: %Copy.type = name_ref T, %T.loc9_27.2 [symbolic = %T.loc9_27.1 (constants.%T.578)]
  358. // CHECK:STDOUT: %T.as_type.loc9_45.2: type = facet_access_type %T.ref.loc9_45 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  359. // CHECK:STDOUT: %.loc9_45.2: type = converted %T.ref.loc9_45, %T.as_type.loc9_45.2 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT: %x: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = bind_name x, %x.param
  362. // CHECK:STDOUT: %return.param: ref @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = out_param call_param1
  363. // CHECK:STDOUT: %return: ref @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = return_slot %return.param
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT: %InitFromAdaptedSpecific.decl: %InitFromAdaptedSpecific.type = fn_decl @InitFromAdaptedSpecific [concrete = constants.%InitFromAdaptedSpecific] {
  366. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = binding_pattern x [concrete]
  367. // CHECK:STDOUT: %x.param_patt: %pattern_type.7ce = value_param_pattern %x.patt, call_param0 [concrete]
  368. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  369. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  370. // CHECK:STDOUT: } {
  371. // CHECK:STDOUT: %int_32.loc13_39: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  372. // CHECK:STDOUT: %i32.loc13_39: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  373. // CHECK:STDOUT: %x.param: %i32 = value_param call_param0
  374. // CHECK:STDOUT: %.loc13: type = splice_block %i32.loc13_31 [concrete = constants.%i32] {
  375. // CHECK:STDOUT: %int_32.loc13_31: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  376. // CHECK:STDOUT: %i32.loc13_31: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT: %x: %i32 = bind_name x, %x.param
  379. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  380. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: generic fn @InitFromAdaptedGeneric(%T.loc9_27.2: %Copy.type) {
  385. // CHECK:STDOUT: %T.loc9_27.1: %Copy.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_27.1 (constants.%T.578)]
  386. // CHECK:STDOUT: %T.as_type.loc9_45.1: type = facet_access_type %T.loc9_27.1 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  387. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.as_type.loc9_45.1 [symbolic = %pattern_type (constants.%pattern_type.f8cebc.1)]
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: !definition:
  390. // CHECK:STDOUT: %require_complete.loc9: <witness> = require_complete_type %T.as_type.loc9_45.1 [symbolic = %require_complete.loc9 (constants.%require_complete.ecc)]
  391. // CHECK:STDOUT: %Adapt.loc10_23.2: type = class_type @Adapt, @Adapt(%T.as_type.loc9_45.1) [symbolic = %Adapt.loc10_23.2 (constants.%Adapt.9d1)]
  392. // CHECK:STDOUT: %require_complete.loc10: <witness> = require_complete_type %Adapt.loc10_23.2 [symbolic = %require_complete.loc10 (constants.%require_complete.17e)]
  393. // CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc9_27.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.3ba)]
  394. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %T.as_type.loc9_45.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet (constants.%Copy.facet.72e)]
  395. // CHECK:STDOUT: %.loc10_26.4: type = fn_type_with_self_type constants.%Copy.Op.type, %Copy.facet [symbolic = %.loc10_26.4 (constants.%.671)]
  396. // CHECK:STDOUT: %impl.elem0.loc10_26.2: @InitFromAdaptedGeneric.%.loc10_26.4 (%.671) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.56e)]
  397. // CHECK:STDOUT: %specific_impl_fn.loc10_26.2: <specific function> = specific_impl_function %impl.elem0.loc10_26.2, @Copy.Op(%Copy.facet) [symbolic = %specific_impl_fn.loc10_26.2 (constants.%specific_impl_fn.fb7)]
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: fn(%x.param: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type)) -> @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) {
  400. // CHECK:STDOUT: !entry:
  401. // CHECK:STDOUT: %x.ref: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = name_ref x, %x
  402. // CHECK:STDOUT: %Adapt.ref: %Adapt.type = name_ref Adapt, file.%Adapt.decl [concrete = constants.%Adapt.generic]
  403. // CHECK:STDOUT: %T.ref.loc10_22: %Copy.type = name_ref T, %T.loc9_27.2 [symbolic = %T.loc9_27.1 (constants.%T.578)]
  404. // CHECK:STDOUT: %T.as_type.loc10_23: type = facet_access_type %T.ref.loc10_22 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  405. // CHECK:STDOUT: %.loc10_23: type = converted %T.ref.loc10_22, %T.as_type.loc10_23 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  406. // CHECK:STDOUT: %Adapt.loc10_23.1: type = class_type @Adapt, @Adapt(constants.%T.as_type) [symbolic = %Adapt.loc10_23.2 (constants.%Adapt.9d1)]
  407. // CHECK:STDOUT: %.loc10_13.1: @InitFromAdaptedGeneric.%Adapt.loc10_23.2 (%Adapt.9d1) = as_compatible %x.ref
  408. // CHECK:STDOUT: %.loc10_13.2: @InitFromAdaptedGeneric.%Adapt.loc10_23.2 (%Adapt.9d1) = converted %x.ref, %.loc10_13.1
  409. // CHECK:STDOUT: %T.ref.loc10_29: %Copy.type = name_ref T, %T.loc9_27.2 [symbolic = %T.loc9_27.1 (constants.%T.578)]
  410. // CHECK:STDOUT: %T.as_type.loc10_29: type = facet_access_type %T.ref.loc10_29 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  411. // CHECK:STDOUT: %.loc10_29: type = converted %T.ref.loc10_29, %T.as_type.loc10_29 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  412. // CHECK:STDOUT: %.loc10_26.1: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = as_compatible %.loc10_13.2
  413. // CHECK:STDOUT: %.loc10_26.2: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = converted %.loc10_13.2, %.loc10_26.1
  414. // CHECK:STDOUT: %impl.elem0.loc10_26.1: @InitFromAdaptedGeneric.%.loc10_26.4 (%.671) = impl_witness_access constants.%Copy.lookup_impl_witness.3ba, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.56e)]
  415. // CHECK:STDOUT: %bound_method.loc10_26.1: <bound method> = bound_method %.loc10_26.2, %impl.elem0.loc10_26.1
  416. // CHECK:STDOUT: %specific_impl_fn.loc10_26.1: <specific function> = specific_impl_function %impl.elem0.loc10_26.1, @Copy.Op(constants.%Copy.facet.72e) [symbolic = %specific_impl_fn.loc10_26.2 (constants.%specific_impl_fn.fb7)]
  417. // CHECK:STDOUT: %bound_method.loc10_26.2: <bound method> = bound_method %.loc10_26.2, %specific_impl_fn.loc10_26.1
  418. // CHECK:STDOUT: %.loc10_26.3: init @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = call %bound_method.loc10_26.2(%.loc10_26.2)
  419. // CHECK:STDOUT: return %.loc10_26.3 to %return
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: fn @InitFromAdaptedSpecific(%x.param: %i32) -> %i32 {
  424. // CHECK:STDOUT: !entry:
  425. // CHECK:STDOUT: %x.ref: %i32 = name_ref x, %x
  426. // CHECK:STDOUT: %Adapt.ref: %Adapt.type = name_ref Adapt, file.%Adapt.decl [concrete = constants.%Adapt.generic]
  427. // CHECK:STDOUT: %int_32.loc14_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  428. // CHECK:STDOUT: %i32.loc14_22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  429. // CHECK:STDOUT: %Adapt: type = class_type @Adapt, @Adapt(constants.%i32) [concrete = constants.%Adapt.526]
  430. // CHECK:STDOUT: %.loc14_13.1: %Adapt.526 = as_compatible %x.ref
  431. // CHECK:STDOUT: %.loc14_13.2: %Adapt.526 = converted %x.ref, %.loc14_13.1
  432. // CHECK:STDOUT: %int_32.loc14_31: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  433. // CHECK:STDOUT: %i32.loc14_31: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  434. // CHECK:STDOUT: %.loc14_28.1: %i32 = as_compatible %.loc14_13.2
  435. // CHECK:STDOUT: %.loc14_28.2: %i32 = converted %.loc14_13.2, %.loc14_28.1
  436. // CHECK:STDOUT: %impl.elem0: %.3c4 = impl_witness_access constants.%Copy.impl_witness.f0b, element0 [concrete = constants.%Int.as.Copy.impl.Op.87e]
  437. // CHECK:STDOUT: %bound_method.loc14_28.1: <bound method> = bound_method %.loc14_28.2, %impl.elem0
  438. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  439. // CHECK:STDOUT: %bound_method.loc14_28.2: <bound method> = bound_method %.loc14_28.2, %specific_fn
  440. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc14_28.2(%.loc14_28.2)
  441. // CHECK:STDOUT: return %Int.as.Copy.impl.Op.call to %return
  442. // CHECK:STDOUT: }
  443. // CHECK:STDOUT:
  444. // CHECK:STDOUT: specific @InitFromAdaptedGeneric(constants.%T.578) {
  445. // CHECK:STDOUT: %T.loc9_27.1 => constants.%T.578
  446. // CHECK:STDOUT: %T.as_type.loc9_45.1 => constants.%T.as_type
  447. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.f8cebc.1
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT: