import_self.carbon 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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/destroy.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/import_self.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/import_self.carbon
  14. // --- a.carbon
  15. library "[[@TEST_NAME]]";
  16. interface Add {
  17. fn Op[self: Self](other: Self) -> Self;
  18. }
  19. // --- b.carbon
  20. library "[[@TEST_NAME]]";
  21. import library "a";
  22. class C { adapt (); }
  23. impl C as Add {
  24. fn Op[unused self: Self](unused other: Self) -> Self { return () as C; }
  25. }
  26. fn F(x: C, y: C) -> C {
  27. return x.(Add.Op)(y);
  28. }
  29. // CHECK:STDOUT: --- a.carbon
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: constants {
  32. // CHECK:STDOUT: %Add.type: type = facet_type <@Add> [concrete]
  33. // CHECK:STDOUT: %Self: %Add.type = symbolic_binding Self, 0 [symbolic]
  34. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  35. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type [symbolic]
  36. // CHECK:STDOUT: %.108: Core.Form = init_form %Self.as_type [symbolic]
  37. // CHECK:STDOUT: %Add.WithSelf.Op.type: type = fn_type @Add.WithSelf.Op, @Add.WithSelf(%Self) [symbolic]
  38. // CHECK:STDOUT: %Add.WithSelf.Op: %Add.WithSelf.Op.type = struct_value () [symbolic]
  39. // CHECK:STDOUT: %Add.assoc_type: type = assoc_entity_type @Add [concrete]
  40. // CHECK:STDOUT: %assoc0: %Add.assoc_type = assoc_entity element0, @Add.WithSelf.%Add.WithSelf.Op.decl [concrete]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: imports {
  44. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  45. // CHECK:STDOUT: import Core//prelude
  46. // CHECK:STDOUT: import Core//prelude/...
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  52. // CHECK:STDOUT: .Core = imports.%Core
  53. // CHECK:STDOUT: .Add = %Add.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %Core.import = import Core
  56. // CHECK:STDOUT: %Add.decl: type = interface_decl @Add [concrete = constants.%Add.type] {} {}
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: interface @Add {
  60. // CHECK:STDOUT: %Self: %Add.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  61. // CHECK:STDOUT: %Add.WithSelf.decl = interface_with_self_decl @Add [concrete]
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: !with Self:
  64. // CHECK:STDOUT: %Add.WithSelf.Op.decl: @Add.WithSelf.%Add.WithSelf.Op.type (%Add.WithSelf.Op.type) = fn_decl @Add.WithSelf.Op [symbolic = @Add.WithSelf.%Add.WithSelf.Op (constants.%Add.WithSelf.Op)] {
  65. // CHECK:STDOUT: %self.param_patt: @Add.WithSelf.Op.%pattern_type (%pattern_type) = value_param_pattern [concrete]
  66. // CHECK:STDOUT: %self.patt: @Add.WithSelf.Op.%pattern_type (%pattern_type) = at_binding_pattern self, %self.param_patt [concrete]
  67. // CHECK:STDOUT: %other.param_patt: @Add.WithSelf.Op.%pattern_type (%pattern_type) = value_param_pattern [concrete]
  68. // CHECK:STDOUT: %other.patt: @Add.WithSelf.Op.%pattern_type (%pattern_type) = at_binding_pattern other, %other.param_patt [concrete]
  69. // CHECK:STDOUT: %return.param_patt: @Add.WithSelf.Op.%pattern_type (%pattern_type) = out_param_pattern [concrete]
  70. // CHECK:STDOUT: %return.patt: @Add.WithSelf.Op.%pattern_type (%pattern_type) = return_slot_pattern %return.param_patt, %.loc5_37.2 [concrete]
  71. // CHECK:STDOUT: } {
  72. // CHECK:STDOUT: %Self.ref.loc5_37: %Add.type = name_ref Self, @Add.%Self [symbolic = %Self (constants.%Self)]
  73. // CHECK:STDOUT: %Self.as_type.loc5_37: type = facet_access_type %Self.ref.loc5_37 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  74. // CHECK:STDOUT: %.loc5_37.2: type = converted %Self.ref.loc5_37, %Self.as_type.loc5_37 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  75. // CHECK:STDOUT: %.loc5_37.3: Core.Form = init_form %.loc5_37.2 [symbolic = %.loc5_37.1 (constants.%.108)]
  76. // CHECK:STDOUT: %self.param: @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param call_param0
  77. // CHECK:STDOUT: %.loc5_15.1: type = splice_block %.loc5_15.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] {
  78. // CHECK:STDOUT: %Self.ref.loc5_15: %Add.type = name_ref Self, @Add.%Self [symbolic = %Self (constants.%Self)]
  79. // CHECK:STDOUT: %Self.as_type.loc5_15.2: type = facet_access_type %Self.ref.loc5_15 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  80. // CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %Self.as_type.loc5_15.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: %self: @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type) = value_binding self, %self.param
  83. // CHECK:STDOUT: %other.param: @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param call_param1
  84. // CHECK:STDOUT: %.loc5_28.1: type = splice_block %.loc5_28.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] {
  85. // CHECK:STDOUT: %Self.ref.loc5_28: %Add.type = name_ref Self, @Add.%Self [symbolic = %Self (constants.%Self)]
  86. // CHECK:STDOUT: %Self.as_type.loc5_28: type = facet_access_type %Self.ref.loc5_28 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  87. // CHECK:STDOUT: %.loc5_28.2: type = converted %Self.ref.loc5_28, %Self.as_type.loc5_28 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT: %other: @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type) = value_binding other, %other.param
  90. // CHECK:STDOUT: %return.param: ref @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type) = out_param call_param2
  91. // CHECK:STDOUT: %return: ref @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type) = return_slot %return.param
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %assoc0: %Add.assoc_type = assoc_entity element0, %Add.WithSelf.Op.decl [concrete = constants.%assoc0]
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: !members:
  96. // CHECK:STDOUT: .Self = %Self
  97. // CHECK:STDOUT: .Op = @Add.WithSelf.%assoc0
  98. // CHECK:STDOUT: witness = (@Add.WithSelf.%Add.WithSelf.Op.decl)
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: !requires:
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: generic fn @Add.WithSelf.Op(@Add.%Self: %Add.type) {
  104. // CHECK:STDOUT: %Self: %Add.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self)]
  105. // CHECK:STDOUT: %Self.as_type.loc5_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  106. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type.loc5_15.1 [symbolic = %pattern_type (constants.%pattern_type)]
  107. // CHECK:STDOUT: %.loc5_37.1: Core.Form = init_form %Self.as_type.loc5_15.1 [symbolic = %.loc5_37.1 (constants.%.108)]
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: fn(%self.param: @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type), %other.param: @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type)) -> out %return.param: @Add.WithSelf.Op.%Self.as_type.loc5_15.1 (%Self.as_type);
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: specific @Add.WithSelf(constants.%Self) {}
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: specific @Add.WithSelf.Op(constants.%Self) {
  115. // CHECK:STDOUT: %Self => constants.%Self
  116. // CHECK:STDOUT: %Self.as_type.loc5_15.1 => constants.%Self.as_type
  117. // CHECK:STDOUT: %pattern_type => constants.%pattern_type
  118. // CHECK:STDOUT: %.loc5_37.1 => constants.%.108
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: --- b.carbon
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: constants {
  124. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  125. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  126. // CHECK:STDOUT: %empty_tuple.af4: %empty_tuple.type = tuple_value () [concrete]
  127. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_tuple.type [concrete]
  128. // CHECK:STDOUT: %Add.type: type = facet_type <@Add> [concrete]
  129. // CHECK:STDOUT: %Self: %Add.type = symbolic_binding Self, 0 [symbolic]
  130. // CHECK:STDOUT: %Add.WithSelf.Op.type.099: type = fn_type @Add.WithSelf.Op, @Add.WithSelf(%Self) [symbolic]
  131. // CHECK:STDOUT: %Add.WithSelf.Op.99a: %Add.WithSelf.Op.type.099 = struct_value () [symbolic]
  132. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  133. // CHECK:STDOUT: %pattern_type.0d9: type = pattern_type %Self.as_type [symbolic]
  134. // CHECK:STDOUT: %.1c4: Core.Form = init_form %Self.as_type [symbolic]
  135. // CHECK:STDOUT: %Add.impl_witness: <witness> = impl_witness @C.as.Add.impl.%Add.impl_witness_table [concrete]
  136. // CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
  137. // CHECK:STDOUT: %.a69: Core.Form = init_form %C [concrete]
  138. // CHECK:STDOUT: %C.as.Add.impl.Op.type: type = fn_type @C.as.Add.impl.Op [concrete]
  139. // CHECK:STDOUT: %C.as.Add.impl.Op: %C.as.Add.impl.Op.type = struct_value () [concrete]
  140. // CHECK:STDOUT: %Add.facet: %Add.type = facet_value %C, (%Add.impl_witness) [concrete]
  141. // CHECK:STDOUT: %Add.WithSelf.Op.type.3ed: type = fn_type @Add.WithSelf.Op, @Add.WithSelf(%Add.facet) [concrete]
  142. // CHECK:STDOUT: %Add.WithSelf.Op.5d9: %Add.WithSelf.Op.type.3ed = struct_value () [concrete]
  143. // CHECK:STDOUT: %empty_tuple.bfb: %C = tuple_value () [concrete]
  144. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  145. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  146. // CHECK:STDOUT: %Add.assoc_type: type = assoc_entity_type @Add [concrete]
  147. // CHECK:STDOUT: %assoc0: %Add.assoc_type = assoc_entity element0, imports.%Main.import_ref.dad [concrete]
  148. // CHECK:STDOUT: %.c75: type = fn_type_with_self_type %Add.WithSelf.Op.type.3ed, %Add.facet [concrete]
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: imports {
  152. // CHECK:STDOUT: %Main.Add: type = import_ref Main//a, Add, loaded [concrete = constants.%Add.type]
  153. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  154. // CHECK:STDOUT: import Core//prelude
  155. // CHECK:STDOUT: import Core//prelude/...
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT: %Main.import_ref.a96: %Add.assoc_type = import_ref Main//a, loc5_41, loaded [concrete = constants.%assoc0]
  158. // CHECK:STDOUT: %Main.Op: @Add.WithSelf.%Add.WithSelf.Op.type (%Add.WithSelf.Op.type.099) = import_ref Main//a, Op, loaded [symbolic = @Add.WithSelf.%Add.WithSelf.Op (constants.%Add.WithSelf.Op.99a)]
  159. // CHECK:STDOUT: %Main.import_ref.bb084d.2: %Add.type = import_ref Main//a, loc4_15, loaded [symbolic = constants.%Self]
  160. // CHECK:STDOUT: %Main.import_ref.17c = import_ref Main//a, loc4_15, unloaded
  161. // CHECK:STDOUT: %Main.import_ref.dad: @Add.WithSelf.%Add.WithSelf.Op.type (%Add.WithSelf.Op.type.099) = import_ref Main//a, loc5_41, loaded [symbolic = @Add.WithSelf.%Add.WithSelf.Op (constants.%Add.WithSelf.Op.99a)]
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: file {
  165. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  166. // CHECK:STDOUT: .Add = imports.%Main.Add
  167. // CHECK:STDOUT: .Core = imports.%Core
  168. // CHECK:STDOUT: .C = %C.decl
  169. // CHECK:STDOUT: .F = %F.decl
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: %Core.import = import Core
  172. // CHECK:STDOUT: %default.import = import <none>
  173. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  174. // CHECK:STDOUT: impl_decl @C.as.Add.impl [concrete] {} {
  175. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  176. // CHECK:STDOUT: %Add.ref: type = name_ref Add, imports.%Main.Add [concrete = constants.%Add.type]
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  179. // CHECK:STDOUT: %x.param_patt: %pattern_type.7c7 = value_param_pattern [concrete]
  180. // CHECK:STDOUT: %x.patt: %pattern_type.7c7 = at_binding_pattern x, %x.param_patt [concrete]
  181. // CHECK:STDOUT: %y.param_patt: %pattern_type.7c7 = value_param_pattern [concrete]
  182. // CHECK:STDOUT: %y.patt: %pattern_type.7c7 = at_binding_pattern y, %y.param_patt [concrete]
  183. // CHECK:STDOUT: %return.param_patt: %pattern_type.7c7 = out_param_pattern [concrete]
  184. // CHECK:STDOUT: %return.patt: %pattern_type.7c7 = return_slot_pattern %return.param_patt, %C.ref.loc12_21 [concrete]
  185. // CHECK:STDOUT: } {
  186. // CHECK:STDOUT: %C.ref.loc12_21: type = name_ref C, file.%C.decl [concrete = constants.%C]
  187. // CHECK:STDOUT: %.loc12: Core.Form = init_form %C.ref.loc12_21 [concrete = constants.%.a69]
  188. // CHECK:STDOUT: %x.param: %C = value_param call_param0
  189. // CHECK:STDOUT: %C.ref.loc12_9: type = name_ref C, file.%C.decl [concrete = constants.%C]
  190. // CHECK:STDOUT: %x: %C = value_binding x, %x.param
  191. // CHECK:STDOUT: %y.param: %C = value_param call_param1
  192. // CHECK:STDOUT: %C.ref.loc12_15: type = name_ref C, file.%C.decl [concrete = constants.%C]
  193. // CHECK:STDOUT: %y: %C = value_binding y, %y.param
  194. // CHECK:STDOUT: %return.param: ref %C = out_param call_param2
  195. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: interface @Add [from "a.carbon"] {
  200. // CHECK:STDOUT: !members:
  201. // CHECK:STDOUT: .Self = imports.%Main.import_ref.17c
  202. // CHECK:STDOUT: .Op = imports.%Main.import_ref.a96
  203. // CHECK:STDOUT: witness = (imports.%Main.Op)
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: !requires:
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: impl @C.as.Add.impl: %C.ref as %Add.ref {
  209. // CHECK:STDOUT: %C.as.Add.impl.Op.decl: %C.as.Add.impl.Op.type = fn_decl @C.as.Add.impl.Op [concrete = constants.%C.as.Add.impl.Op] {
  210. // CHECK:STDOUT: %self.param_patt: %pattern_type.7c7 = value_param_pattern [concrete]
  211. // CHECK:STDOUT: %self.patt: %pattern_type.7c7 = at_binding_pattern self, %self.param_patt [concrete]
  212. // CHECK:STDOUT: %other.param_patt: %pattern_type.7c7 = value_param_pattern [concrete]
  213. // CHECK:STDOUT: %other.patt: %pattern_type.7c7 = at_binding_pattern other, %other.param_patt [concrete]
  214. // CHECK:STDOUT: %return.param_patt: %pattern_type.7c7 = out_param_pattern [concrete]
  215. // CHECK:STDOUT: %return.patt: %pattern_type.7c7 = return_slot_pattern %return.param_patt, %Self.ref.loc9_51 [concrete]
  216. // CHECK:STDOUT: } {
  217. // CHECK:STDOUT: %Self.ref.loc9_51: type = name_ref Self, @C.as.Add.impl.%C.ref [concrete = constants.%C]
  218. // CHECK:STDOUT: %.loc9_51: Core.Form = init_form %Self.ref.loc9_51 [concrete = constants.%.a69]
  219. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  220. // CHECK:STDOUT: %Self.ref.loc9_22: type = name_ref Self, @C.as.Add.impl.%C.ref [concrete = constants.%C]
  221. // CHECK:STDOUT: %self: %C = value_binding self, %self.param
  222. // CHECK:STDOUT: %other.param: %C = value_param call_param1
  223. // CHECK:STDOUT: %Self.ref.loc9_42: type = name_ref Self, @C.as.Add.impl.%C.ref [concrete = constants.%C]
  224. // CHECK:STDOUT: %other: %C = value_binding other, %other.param
  225. // CHECK:STDOUT: %return.param: ref %C = out_param call_param2
  226. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT: %Add.impl_witness_table = impl_witness_table (%C.as.Add.impl.Op.decl), @C.as.Add.impl [concrete]
  229. // CHECK:STDOUT: %Add.impl_witness: <witness> = impl_witness %Add.impl_witness_table [concrete = constants.%Add.impl_witness]
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: !members:
  232. // CHECK:STDOUT: .Op = %C.as.Add.impl.Op.decl
  233. // CHECK:STDOUT: .C = <poisoned>
  234. // CHECK:STDOUT: witness = %Add.impl_witness
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: class @C {
  238. // CHECK:STDOUT: %.loc6_18: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple.af4]
  239. // CHECK:STDOUT: %.loc6_19: type = converted %.loc6_18, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  240. // CHECK:STDOUT: adapt_decl %.loc6_19 [concrete]
  241. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_tuple.type [concrete = constants.%complete_type]
  242. // CHECK:STDOUT: complete_type_witness = %complete_type
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: !members:
  245. // CHECK:STDOUT: .Self = constants.%C
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: generic fn @Add.WithSelf.Op(imports.%Main.import_ref.bb084d.2: %Add.type) [from "a.carbon"] {
  249. // CHECK:STDOUT: %Self: %Add.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self)]
  250. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type)]
  251. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type [symbolic = %pattern_type (constants.%pattern_type.0d9)]
  252. // CHECK:STDOUT: %.1: Core.Form = init_form %Self.as_type [symbolic = %.1 (constants.%.1c4)]
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: fn;
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: fn @C.as.Add.impl.Op(%self.param: %C, %other.param: %C) -> out %return.param: %C {
  258. // CHECK:STDOUT: !entry:
  259. // CHECK:STDOUT: %.loc9_66: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple.af4]
  260. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  261. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple.af4]
  262. // CHECK:STDOUT: %.loc9_68.1: %C = as_compatible %empty_tuple [concrete = constants.%empty_tuple.bfb]
  263. // CHECK:STDOUT: %.loc9_68.2: %C = converted %.loc9_66, %.loc9_68.1 [concrete = constants.%empty_tuple.bfb]
  264. // CHECK:STDOUT: %.loc9_72.1: %empty_tuple.type = as_compatible %.loc9_68.2 [concrete = constants.%empty_tuple.af4]
  265. // CHECK:STDOUT: %.loc9_72.2: init %empty_tuple.type = tuple_init () [concrete = constants.%empty_tuple.af4]
  266. // CHECK:STDOUT: %.loc9_72.3: init %C = as_compatible %.loc9_72.2 [concrete = constants.%empty_tuple.bfb]
  267. // CHECK:STDOUT: %.loc9_72.4: init %C = converted %.loc9_68.2, %.loc9_72.3 [concrete = constants.%empty_tuple.bfb]
  268. // CHECK:STDOUT: return %.loc9_72.4
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: fn @F(%x.param: %C, %y.param: %C) -> out %return.param: %C {
  272. // CHECK:STDOUT: !entry:
  273. // CHECK:STDOUT: %x.ref: %C = name_ref x, %x
  274. // CHECK:STDOUT: %Add.ref: type = name_ref Add, imports.%Main.Add [concrete = constants.%Add.type]
  275. // CHECK:STDOUT: %Op.ref: %Add.assoc_type = name_ref Op, imports.%Main.import_ref.a96 [concrete = constants.%assoc0]
  276. // CHECK:STDOUT: %impl.elem0: %.c75 = impl_witness_access constants.%Add.impl_witness, element0 [concrete = constants.%C.as.Add.impl.Op]
  277. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %x.ref, %impl.elem0
  278. // CHECK:STDOUT: %y.ref: %C = name_ref y, %y
  279. // CHECK:STDOUT: %C.as.Add.impl.Op.call: init %C = call %bound_method(%x.ref, %y.ref)
  280. // CHECK:STDOUT: return %C.as.Add.impl.Op.call
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: specific @Add.WithSelf(constants.%Self) {
  284. // CHECK:STDOUT: !definition:
  285. // CHECK:STDOUT: %Self => constants.%Self
  286. // CHECK:STDOUT: %Add.WithSelf.Op.type => constants.%Add.WithSelf.Op.type.099
  287. // CHECK:STDOUT: %Add.WithSelf.Op => constants.%Add.WithSelf.Op.99a
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: specific @Add.WithSelf.Op(constants.%Self) {
  291. // CHECK:STDOUT: %Self => constants.%Self
  292. // CHECK:STDOUT: %Self.as_type => constants.%Self.as_type
  293. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.0d9
  294. // CHECK:STDOUT: %.1 => constants.%.1c4
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: specific @Add.WithSelf(constants.%Add.facet) {
  298. // CHECK:STDOUT: !definition:
  299. // CHECK:STDOUT: %Self => constants.%Add.facet
  300. // CHECK:STDOUT: %Add.WithSelf.Op.type => constants.%Add.WithSelf.Op.type.3ed
  301. // CHECK:STDOUT: %Add.WithSelf.Op => constants.%Add.WithSelf.Op.5d9
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: specific @Add.WithSelf.Op(constants.%Add.facet) {
  305. // CHECK:STDOUT: %Self => constants.%Add.facet
  306. // CHECK:STDOUT: %Self.as_type => constants.%C
  307. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7c7
  308. // CHECK:STDOUT: %.1 => constants.%.a69
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT: