init.carbon 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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:! Core.Destroy) {
  15. var k: T;
  16. }
  17. //@dump-sem-ir-begin
  18. fn InitFromStructGeneric(T:! Core.Copy & Core.Destroy, 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: %empty_tuple.type: type = tuple_type () [concrete]
  44. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  45. // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [concrete]
  46. // CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [concrete]
  47. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  48. // CHECK:STDOUT: %BitAndWith.type.f2e: type = generic_interface_type @BitAndWith [concrete]
  49. // CHECK:STDOUT: %BitAndWith.generic: %BitAndWith.type.f2e = struct_value () [concrete]
  50. // CHECK:STDOUT: %BitAndWith.type.b10: type = facet_type <@BitAndWith, @BitAndWith(type)> [concrete]
  51. // CHECK:STDOUT: %BitAndWith.impl_witness: <witness> = impl_witness imports.%BitAndWith.impl_witness_table [concrete]
  52. // CHECK:STDOUT: %BitAndWith.facet: %BitAndWith.type.b10 = facet_value type, (%BitAndWith.impl_witness) [concrete]
  53. // CHECK:STDOUT: %BitAndWith.WithSelf.Op.type.4bd: type = fn_type @BitAndWith.WithSelf.Op, @BitAndWith.WithSelf(type, %BitAndWith.facet) [concrete]
  54. // CHECK:STDOUT: %.d15: type = fn_type_with_self_type %BitAndWith.WithSelf.Op.type.4bd, %BitAndWith.facet [concrete]
  55. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.type: type = fn_type @type.as.BitAndWith.impl.Op [concrete]
  56. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op: %type.as.BitAndWith.impl.Op.type = struct_value () [concrete]
  57. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.bound: <bound method> = bound_method %Copy.type, %type.as.BitAndWith.impl.Op [concrete]
  58. // CHECK:STDOUT: %facet_type: type = facet_type <@Destroy & @Copy> [concrete]
  59. // CHECK:STDOUT: %pattern_type.b13: type = pattern_type %facet_type [concrete]
  60. // CHECK:STDOUT: %T.65f: %facet_type = symbolic_binding T, 0 [symbolic]
  61. // CHECK:STDOUT: %T.as_type.db4: type = facet_access_type %T.65f [symbolic]
  62. // CHECK:STDOUT: %pattern_type.58d: type = pattern_type %T.as_type.db4 [symbolic]
  63. // CHECK:STDOUT: %.a57: Core.Form = init_form %T.as_type.db4 [symbolic]
  64. // CHECK:STDOUT: %InitFromStructGeneric.type: type = fn_type @InitFromStructGeneric [concrete]
  65. // CHECK:STDOUT: %InitFromStructGeneric: %InitFromStructGeneric.type = struct_value () [concrete]
  66. // CHECK:STDOUT: %require_complete.1e9: <witness> = require_complete_type %T.as_type.db4 [symbolic]
  67. // CHECK:STDOUT: %Destroy.lookup_impl_witness.84a: <witness> = lookup_impl_witness %T.65f, @Destroy [symbolic]
  68. // CHECK:STDOUT: %Destroy.facet.5e1: %Destroy.type = facet_value %T.as_type.db4, (%Destroy.lookup_impl_witness.84a) [symbolic]
  69. // CHECK:STDOUT: %Class.46c: type = class_type @Class, @Class(%Destroy.facet.5e1) [symbolic]
  70. // CHECK:STDOUT: %Class.elem.ef9: type = unbound_element_type %Class.46c, %T.as_type.db4 [symbolic]
  71. // CHECK:STDOUT: %struct_type.k.92f: type = struct_type {.k: %T.as_type.db4} [symbolic]
  72. // CHECK:STDOUT: %require_complete.c1b: <witness> = require_complete_type %Class.46c [symbolic]
  73. // CHECK:STDOUT: %pattern_type.ebf: type = pattern_type %Class.46c [symbolic]
  74. // CHECK:STDOUT: %Copy.lookup_impl_witness.322: <witness> = lookup_impl_witness %T.65f, @Copy [symbolic]
  75. // CHECK:STDOUT: %Copy.facet.856: %Copy.type = facet_value %T.as_type.db4, (%Copy.lookup_impl_witness.322) [symbolic]
  76. // CHECK:STDOUT: %Copy.WithSelf.Op.type.5d5: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.856) [symbolic]
  77. // CHECK:STDOUT: %.e56: type = fn_type_with_self_type %Copy.WithSelf.Op.type.5d5, %Copy.facet.856 [symbolic]
  78. // CHECK:STDOUT: %impl.elem0.bab: %.e56 = impl_witness_access %Copy.lookup_impl_witness.322, element0 [symbolic]
  79. // CHECK:STDOUT: %specific_impl_fn.421: <specific function> = specific_impl_function %impl.elem0.bab, @Copy.WithSelf.Op(%Copy.facet.856) [symbolic]
  80. // CHECK:STDOUT: %Destroy.lookup_impl_witness.488: <witness> = lookup_impl_witness %Class.46c, @Destroy [symbolic]
  81. // CHECK:STDOUT: %Destroy.facet.474: %Destroy.type = facet_value %Class.46c, (%Destroy.lookup_impl_witness.488) [symbolic]
  82. // CHECK:STDOUT: %Destroy.WithSelf.Op.type.f65: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.474) [symbolic]
  83. // CHECK:STDOUT: %.1fe: type = fn_type_with_self_type %Destroy.WithSelf.Op.type.f65, %Destroy.facet.474 [symbolic]
  84. // CHECK:STDOUT: %impl.elem0.ae3: %.1fe = impl_witness_access %Destroy.lookup_impl_witness.488, element0 [symbolic]
  85. // CHECK:STDOUT: %specific_impl_fn.4b3: <specific function> = specific_impl_function %impl.elem0.ae3, @Destroy.WithSelf.Op(%Destroy.facet.474) [symbolic]
  86. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  87. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  88. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  89. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  90. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  91. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  92. // CHECK:STDOUT: %.ff5: Core.Form = init_form %i32 [concrete]
  93. // CHECK:STDOUT: %InitFromStructSpecific.type: type = fn_type @InitFromStructSpecific [concrete]
  94. // CHECK:STDOUT: %InitFromStructSpecific: %InitFromStructSpecific.type = struct_value () [concrete]
  95. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  96. // CHECK:STDOUT: %Destroy.Op.type.bae255.2: type = fn_type @Destroy.Op.loc15_19.2 [concrete]
  97. // CHECK:STDOUT: %Destroy.Op.651ba6.2: %Destroy.Op.type.bae255.2 = struct_value () [concrete]
  98. // CHECK:STDOUT: %custom_witness.8d7fae.2: <witness> = custom_witness (%Destroy.Op.651ba6.2), @Destroy [concrete]
  99. // CHECK:STDOUT: %Destroy.facet.0fd: %Destroy.type = facet_value %i32, (%custom_witness.8d7fae.2) [concrete]
  100. // CHECK:STDOUT: %Class.02d: type = class_type @Class, @Class(%Destroy.facet.0fd) [concrete]
  101. // CHECK:STDOUT: %Class.elem.2a7: type = unbound_element_type %Class.02d, %i32 [concrete]
  102. // CHECK:STDOUT: %struct_type.k.0bf: type = struct_type {.k: %i32} [concrete]
  103. // CHECK:STDOUT: %pattern_type.f2b: type = pattern_type %Class.02d [concrete]
  104. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.824: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  105. // CHECK:STDOUT: %Int.as.Copy.impl.Op.9b9: %Int.as.Copy.impl.Op.type.824 = struct_value () [symbolic]
  106. // CHECK:STDOUT: %Copy.impl_witness.f17: <witness> = impl_witness imports.%Copy.impl_witness_table.e76, @Int.as.Copy.impl(%int_32) [concrete]
  107. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.546: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  108. // CHECK:STDOUT: %Int.as.Copy.impl.Op.664: %Int.as.Copy.impl.Op.type.546 = struct_value () [concrete]
  109. // CHECK:STDOUT: %Copy.facet.de4: %Copy.type = facet_value %i32, (%Copy.impl_witness.f17) [concrete]
  110. // CHECK:STDOUT: %Copy.WithSelf.Op.type.081: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.de4) [concrete]
  111. // CHECK:STDOUT: %.8e2: type = fn_type_with_self_type %Copy.WithSelf.Op.type.081, %Copy.facet.de4 [concrete]
  112. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.664, @Int.as.Copy.impl.Op(%int_32) [concrete]
  113. // CHECK:STDOUT: %Destroy.Op.type.bae255.4: type = fn_type @Destroy.Op.loc15_3.2 [concrete]
  114. // CHECK:STDOUT: %Destroy.Op.651ba6.4: %Destroy.Op.type.bae255.4 = struct_value () [concrete]
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: imports {
  118. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  119. // CHECK:STDOUT: .Destroy = %Core.Destroy
  120. // CHECK:STDOUT: .Copy = %Core.Copy
  121. // CHECK:STDOUT: .BitAndWith = %Core.BitAndWith
  122. // CHECK:STDOUT: .Int = %Core.Int
  123. // CHECK:STDOUT: import Core//prelude
  124. // CHECK:STDOUT: import Core//prelude/...
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  127. // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
  128. // CHECK:STDOUT: %Core.BitAndWith: %BitAndWith.type.f2e = import_ref Core//prelude/parts/as, BitAndWith, loaded [concrete = constants.%BitAndWith.generic]
  129. // CHECK:STDOUT: %Core.import_ref.8d3: %type.as.BitAndWith.impl.Op.type = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, loaded [concrete = constants.%type.as.BitAndWith.impl.Op]
  130. // CHECK:STDOUT: %BitAndWith.impl_witness_table = impl_witness_table (%Core.import_ref.8d3), @type.as.BitAndWith.impl [concrete]
  131. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  132. // CHECK:STDOUT: %Core.import_ref.18d: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.824) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.9b9)]
  133. // CHECK:STDOUT: %Copy.impl_witness_table.e76 = impl_witness_table (%Core.import_ref.18d), @Int.as.Copy.impl [concrete]
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: file {
  137. // CHECK:STDOUT: %InitFromStructGeneric.decl: %InitFromStructGeneric.type = fn_decl @InitFromStructGeneric [concrete = constants.%InitFromStructGeneric] {
  138. // CHECK:STDOUT: %T.patt: %pattern_type.b13 = symbolic_binding_pattern T, 0 [concrete]
  139. // CHECK:STDOUT: %x.param_patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.58d) = value_param_pattern [concrete]
  140. // CHECK:STDOUT: %x.patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.58d) = at_binding_pattern x, %x.param_patt [concrete]
  141. // CHECK:STDOUT: %return.param_patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.58d) = out_param_pattern [concrete]
  142. // CHECK:STDOUT: %return.patt: @InitFromStructGeneric.%pattern_type.loc9 (%pattern_type.58d) = return_slot_pattern %return.param_patt, %.loc9_65.3 [concrete]
  143. // CHECK:STDOUT: } {
  144. // CHECK:STDOUT: %T.ref.loc9_65: %facet_type = name_ref T, %T.loc9_27.2 [symbolic = %T.loc9_27.1 (constants.%T.65f)]
  145. // CHECK:STDOUT: %T.as_type.loc9_65: type = facet_access_type %T.ref.loc9_65 [symbolic = %T.as_type.loc9_59.1 (constants.%T.as_type.db4)]
  146. // CHECK:STDOUT: %.loc9_65.3: type = converted %T.ref.loc9_65, %T.as_type.loc9_65 [symbolic = %T.as_type.loc9_59.1 (constants.%T.as_type.db4)]
  147. // CHECK:STDOUT: %.loc9_65.4: Core.Form = init_form %.loc9_65.3 [symbolic = %.loc9_65.2 (constants.%.a57)]
  148. // CHECK:STDOUT: %.loc9_40.1: type = splice_block %.loc9_40.3 [concrete = constants.%facet_type] {
  149. // CHECK:STDOUT: <elided>
  150. // CHECK:STDOUT: %Core.ref.loc9_30: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  151. // CHECK:STDOUT: %Copy.ref: type = name_ref Copy, imports.%Core.Copy [concrete = constants.%Copy.type]
  152. // CHECK:STDOUT: %Core.ref.loc9_42: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  153. // CHECK:STDOUT: %Destroy.ref: type = name_ref Destroy, imports.%Core.Destroy [concrete = constants.%Destroy.type]
  154. // CHECK:STDOUT: %impl.elem0.loc9: %.d15 = impl_witness_access constants.%BitAndWith.impl_witness, element0 [concrete = constants.%type.as.BitAndWith.impl.Op]
  155. // CHECK:STDOUT: %bound_method.loc9: <bound method> = bound_method %Copy.ref, %impl.elem0.loc9 [concrete = constants.%type.as.BitAndWith.impl.Op.bound]
  156. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.call: init type = call %bound_method.loc9(%Copy.ref, %Destroy.ref) [concrete = constants.%facet_type]
  157. // CHECK:STDOUT: %.loc9_40.2: type = value_of_initializer %type.as.BitAndWith.impl.Op.call [concrete = constants.%facet_type]
  158. // CHECK:STDOUT: %.loc9_40.3: type = converted %type.as.BitAndWith.impl.Op.call, %.loc9_40.2 [concrete = constants.%facet_type]
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT: %T.loc9_27.2: %facet_type = symbolic_binding T, 0 [symbolic = %T.loc9_27.1 (constants.%T.65f)]
  161. // CHECK:STDOUT: %x.param: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = value_param call_param0
  162. // CHECK:STDOUT: %.loc9_59.1: type = splice_block %.loc9_59.2 [symbolic = %T.as_type.loc9_59.1 (constants.%T.as_type.db4)] {
  163. // CHECK:STDOUT: %T.ref.loc9_59: %facet_type = name_ref T, %T.loc9_27.2 [symbolic = %T.loc9_27.1 (constants.%T.65f)]
  164. // CHECK:STDOUT: %T.as_type.loc9_59.2: type = facet_access_type %T.ref.loc9_59 [symbolic = %T.as_type.loc9_59.1 (constants.%T.as_type.db4)]
  165. // CHECK:STDOUT: %.loc9_59.2: type = converted %T.ref.loc9_59, %T.as_type.loc9_59.2 [symbolic = %T.as_type.loc9_59.1 (constants.%T.as_type.db4)]
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT: %x: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = value_binding x, %x.param
  168. // CHECK:STDOUT: %return.param: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = out_param call_param1
  169. // CHECK:STDOUT: %return: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = return_slot %return.param
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: %InitFromStructSpecific.decl: %InitFromStructSpecific.type = fn_decl @InitFromStructSpecific [concrete = constants.%InitFromStructSpecific] {
  172. // CHECK:STDOUT: %x.param_patt: %pattern_type.7ce = value_param_pattern [concrete]
  173. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = at_binding_pattern x, %x.param_patt [concrete]
  174. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern [concrete]
  175. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern %return.param_patt, %i32.loc14_38 [concrete]
  176. // CHECK:STDOUT: } {
  177. // CHECK:STDOUT: %i32.loc14_38: type = type_literal constants.%i32 [concrete = constants.%i32]
  178. // CHECK:STDOUT: %.loc14: Core.Form = init_form %i32.loc14_38 [concrete = constants.%.ff5]
  179. // CHECK:STDOUT: %x.param: %i32 = value_param call_param0
  180. // CHECK:STDOUT: %i32.loc14_30: type = type_literal constants.%i32 [concrete = constants.%i32]
  181. // CHECK:STDOUT: %x: %i32 = value_binding x, %x.param
  182. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  183. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: generic fn @InitFromStructGeneric(%T.loc9_27.2: %facet_type) {
  188. // CHECK:STDOUT: %T.loc9_27.1: %facet_type = symbolic_binding T, 0 [symbolic = %T.loc9_27.1 (constants.%T.65f)]
  189. // CHECK:STDOUT: %T.as_type.loc9_59.1: type = facet_access_type %T.loc9_27.1 [symbolic = %T.as_type.loc9_59.1 (constants.%T.as_type.db4)]
  190. // CHECK:STDOUT: %pattern_type.loc9: type = pattern_type %T.as_type.loc9_59.1 [symbolic = %pattern_type.loc9 (constants.%pattern_type.58d)]
  191. // CHECK:STDOUT: %.loc9_65.2: Core.Form = init_form %T.as_type.loc9_59.1 [symbolic = %.loc9_65.2 (constants.%.a57)]
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: !definition:
  194. // CHECK:STDOUT: %require_complete.loc9: <witness> = require_complete_type %T.as_type.loc9_59.1 [symbolic = %require_complete.loc9 (constants.%require_complete.1e9)]
  195. // CHECK:STDOUT: %Destroy.lookup_impl_witness.loc10_17: <witness> = lookup_impl_witness %T.loc9_27.1, @Destroy [symbolic = %Destroy.lookup_impl_witness.loc10_17 (constants.%Destroy.lookup_impl_witness.84a)]
  196. // CHECK:STDOUT: %Destroy.facet.loc10_17.2: %Destroy.type = facet_value %T.as_type.loc9_59.1, (%Destroy.lookup_impl_witness.loc10_17) [symbolic = %Destroy.facet.loc10_17.2 (constants.%Destroy.facet.5e1)]
  197. // CHECK:STDOUT: %Class.loc10_17.2: type = class_type @Class, @Class(%Destroy.facet.loc10_17.2) [symbolic = %Class.loc10_17.2 (constants.%Class.46c)]
  198. // CHECK:STDOUT: %require_complete.loc10: <witness> = require_complete_type %Class.loc10_17.2 [symbolic = %require_complete.loc10 (constants.%require_complete.c1b)]
  199. // CHECK:STDOUT: %pattern_type.loc10: type = pattern_type %Class.loc10_17.2 [symbolic = %pattern_type.loc10 (constants.%pattern_type.ebf)]
  200. // CHECK:STDOUT: %struct_type.k: type = struct_type {.k: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4)} [symbolic = %struct_type.k (constants.%struct_type.k.92f)]
  201. // 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.322)]
  202. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %T.as_type.loc9_59.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet (constants.%Copy.facet.856)]
  203. // CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.5d5)]
  204. // CHECK:STDOUT: %.loc10_27: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet [symbolic = %.loc10_27 (constants.%.e56)]
  205. // CHECK:STDOUT: %impl.elem0.loc10_27.2: @InitFromStructGeneric.%.loc10_27 (%.e56) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.bab)]
  206. // CHECK:STDOUT: %specific_impl_fn.loc10_27.2: <specific function> = specific_impl_function %impl.elem0.loc10_27.2, @Copy.WithSelf.Op(%Copy.facet) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.421)]
  207. // CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class.loc10_17.2, %T.as_type.loc9_59.1 [symbolic = %Class.elem (constants.%Class.elem.ef9)]
  208. // CHECK:STDOUT: %Destroy.lookup_impl_witness.loc10_3: <witness> = lookup_impl_witness %Class.loc10_17.2, @Destroy [symbolic = %Destroy.lookup_impl_witness.loc10_3 (constants.%Destroy.lookup_impl_witness.488)]
  209. // CHECK:STDOUT: %Destroy.facet.loc10_3: %Destroy.type = facet_value %Class.loc10_17.2, (%Destroy.lookup_impl_witness.loc10_3) [symbolic = %Destroy.facet.loc10_3 (constants.%Destroy.facet.474)]
  210. // CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.loc10_3) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.f65)]
  211. // CHECK:STDOUT: %.loc10_3.2: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet.loc10_3 [symbolic = %.loc10_3.2 (constants.%.1fe)]
  212. // CHECK:STDOUT: %impl.elem0.loc10_3.2: @InitFromStructGeneric.%.loc10_3.2 (%.1fe) = impl_witness_access %Destroy.lookup_impl_witness.loc10_3, element0 [symbolic = %impl.elem0.loc10_3.2 (constants.%impl.elem0.ae3)]
  213. // CHECK:STDOUT: %specific_impl_fn.loc10_3.2: <specific function> = specific_impl_function %impl.elem0.loc10_3.2, @Destroy.WithSelf.Op(%Destroy.facet.loc10_3) [symbolic = %specific_impl_fn.loc10_3.2 (constants.%specific_impl_fn.4b3)]
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: fn(%x.param: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4)) -> out %return.param: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) {
  216. // CHECK:STDOUT: !entry:
  217. // CHECK:STDOUT: name_binding_decl {
  218. // CHECK:STDOUT: %v.patt: @InitFromStructGeneric.%pattern_type.loc10 (%pattern_type.ebf) = ref_binding_pattern v [concrete]
  219. // CHECK:STDOUT: %v.var_patt: @InitFromStructGeneric.%pattern_type.loc10 (%pattern_type.ebf) = var_pattern %v.patt [concrete]
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT: %v.var: ref @InitFromStructGeneric.%Class.loc10_17.2 (%Class.46c) = var %v.var_patt
  222. // CHECK:STDOUT: %x.ref: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = name_ref x, %x
  223. // CHECK:STDOUT: %.loc10_28.1: @InitFromStructGeneric.%struct_type.k (%struct_type.k.92f) = struct_literal (%x.ref)
  224. // CHECK:STDOUT: %impl.elem0.loc10_27.1: @InitFromStructGeneric.%.loc10_27 (%.e56) = impl_witness_access constants.%Copy.lookup_impl_witness.322, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.bab)]
  225. // CHECK:STDOUT: %bound_method.loc10_27.1: <bound method> = bound_method %x.ref, %impl.elem0.loc10_27.1
  226. // CHECK:STDOUT: %specific_impl_fn.loc10_27.1: <specific function> = specific_impl_function %impl.elem0.loc10_27.1, @Copy.WithSelf.Op(constants.%Copy.facet.856) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.421)]
  227. // CHECK:STDOUT: %bound_method.loc10_27.2: <bound method> = bound_method %x.ref, %specific_impl_fn.loc10_27.1
  228. // CHECK:STDOUT: %.loc10_28.2: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = class_element_access %v.var, element0
  229. // CHECK:STDOUT: %Copy.WithSelf.Op.call.loc10: init @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) to %.loc10_28.2 = call %bound_method.loc10_27.2(%x.ref)
  230. // CHECK:STDOUT: %.loc10_28.3: init @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) to %.loc10_28.2 = in_place_init %Copy.WithSelf.Op.call.loc10
  231. // CHECK:STDOUT: %.loc10_28.4: init @InitFromStructGeneric.%Class.loc10_17.2 (%Class.46c) to %v.var = class_init (%.loc10_28.3)
  232. // CHECK:STDOUT: %.loc10_3.1: init @InitFromStructGeneric.%Class.loc10_17.2 (%Class.46c) = converted %.loc10_28.1, %.loc10_28.4
  233. // CHECK:STDOUT: assign %v.var, %.loc10_3.1
  234. // CHECK:STDOUT: %.loc10_17.1: type = splice_block %Class.loc10_17.1 [symbolic = %Class.loc10_17.2 (constants.%Class.46c)] {
  235. // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
  236. // CHECK:STDOUT: %T.ref.loc10: %facet_type = name_ref T, %T.loc9_27.2 [symbolic = %T.loc9_27.1 (constants.%T.65f)]
  237. // CHECK:STDOUT: %T.as_type.loc10: type = facet_access_type %T.ref.loc10 [symbolic = %T.as_type.loc9_59.1 (constants.%T.as_type.db4)]
  238. // CHECK:STDOUT: %Destroy.facet.loc10_17.1: %Destroy.type = facet_value %T.as_type.loc10, (constants.%Destroy.lookup_impl_witness.84a) [symbolic = %Destroy.facet.loc10_17.2 (constants.%Destroy.facet.5e1)]
  239. // CHECK:STDOUT: %.loc10_17.2: %Destroy.type = converted %T.ref.loc10, %Destroy.facet.loc10_17.1 [symbolic = %Destroy.facet.loc10_17.2 (constants.%Destroy.facet.5e1)]
  240. // CHECK:STDOUT: %Class.loc10_17.1: type = class_type @Class, @Class(constants.%Destroy.facet.5e1) [symbolic = %Class.loc10_17.2 (constants.%Class.46c)]
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT: %v: ref @InitFromStructGeneric.%Class.loc10_17.2 (%Class.46c) = ref_binding v, %v.var
  243. // CHECK:STDOUT: %v.ref: ref @InitFromStructGeneric.%Class.loc10_17.2 (%Class.46c) = name_ref v, %v
  244. // CHECK:STDOUT: %k.ref: @InitFromStructGeneric.%Class.elem (%Class.elem.ef9) = name_ref k, @Class.%.loc5_8 [concrete = @Class.%.loc5_8]
  245. // CHECK:STDOUT: %.loc11_11.1: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = class_element_access %v.ref, element0
  246. // CHECK:STDOUT: %.loc11_11.2: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = acquire_value %.loc11_11.1
  247. // CHECK:STDOUT: %impl.elem0.loc11: @InitFromStructGeneric.%.loc10_27 (%.e56) = impl_witness_access constants.%Copy.lookup_impl_witness.322, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.bab)]
  248. // CHECK:STDOUT: %bound_method.loc11_11.1: <bound method> = bound_method %.loc11_11.2, %impl.elem0.loc11
  249. // CHECK:STDOUT: %specific_impl_fn.loc11: <specific function> = specific_impl_function %impl.elem0.loc11, @Copy.WithSelf.Op(constants.%Copy.facet.856) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.421)]
  250. // CHECK:STDOUT: %bound_method.loc11_11.2: <bound method> = bound_method %.loc11_11.2, %specific_impl_fn.loc11
  251. // CHECK:STDOUT: %.loc9_65.1: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) = splice_block %return.param {}
  252. // CHECK:STDOUT: %Copy.WithSelf.Op.call.loc11: init @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.db4) to %.loc9_65.1 = call %bound_method.loc11_11.2(%.loc11_11.2)
  253. // CHECK:STDOUT: %impl.elem0.loc10_3.1: @InitFromStructGeneric.%.loc10_3.2 (%.1fe) = impl_witness_access constants.%Destroy.lookup_impl_witness.488, element0 [symbolic = %impl.elem0.loc10_3.2 (constants.%impl.elem0.ae3)]
  254. // CHECK:STDOUT: %bound_method.loc10_3.1: <bound method> = bound_method %v.var, %impl.elem0.loc10_3.1
  255. // CHECK:STDOUT: %specific_impl_fn.loc10_3.1: <specific function> = specific_impl_function %impl.elem0.loc10_3.1, @Destroy.WithSelf.Op(constants.%Destroy.facet.474) [symbolic = %specific_impl_fn.loc10_3.2 (constants.%specific_impl_fn.4b3)]
  256. // CHECK:STDOUT: %bound_method.loc10_3.2: <bound method> = bound_method %v.var, %specific_impl_fn.loc10_3.1
  257. // CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call %bound_method.loc10_3.2(%v.var)
  258. // CHECK:STDOUT: return %Copy.WithSelf.Op.call.loc11 to %return.param
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: fn @InitFromStructSpecific(%x.param: %i32) -> out %return.param: %i32 {
  263. // CHECK:STDOUT: !entry:
  264. // CHECK:STDOUT: name_binding_decl {
  265. // CHECK:STDOUT: %v.patt: %pattern_type.f2b = ref_binding_pattern v [concrete]
  266. // CHECK:STDOUT: %v.var_patt: %pattern_type.f2b = var_pattern %v.patt [concrete]
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT: %v.var: ref %Class.02d = var %v.var_patt
  269. // CHECK:STDOUT: %x.ref: %i32 = name_ref x, %x
  270. // CHECK:STDOUT: %.loc15_30.1: %struct_type.k.0bf = struct_literal (%x.ref)
  271. // CHECK:STDOUT: %impl.elem0.loc15: %.8e2 = impl_witness_access constants.%Copy.impl_witness.f17, element0 [concrete = constants.%Int.as.Copy.impl.Op.664]
  272. // CHECK:STDOUT: %bound_method.loc15_29.1: <bound method> = bound_method %x.ref, %impl.elem0.loc15
  273. // 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]
  274. // CHECK:STDOUT: %bound_method.loc15_29.2: <bound method> = bound_method %x.ref, %specific_fn.loc15
  275. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc15: init %i32 = call %bound_method.loc15_29.2(%x.ref)
  276. // CHECK:STDOUT: %.loc15_30.2: ref %i32 = class_element_access %v.var, element0
  277. // CHECK:STDOUT: %.loc15_30.3: init %i32 to %.loc15_30.2 = in_place_init %Int.as.Copy.impl.Op.call.loc15
  278. // CHECK:STDOUT: %.loc15_30.4: init %Class.02d to %v.var = class_init (%.loc15_30.3)
  279. // CHECK:STDOUT: %.loc15_3: init %Class.02d = converted %.loc15_30.1, %.loc15_30.4
  280. // CHECK:STDOUT: assign %v.var, %.loc15_3
  281. // CHECK:STDOUT: %.loc15_19.1: type = splice_block %Class [concrete = constants.%Class.02d] {
  282. // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
  283. // CHECK:STDOUT: %i32.loc15: type = type_literal constants.%i32 [concrete = constants.%i32]
  284. // CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %i32.loc15, (constants.%custom_witness.8d7fae.2) [concrete = constants.%Destroy.facet.0fd]
  285. // CHECK:STDOUT: %.loc15_19.2: %Destroy.type = converted %i32.loc15, %Destroy.facet [concrete = constants.%Destroy.facet.0fd]
  286. // CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%Destroy.facet.0fd) [concrete = constants.%Class.02d]
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT: %v: ref %Class.02d = ref_binding v, %v.var
  289. // CHECK:STDOUT: %v.ref: ref %Class.02d = name_ref v, %v
  290. // CHECK:STDOUT: %k.ref: %Class.elem.2a7 = name_ref k, @Class.%.loc5_8 [concrete = @Class.%.loc5_8]
  291. // CHECK:STDOUT: %.loc16_11.1: ref %i32 = class_element_access %v.ref, element0
  292. // CHECK:STDOUT: %.loc16_11.2: %i32 = acquire_value %.loc16_11.1
  293. // CHECK:STDOUT: %impl.elem0.loc16: %.8e2 = impl_witness_access constants.%Copy.impl_witness.f17, element0 [concrete = constants.%Int.as.Copy.impl.Op.664]
  294. // CHECK:STDOUT: %bound_method.loc16_11.1: <bound method> = bound_method %.loc16_11.2, %impl.elem0.loc16
  295. // 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]
  296. // CHECK:STDOUT: %bound_method.loc16_11.2: <bound method> = bound_method %.loc16_11.2, %specific_fn.loc16
  297. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc16: init %i32 = call %bound_method.loc16_11.2(%.loc16_11.2)
  298. // CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %v.var, constants.%Destroy.Op.651ba6.4
  299. // CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call %Destroy.Op.bound(%v.var)
  300. // CHECK:STDOUT: return %Int.as.Copy.impl.Op.call.loc16
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: fn @Destroy.Op.loc15_19.1(%self.param: ref %i32.builtin) = "no_op";
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: fn @Destroy.Op.loc15_19.2(%self.param: ref %i32) {
  306. // CHECK:STDOUT: !entry:
  307. // CHECK:STDOUT: return
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: fn @Destroy.Op.loc15_3.1(%self.param: ref %struct_type.k.0bf) {
  311. // CHECK:STDOUT: !entry:
  312. // CHECK:STDOUT: return
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: fn @Destroy.Op.loc15_3.2(%self.param: ref %Class.02d) {
  316. // CHECK:STDOUT: !entry:
  317. // CHECK:STDOUT: return
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: specific @InitFromStructGeneric(constants.%T.65f) {
  321. // CHECK:STDOUT: %T.loc9_27.1 => constants.%T.65f
  322. // CHECK:STDOUT: %T.as_type.loc9_59.1 => constants.%T.as_type.db4
  323. // CHECK:STDOUT: %pattern_type.loc9 => constants.%pattern_type.58d
  324. // CHECK:STDOUT: %.loc9_65.2 => constants.%.a57
  325. // CHECK:STDOUT: }
  326. // CHECK:STDOUT:
  327. // CHECK:STDOUT: --- adapt.carbon
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: constants {
  330. // CHECK:STDOUT: %Adapt.type: type = generic_class_type @Adapt [concrete]
  331. // CHECK:STDOUT: %Adapt.generic: %Adapt.type = struct_value () [concrete]
  332. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  333. // CHECK:STDOUT: %pattern_type.ce2: type = pattern_type %Copy.type [concrete]
  334. // CHECK:STDOUT: %T.035: %Copy.type = symbolic_binding T, 0 [symbolic]
  335. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T.035 [symbolic]
  336. // CHECK:STDOUT: %pattern_type.3b9bb5.2: type = pattern_type %T.as_type [symbolic]
  337. // CHECK:STDOUT: %.435d17.2: Core.Form = init_form %T.as_type [symbolic]
  338. // CHECK:STDOUT: %InitFromAdaptedGeneric.type: type = fn_type @InitFromAdaptedGeneric [concrete]
  339. // CHECK:STDOUT: %InitFromAdaptedGeneric: %InitFromAdaptedGeneric.type = struct_value () [concrete]
  340. // CHECK:STDOUT: %require_complete.89e: <witness> = require_complete_type %T.as_type [symbolic]
  341. // CHECK:STDOUT: %Adapt.2b1: type = class_type @Adapt, @Adapt(%T.as_type) [symbolic]
  342. // CHECK:STDOUT: %require_complete.619: <witness> = require_complete_type %Adapt.2b1 [symbolic]
  343. // CHECK:STDOUT: %Copy.lookup_impl_witness.58d: <witness> = lookup_impl_witness %T.035, @Copy [symbolic]
  344. // CHECK:STDOUT: %Copy.WithSelf.Op.type.735e75.2: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.035) [symbolic]
  345. // CHECK:STDOUT: %.023: type = fn_type_with_self_type %Copy.WithSelf.Op.type.735e75.2, %T.035 [symbolic]
  346. // CHECK:STDOUT: %impl.elem0.594: %.023 = impl_witness_access %Copy.lookup_impl_witness.58d, element0 [symbolic]
  347. // CHECK:STDOUT: %specific_impl_fn.bdc: <specific function> = specific_impl_function %impl.elem0.594, @Copy.WithSelf.Op(%T.035) [symbolic]
  348. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  349. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  350. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  351. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  352. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  353. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  354. // CHECK:STDOUT: %.ff5: Core.Form = init_form %i32 [concrete]
  355. // CHECK:STDOUT: %InitFromAdaptedSpecific.type: type = fn_type @InitFromAdaptedSpecific [concrete]
  356. // CHECK:STDOUT: %InitFromAdaptedSpecific: %InitFromAdaptedSpecific.type = struct_value () [concrete]
  357. // CHECK:STDOUT: %Adapt.808: type = class_type @Adapt, @Adapt(%i32) [concrete]
  358. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.824: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  359. // CHECK:STDOUT: %Int.as.Copy.impl.Op.9b9: %Int.as.Copy.impl.Op.type.824 = struct_value () [symbolic]
  360. // CHECK:STDOUT: %Copy.impl_witness.f17: <witness> = impl_witness imports.%Copy.impl_witness_table.e76, @Int.as.Copy.impl(%int_32) [concrete]
  361. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.546: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  362. // CHECK:STDOUT: %Int.as.Copy.impl.Op.664: %Int.as.Copy.impl.Op.type.546 = struct_value () [concrete]
  363. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.f17) [concrete]
  364. // CHECK:STDOUT: %Copy.WithSelf.Op.type.081: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
  365. // CHECK:STDOUT: %.8e2: type = fn_type_with_self_type %Copy.WithSelf.Op.type.081, %Copy.facet [concrete]
  366. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.664, @Int.as.Copy.impl.Op(%int_32) [concrete]
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT:
  369. // CHECK:STDOUT: imports {
  370. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  371. // CHECK:STDOUT: .Copy = %Core.Copy
  372. // CHECK:STDOUT: .Int = %Core.Int
  373. // CHECK:STDOUT: import Core//prelude
  374. // CHECK:STDOUT: import Core//prelude/...
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
  377. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  378. // CHECK:STDOUT: %Core.import_ref.18d: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.824) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.9b9)]
  379. // CHECK:STDOUT: %Copy.impl_witness_table.e76 = impl_witness_table (%Core.import_ref.18d), @Int.as.Copy.impl [concrete]
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: file {
  383. // CHECK:STDOUT: %InitFromAdaptedGeneric.decl: %InitFromAdaptedGeneric.type = fn_decl @InitFromAdaptedGeneric [concrete = constants.%InitFromAdaptedGeneric] {
  384. // CHECK:STDOUT: %T.patt: %pattern_type.ce2 = symbolic_binding_pattern T, 0 [concrete]
  385. // CHECK:STDOUT: %x.param_patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.3b9bb5.2) = value_param_pattern [concrete]
  386. // CHECK:STDOUT: %x.patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.3b9bb5.2) = at_binding_pattern x, %x.param_patt [concrete]
  387. // CHECK:STDOUT: %return.param_patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.3b9bb5.2) = out_param_pattern [concrete]
  388. // CHECK:STDOUT: %return.patt: @InitFromAdaptedGeneric.%pattern_type (%pattern_type.3b9bb5.2) = return_slot_pattern %return.param_patt, %.loc9_51.3 [concrete]
  389. // CHECK:STDOUT: } {
  390. // CHECK:STDOUT: %T.ref.loc9_51: %Copy.type = name_ref T, %T.loc9_28.2 [symbolic = %T.loc9_28.1 (constants.%T.035)]
  391. // 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)]
  392. // CHECK:STDOUT: %.loc9_51.3: type = converted %T.ref.loc9_51, %T.as_type.loc9_51 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  393. // CHECK:STDOUT: %.loc9_51.4: Core.Form = init_form %.loc9_51.3 [symbolic = %.loc9_51.2 (constants.%.435d17.2)]
  394. // CHECK:STDOUT: %.loc9_35: type = splice_block %Copy.ref [concrete = constants.%Copy.type] {
  395. // CHECK:STDOUT: <elided>
  396. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  397. // CHECK:STDOUT: %Copy.ref: type = name_ref Copy, imports.%Core.Copy [concrete = constants.%Copy.type]
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT: %T.loc9_28.2: %Copy.type = symbolic_binding T, 0 [symbolic = %T.loc9_28.1 (constants.%T.035)]
  400. // CHECK:STDOUT: %x.param: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = value_param call_param0
  401. // CHECK:STDOUT: %.loc9_45.1: type = splice_block %.loc9_45.2 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)] {
  402. // CHECK:STDOUT: %T.ref.loc9_45: %Copy.type = name_ref T, %T.loc9_28.2 [symbolic = %T.loc9_28.1 (constants.%T.035)]
  403. // 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)]
  404. // 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)]
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT: %x: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = value_binding x, %x.param
  407. // CHECK:STDOUT: %return.param: ref @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = out_param call_param1
  408. // CHECK:STDOUT: %return: ref @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = return_slot %return.param
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT: %InitFromAdaptedSpecific.decl: %InitFromAdaptedSpecific.type = fn_decl @InitFromAdaptedSpecific [concrete = constants.%InitFromAdaptedSpecific] {
  411. // CHECK:STDOUT: %x.param_patt: %pattern_type.7ce = value_param_pattern [concrete]
  412. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = at_binding_pattern x, %x.param_patt [concrete]
  413. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern [concrete]
  414. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern %return.param_patt, %i32.loc13_39 [concrete]
  415. // CHECK:STDOUT: } {
  416. // CHECK:STDOUT: %i32.loc13_39: type = type_literal constants.%i32 [concrete = constants.%i32]
  417. // CHECK:STDOUT: %.loc13: Core.Form = init_form %i32.loc13_39 [concrete = constants.%.ff5]
  418. // CHECK:STDOUT: %x.param: %i32 = value_param call_param0
  419. // CHECK:STDOUT: %i32.loc13_31: type = type_literal constants.%i32 [concrete = constants.%i32]
  420. // CHECK:STDOUT: %x: %i32 = value_binding x, %x.param
  421. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  422. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  423. // CHECK:STDOUT: }
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: generic fn @InitFromAdaptedGeneric(%T.loc9_28.2: %Copy.type) {
  427. // CHECK:STDOUT: %T.loc9_28.1: %Copy.type = symbolic_binding T, 0 [symbolic = %T.loc9_28.1 (constants.%T.035)]
  428. // CHECK:STDOUT: %T.as_type.loc9_45.1: type = facet_access_type %T.loc9_28.1 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
  429. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.as_type.loc9_45.1 [symbolic = %pattern_type (constants.%pattern_type.3b9bb5.2)]
  430. // CHECK:STDOUT: %.loc9_51.2: Core.Form = init_form %T.as_type.loc9_45.1 [symbolic = %.loc9_51.2 (constants.%.435d17.2)]
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: !definition:
  433. // CHECK:STDOUT: %require_complete.loc9: <witness> = require_complete_type %T.as_type.loc9_45.1 [symbolic = %require_complete.loc9 (constants.%require_complete.89e)]
  434. // CHECK:STDOUT: %Adapt.loc10_23.2: type = class_type @Adapt, @Adapt(%T.as_type.loc9_45.1) [symbolic = %Adapt.loc10_23.2 (constants.%Adapt.2b1)]
  435. // CHECK:STDOUT: %require_complete.loc10: <witness> = require_complete_type %Adapt.loc10_23.2 [symbolic = %require_complete.loc10 (constants.%require_complete.619)]
  436. // CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.loc9_28.1) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.735e75.2)]
  437. // CHECK:STDOUT: %.loc10_26.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc9_28.1 [symbolic = %.loc10_26.3 (constants.%.023)]
  438. // CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc9_28.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.58d)]
  439. // CHECK:STDOUT: %impl.elem0.loc10_26.2: @InitFromAdaptedGeneric.%.loc10_26.3 (%.023) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.594)]
  440. // CHECK:STDOUT: %specific_impl_fn.loc10_26.2: <specific function> = specific_impl_function %impl.elem0.loc10_26.2, @Copy.WithSelf.Op(%T.loc9_28.1) [symbolic = %specific_impl_fn.loc10_26.2 (constants.%specific_impl_fn.bdc)]
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: fn(%x.param: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type)) -> out %return.param: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) {
  443. // CHECK:STDOUT: !entry:
  444. // CHECK:STDOUT: %x.ref: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = name_ref x, %x
  445. // CHECK:STDOUT: %Adapt.ref: %Adapt.type = name_ref Adapt, file.%Adapt.decl [concrete = constants.%Adapt.generic]
  446. // CHECK:STDOUT: %T.ref.loc10_22: %Copy.type = name_ref T, %T.loc9_28.2 [symbolic = %T.loc9_28.1 (constants.%T.035)]
  447. // 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)]
  448. // 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)]
  449. // CHECK:STDOUT: %Adapt.loc10_23.1: type = class_type @Adapt, @Adapt(constants.%T.as_type) [symbolic = %Adapt.loc10_23.2 (constants.%Adapt.2b1)]
  450. // CHECK:STDOUT: %.loc10_13.1: @InitFromAdaptedGeneric.%Adapt.loc10_23.2 (%Adapt.2b1) = as_compatible %x.ref
  451. // CHECK:STDOUT: %.loc10_13.2: @InitFromAdaptedGeneric.%Adapt.loc10_23.2 (%Adapt.2b1) = converted %x.ref, %.loc10_13.1
  452. // CHECK:STDOUT: %T.ref.loc10_29: %Copy.type = name_ref T, %T.loc9_28.2 [symbolic = %T.loc9_28.1 (constants.%T.035)]
  453. // 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)]
  454. // 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)]
  455. // CHECK:STDOUT: %.loc10_26.1: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = as_compatible %.loc10_13.2
  456. // CHECK:STDOUT: %.loc10_26.2: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = converted %.loc10_13.2, %.loc10_26.1
  457. // CHECK:STDOUT: %impl.elem0.loc10_26.1: @InitFromAdaptedGeneric.%.loc10_26.3 (%.023) = impl_witness_access constants.%Copy.lookup_impl_witness.58d, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.594)]
  458. // CHECK:STDOUT: %bound_method.loc10_26.1: <bound method> = bound_method %.loc10_26.2, %impl.elem0.loc10_26.1
  459. // CHECK:STDOUT: %specific_impl_fn.loc10_26.1: <specific function> = specific_impl_function %impl.elem0.loc10_26.1, @Copy.WithSelf.Op(constants.%T.035) [symbolic = %specific_impl_fn.loc10_26.2 (constants.%specific_impl_fn.bdc)]
  460. // CHECK:STDOUT: %bound_method.loc10_26.2: <bound method> = bound_method %.loc10_26.2, %specific_impl_fn.loc10_26.1
  461. // CHECK:STDOUT: %.loc9_51.1: ref @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = splice_block %return.param {}
  462. // CHECK:STDOUT: %Copy.WithSelf.Op.call: init @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) to %.loc9_51.1 = call %bound_method.loc10_26.2(%.loc10_26.2)
  463. // CHECK:STDOUT: return %Copy.WithSelf.Op.call to %return.param
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: fn @InitFromAdaptedSpecific(%x.param: %i32) -> out %return.param: %i32 {
  468. // CHECK:STDOUT: !entry:
  469. // CHECK:STDOUT: %x.ref: %i32 = name_ref x, %x
  470. // CHECK:STDOUT: %Adapt.ref: %Adapt.type = name_ref Adapt, file.%Adapt.decl [concrete = constants.%Adapt.generic]
  471. // CHECK:STDOUT: %i32.loc14_22: type = type_literal constants.%i32 [concrete = constants.%i32]
  472. // CHECK:STDOUT: %Adapt: type = class_type @Adapt, @Adapt(constants.%i32) [concrete = constants.%Adapt.808]
  473. // CHECK:STDOUT: %.loc14_13.1: %Adapt.808 = as_compatible %x.ref
  474. // CHECK:STDOUT: %.loc14_13.2: %Adapt.808 = converted %x.ref, %.loc14_13.1
  475. // CHECK:STDOUT: %i32.loc14_31: type = type_literal constants.%i32 [concrete = constants.%i32]
  476. // CHECK:STDOUT: %.loc14_28.1: %i32 = as_compatible %.loc14_13.2
  477. // CHECK:STDOUT: %.loc14_28.2: %i32 = converted %.loc14_13.2, %.loc14_28.1
  478. // CHECK:STDOUT: %impl.elem0: %.8e2 = impl_witness_access constants.%Copy.impl_witness.f17, element0 [concrete = constants.%Int.as.Copy.impl.Op.664]
  479. // CHECK:STDOUT: %bound_method.loc14_28.1: <bound method> = bound_method %.loc14_28.2, %impl.elem0
  480. // 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]
  481. // CHECK:STDOUT: %bound_method.loc14_28.2: <bound method> = bound_method %.loc14_28.2, %specific_fn
  482. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc14_28.2(%.loc14_28.2)
  483. // CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
  484. // CHECK:STDOUT: }
  485. // CHECK:STDOUT:
  486. // CHECK:STDOUT: specific @InitFromAdaptedGeneric(constants.%T.035) {
  487. // CHECK:STDOUT: %T.loc9_28.1 => constants.%T.035
  488. // CHECK:STDOUT: %T.as_type.loc9_45.1 => constants.%T.as_type
  489. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.3b9bb5.2
  490. // CHECK:STDOUT: %.loc9_51.2 => constants.%.435d17.2
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT: