access.carbon 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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/convert.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/facet/access.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/access.carbon
  12. // --- access_assoc_fn.carbon
  13. library "[[@TEST_NAME]]";
  14. interface I {
  15. fn DoIt();
  16. }
  17. fn Use(T:! I) {
  18. //@dump-sem-ir-begin
  19. T.DoIt();
  20. //@dump-sem-ir-end
  21. }
  22. // --- assoc_fn_using_self.carbon
  23. library "[[@TEST_NAME]]";
  24. interface I {
  25. fn Make() -> Self;
  26. }
  27. fn Use(T:! I) -> T {
  28. //@dump-sem-ir-begin
  29. return T.Make();
  30. //@dump-sem-ir-end
  31. }
  32. // --- access_assoc_method.carbon
  33. library "[[@TEST_NAME]]";
  34. interface I {
  35. fn Copy[self: Self]() -> Self;
  36. }
  37. //@dump-sem-ir-begin
  38. fn Use[T:! I](x: T) -> T {
  39. return x.Copy();
  40. }
  41. //@dump-sem-ir-end
  42. // --- access_selfless_method.carbon
  43. library "[[@TEST_NAME]]";
  44. interface I {
  45. fn Hello();
  46. }
  47. fn Use[T:! I](x: T){
  48. //@dump-sem-ir-begin
  49. x.Hello();
  50. //@dump-sem-ir-end
  51. }
  52. // --- access_assoc_method_indirect.carbon
  53. library "[[@TEST_NAME]]";
  54. interface I {
  55. fn Copy[self: Self]() -> Self;
  56. }
  57. fn UseIndirect[T:! I](x: T) -> T {
  58. //@dump-sem-ir-begin
  59. return x.(T.Copy)();
  60. //@dump-sem-ir-end
  61. }
  62. // --- fail_non_const_associated.carbon
  63. library "[[@TEST_NAME]]";
  64. interface I { let T:! type; }
  65. fn Id[U:! type](x: U) -> U { return Id(x); }
  66. impl () as I where .T = () {}
  67. // Type of member expr is associated entity type,
  68. // but value is not constant.
  69. // CHECK:STDERR: fail_non_const_associated.carbon:[[@LINE+4]]:8: error: semantics TODO: `Non-constant associated entity value` [SemanticsTodo]
  70. // CHECK:STDERR: var v: ().(Id(I.T));
  71. // CHECK:STDERR: ^~~~~~~~~~~~
  72. // CHECK:STDERR:
  73. var v: ().(Id(I.T));
  74. // --- fail_non_const_associated_in_interface.carbon
  75. library "[[@TEST_NAME]]";
  76. fn Id[U:! type](x: U) -> U { return Id(x); }
  77. interface J {
  78. let T:! type;
  79. // CHECK:STDERR: fail_non_const_associated_in_interface.carbon:[[@LINE+4]]:13: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  80. // CHECK:STDERR: fn F() -> Id(T);
  81. // CHECK:STDERR: ^~~~~
  82. // CHECK:STDERR:
  83. fn F() -> Id(T);
  84. }
  85. // --- fail_alias_to_non_const_assoc_entity.carbon
  86. library "[[@TEST_NAME]]";
  87. interface I {
  88. let T:! type;
  89. }
  90. // CHECK:STDERR: fail_alias_to_non_const_assoc_entity.carbon:[[@LINE+4]]:8: error: semantics TODO: `HandleAutoTypeLiteral` [SemanticsTodo]
  91. // CHECK:STDERR: let x: auto = I.T;
  92. // CHECK:STDERR: ^~~~
  93. // CHECK:STDERR:
  94. let x: auto = I.T;
  95. interface J {
  96. // Is this valid?
  97. alias U = x;
  98. // type of U is an assoc entity type, but value is not constant.
  99. fn F() -> U;
  100. }
  101. // --- to_import.carbon
  102. library "[[@TEST_NAME]]";
  103. interface I {
  104. let T:! type;
  105. }
  106. alias U = I.T;
  107. // --- fail_access_alias_in_imported_library.carbon
  108. library "[[@TEST_NAME]]";
  109. import library "to_import";
  110. interface J {
  111. // extend I;
  112. alias V = U;
  113. // CHECK:STDERR: fail_access_alias_in_imported_library.carbon:[[@LINE+4]]:13: error: cannot convert type `Self` that implements `J` into type implementing `I` [ConversionFailureFacetToFacet]
  114. // CHECK:STDERR: fn F() -> V;
  115. // CHECK:STDERR: ^
  116. // CHECK:STDERR:
  117. fn F() -> V;
  118. }
  119. // --- access_constant_in_self_facet.carbon
  120. library "[[@TEST_NAME]]";
  121. interface A { let X:! type; }
  122. //@dump-sem-ir-begin
  123. fn F(AA:! A where .X = ()) -> AA.X {
  124. return ();
  125. }
  126. //@dump-sem-ir-end
  127. // --- access_constant_in_self_facet_with_multiple_interfaces.carbon
  128. library "[[@TEST_NAME]]";
  129. interface A { let X:! type; }
  130. interface B { let Y:! type; }
  131. // The rewrite rules of .X and .Y come in some canonically sorted order. The
  132. // ImplWitnessAccess instruction looks at them to try find a value for the
  133. // rewrite in the conversion target. We use different orderings to more reliably
  134. // create the scenario where the ImplWitnessAccess sees a rewrite of a value in
  135. // an interface other than the one it is accessing before finding the correct
  136. // rewrite.
  137. //@dump-sem-ir-begin
  138. fn F(AB:! A & B where .X = () and .Y = {}) -> AB.X {
  139. return ();
  140. }
  141. fn G(AB:! A & B where .X = () and .Y = {}) -> AB.Y {
  142. return {};
  143. }
  144. //@dump-sem-ir-end
  145. // CHECK:STDOUT: --- access_assoc_fn.carbon
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: constants {
  148. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  149. // CHECK:STDOUT: %I.DoIt.type: type = fn_type @I.DoIt [concrete]
  150. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  151. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  152. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.DoIt.decl [concrete]
  153. // CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic]
  154. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  155. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  156. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type, (%I.lookup_impl_witness) [symbolic]
  157. // CHECK:STDOUT: %.531: type = fn_type_with_self_type %I.DoIt.type, %I.facet [symbolic]
  158. // CHECK:STDOUT: %impl.elem0: %.531 = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  159. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @I.DoIt(%I.facet) [symbolic]
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: imports {
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: generic fn @Use(%T.loc8_8.2: %I.type) {
  166. // CHECK:STDOUT: <elided>
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: !definition:
  169. // CHECK:STDOUT: %T.as_type.loc10_4.2: type = facet_access_type %T.loc8_8.1 [symbolic = %T.as_type.loc10_4.2 (constants.%T.as_type)]
  170. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc8_8.1, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  171. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type.loc10_4.2, (%I.lookup_impl_witness) [symbolic = %I.facet (constants.%I.facet)]
  172. // CHECK:STDOUT: %.loc10_4.2: type = fn_type_with_self_type constants.%I.DoIt.type, %I.facet [symbolic = %.loc10_4.2 (constants.%.531)]
  173. // CHECK:STDOUT: %impl.elem0.loc10_4.2: @Use.%.loc10_4.2 (%.531) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_4.2 (constants.%impl.elem0)]
  174. // CHECK:STDOUT: %specific_impl_fn.loc10_4.2: <specific function> = specific_impl_function %impl.elem0.loc10_4.2, @I.DoIt(%I.facet) [symbolic = %specific_impl_fn.loc10_4.2 (constants.%specific_impl_fn)]
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: fn() {
  177. // CHECK:STDOUT: !entry:
  178. // CHECK:STDOUT: %T.ref: %I.type = name_ref T, %T.loc8_8.2 [symbolic = %T.loc8_8.1 (constants.%T)]
  179. // CHECK:STDOUT: %DoIt.ref: %I.assoc_type = name_ref DoIt, @I.%assoc0 [concrete = constants.%assoc0]
  180. // CHECK:STDOUT: %T.as_type.loc10_4.1: type = facet_access_type %T.ref [symbolic = %T.as_type.loc10_4.2 (constants.%T.as_type)]
  181. // CHECK:STDOUT: %.loc10_4.1: type = converted %T.ref, %T.as_type.loc10_4.1 [symbolic = %T.as_type.loc10_4.2 (constants.%T.as_type)]
  182. // CHECK:STDOUT: %impl.elem0.loc10_4.1: @Use.%.loc10_4.2 (%.531) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_4.2 (constants.%impl.elem0)]
  183. // CHECK:STDOUT: %specific_impl_fn.loc10_4.1: <specific function> = specific_impl_function %impl.elem0.loc10_4.1, @I.DoIt(constants.%I.facet) [symbolic = %specific_impl_fn.loc10_4.2 (constants.%specific_impl_fn)]
  184. // CHECK:STDOUT: %.loc10_10: init %empty_tuple.type = call %specific_impl_fn.loc10_4.1()
  185. // CHECK:STDOUT: <elided>
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: specific @Use(constants.%T) {
  190. // CHECK:STDOUT: %T.loc8_8.1 => constants.%T
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: --- assoc_fn_using_self.carbon
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: constants {
  196. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  197. // CHECK:STDOUT: %I.Make.type: type = fn_type @I.Make [concrete]
  198. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  199. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.Make.decl [concrete]
  200. // CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic]
  201. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  202. // CHECK:STDOUT: %pattern_type.d22d6c.2: type = pattern_type %T.as_type [symbolic]
  203. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  204. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type, (%I.lookup_impl_witness) [symbolic]
  205. // CHECK:STDOUT: %.7cf: type = fn_type_with_self_type %I.Make.type, %I.facet [symbolic]
  206. // CHECK:STDOUT: %impl.elem0: %.7cf = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  207. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @I.Make(%I.facet) [symbolic]
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: imports {
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: generic fn @Use(%T.loc8_8.2: %I.type) {
  214. // CHECK:STDOUT: <elided>
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: !definition:
  217. // CHECK:STDOUT: <elided>
  218. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc8_8.1, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  219. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type.loc8_18.1, (%I.lookup_impl_witness) [symbolic = %I.facet (constants.%I.facet)]
  220. // CHECK:STDOUT: %.loc10_11.2: type = fn_type_with_self_type constants.%I.Make.type, %I.facet [symbolic = %.loc10_11.2 (constants.%.7cf)]
  221. // CHECK:STDOUT: %impl.elem0.loc10_11.2: @Use.%.loc10_11.2 (%.7cf) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_11.2 (constants.%impl.elem0)]
  222. // CHECK:STDOUT: %specific_impl_fn.loc10_11.2: <specific function> = specific_impl_function %impl.elem0.loc10_11.2, @I.Make(%I.facet) [symbolic = %specific_impl_fn.loc10_11.2 (constants.%specific_impl_fn)]
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: fn() -> %return.param: @Use.%T.as_type.loc8_18.1 (%T.as_type) {
  225. // CHECK:STDOUT: !entry:
  226. // CHECK:STDOUT: %T.ref.loc10: %I.type = name_ref T, %T.loc8_8.2 [symbolic = %T.loc8_8.1 (constants.%T)]
  227. // CHECK:STDOUT: %Make.ref: %I.assoc_type = name_ref Make, @I.%assoc0 [concrete = constants.%assoc0]
  228. // CHECK:STDOUT: %T.as_type.loc10: type = facet_access_type %T.ref.loc10 [symbolic = %T.as_type.loc8_18.1 (constants.%T.as_type)]
  229. // CHECK:STDOUT: %.loc10_11.1: type = converted %T.ref.loc10, %T.as_type.loc10 [symbolic = %T.as_type.loc8_18.1 (constants.%T.as_type)]
  230. // CHECK:STDOUT: %impl.elem0.loc10_11.1: @Use.%.loc10_11.2 (%.7cf) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_11.2 (constants.%impl.elem0)]
  231. // CHECK:STDOUT: %specific_impl_fn.loc10_11.1: <specific function> = specific_impl_function %impl.elem0.loc10_11.1, @I.Make(constants.%I.facet) [symbolic = %specific_impl_fn.loc10_11.2 (constants.%specific_impl_fn)]
  232. // CHECK:STDOUT: <elided>
  233. // CHECK:STDOUT: %.loc10_17: init @Use.%T.as_type.loc8_18.1 (%T.as_type) = call %specific_impl_fn.loc10_11.1() to %.loc8_15
  234. // CHECK:STDOUT: return %.loc10_17 to %return
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: specific @Use(constants.%T) {
  239. // CHECK:STDOUT: %T.loc8_8.1 => constants.%T
  240. // CHECK:STDOUT: %T.as_type.loc8_18.1 => constants.%T.as_type
  241. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.d22d6c.2
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: --- access_assoc_method.carbon
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: constants {
  247. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  248. // CHECK:STDOUT: %I.Copy.type: type = fn_type @I.Copy [concrete]
  249. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  250. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.Copy.decl [concrete]
  251. // CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic]
  252. // CHECK:STDOUT: %pattern_type.09a: type = pattern_type %I.type [concrete]
  253. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  254. // CHECK:STDOUT: %pattern_type.d22d6c.2: type = pattern_type %T.as_type [symbolic]
  255. // CHECK:STDOUT: %Use.type: type = fn_type @Use [concrete]
  256. // CHECK:STDOUT: %Use: %Use.type = struct_value () [concrete]
  257. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.as_type [symbolic]
  258. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  259. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type, (%I.lookup_impl_witness) [symbolic]
  260. // CHECK:STDOUT: %.ee3: type = fn_type_with_self_type %I.Copy.type, %I.facet [symbolic]
  261. // CHECK:STDOUT: %impl.elem0: %.ee3 = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  262. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @I.Copy(%I.facet) [symbolic]
  263. // CHECK:STDOUT: }
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: imports {
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: file {
  269. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [concrete = constants.%Use] {
  270. // CHECK:STDOUT: %T.patt: %pattern_type.09a = symbolic_binding_pattern T, 0 [concrete]
  271. // CHECK:STDOUT: %x.patt: @Use.%pattern_type (%pattern_type.d22d6c.2) = binding_pattern x [concrete]
  272. // CHECK:STDOUT: %x.param_patt: @Use.%pattern_type (%pattern_type.d22d6c.2) = value_param_pattern %x.patt, call_param0 [concrete]
  273. // CHECK:STDOUT: %return.patt: @Use.%pattern_type (%pattern_type.d22d6c.2) = return_slot_pattern [concrete]
  274. // CHECK:STDOUT: %return.param_patt: @Use.%pattern_type (%pattern_type.d22d6c.2) = out_param_pattern %return.patt, call_param1 [concrete]
  275. // CHECK:STDOUT: } {
  276. // CHECK:STDOUT: %T.ref.loc9_24: %I.type = name_ref T, %T.loc9_8.2 [symbolic = %T.loc9_8.1 (constants.%T)]
  277. // CHECK:STDOUT: %T.as_type.loc9_24: type = facet_access_type %T.ref.loc9_24 [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)]
  278. // CHECK:STDOUT: %.loc9_24: type = converted %T.ref.loc9_24, %T.as_type.loc9_24 [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)]
  279. // CHECK:STDOUT: %.loc9_12: type = splice_block %I.ref [concrete = constants.%I.type] {
  280. // CHECK:STDOUT: <elided>
  281. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT: %T.loc9_8.2: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_8.1 (constants.%T)]
  284. // CHECK:STDOUT: %x.param: @Use.%T.as_type.loc9_18.1 (%T.as_type) = value_param call_param0
  285. // CHECK:STDOUT: %.loc9_18.1: type = splice_block %.loc9_18.2 [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)] {
  286. // CHECK:STDOUT: %T.ref.loc9_18: %I.type = name_ref T, %T.loc9_8.2 [symbolic = %T.loc9_8.1 (constants.%T)]
  287. // CHECK:STDOUT: %T.as_type.loc9_18.2: type = facet_access_type %T.ref.loc9_18 [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)]
  288. // CHECK:STDOUT: %.loc9_18.2: type = converted %T.ref.loc9_18, %T.as_type.loc9_18.2 [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)]
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT: %x: @Use.%T.as_type.loc9_18.1 (%T.as_type) = bind_name x, %x.param
  291. // CHECK:STDOUT: %return.param: ref @Use.%T.as_type.loc9_18.1 (%T.as_type) = out_param call_param1
  292. // CHECK:STDOUT: %return: ref @Use.%T.as_type.loc9_18.1 (%T.as_type) = return_slot %return.param
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: generic fn @Use(%T.loc9_8.2: %I.type) {
  297. // CHECK:STDOUT: %T.loc9_8.1: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_8.1 (constants.%T)]
  298. // CHECK:STDOUT: %T.as_type.loc9_18.1: type = facet_access_type %T.loc9_8.1 [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)]
  299. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.as_type.loc9_18.1 [symbolic = %pattern_type (constants.%pattern_type.d22d6c.2)]
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: !definition:
  302. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.as_type.loc9_18.1 [symbolic = %require_complete (constants.%require_complete)]
  303. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc9_8.1, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  304. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type.loc9_18.1, (%I.lookup_impl_witness) [symbolic = %I.facet (constants.%I.facet)]
  305. // CHECK:STDOUT: %.loc10_11.2: type = fn_type_with_self_type constants.%I.Copy.type, %I.facet [symbolic = %.loc10_11.2 (constants.%.ee3)]
  306. // CHECK:STDOUT: %impl.elem0.loc10_11.2: @Use.%.loc10_11.2 (%.ee3) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_11.2 (constants.%impl.elem0)]
  307. // CHECK:STDOUT: %specific_impl_fn.loc10_11.2: <specific function> = specific_impl_function %impl.elem0.loc10_11.2, @I.Copy(%I.facet) [symbolic = %specific_impl_fn.loc10_11.2 (constants.%specific_impl_fn)]
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: fn(%x.param: @Use.%T.as_type.loc9_18.1 (%T.as_type)) -> %return.param: @Use.%T.as_type.loc9_18.1 (%T.as_type) {
  310. // CHECK:STDOUT: !entry:
  311. // CHECK:STDOUT: %x.ref: @Use.%T.as_type.loc9_18.1 (%T.as_type) = name_ref x, %x
  312. // CHECK:STDOUT: %Copy.ref: %I.assoc_type = name_ref Copy, @I.%assoc0 [concrete = constants.%assoc0]
  313. // CHECK:STDOUT: %T.as_type.loc10: type = facet_access_type constants.%T [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)]
  314. // CHECK:STDOUT: %.loc10_11.1: type = converted constants.%T, %T.as_type.loc10 [symbolic = %T.as_type.loc9_18.1 (constants.%T.as_type)]
  315. // CHECK:STDOUT: %impl.elem0.loc10_11.1: @Use.%.loc10_11.2 (%.ee3) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_11.2 (constants.%impl.elem0)]
  316. // CHECK:STDOUT: %bound_method.loc10_11: <bound method> = bound_method %x.ref, %impl.elem0.loc10_11.1
  317. // CHECK:STDOUT: %specific_impl_fn.loc10_11.1: <specific function> = specific_impl_function %impl.elem0.loc10_11.1, @I.Copy(constants.%I.facet) [symbolic = %specific_impl_fn.loc10_11.2 (constants.%specific_impl_fn)]
  318. // CHECK:STDOUT: %bound_method.loc10_17: <bound method> = bound_method %x.ref, %specific_impl_fn.loc10_11.1
  319. // CHECK:STDOUT: %.loc9_21: ref @Use.%T.as_type.loc9_18.1 (%T.as_type) = splice_block %return {}
  320. // CHECK:STDOUT: %.loc10_17: init @Use.%T.as_type.loc9_18.1 (%T.as_type) = call %bound_method.loc10_17(%x.ref) to %.loc9_21
  321. // CHECK:STDOUT: return %.loc10_17 to %return
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: specific @Use(constants.%T) {
  326. // CHECK:STDOUT: %T.loc9_8.1 => constants.%T
  327. // CHECK:STDOUT: %T.as_type.loc9_18.1 => constants.%T.as_type
  328. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.d22d6c.2
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: --- access_selfless_method.carbon
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: constants {
  334. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  335. // CHECK:STDOUT: %I.Hello.type: type = fn_type @I.Hello [concrete]
  336. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  337. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  338. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.Hello.decl [concrete]
  339. // CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic]
  340. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  341. // CHECK:STDOUT: %pattern_type.d22: type = pattern_type %T.as_type [symbolic]
  342. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  343. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type, (%I.lookup_impl_witness) [symbolic]
  344. // CHECK:STDOUT: %.234: type = fn_type_with_self_type %I.Hello.type, %I.facet [symbolic]
  345. // CHECK:STDOUT: %impl.elem0: %.234 = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  346. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @I.Hello(%I.facet) [symbolic]
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: imports {
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: generic fn @Use(%T.loc8_8.2: %I.type) {
  353. // CHECK:STDOUT: <elided>
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: !definition:
  356. // CHECK:STDOUT: <elided>
  357. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc8_8.1, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  358. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type.loc8_18.1, (%I.lookup_impl_witness) [symbolic = %I.facet (constants.%I.facet)]
  359. // CHECK:STDOUT: %.loc10_4.2: type = fn_type_with_self_type constants.%I.Hello.type, %I.facet [symbolic = %.loc10_4.2 (constants.%.234)]
  360. // CHECK:STDOUT: %impl.elem0.loc10_4.2: @Use.%.loc10_4.2 (%.234) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_4.2 (constants.%impl.elem0)]
  361. // CHECK:STDOUT: %specific_impl_fn.loc10_4.2: <specific function> = specific_impl_function %impl.elem0.loc10_4.2, @I.Hello(%I.facet) [symbolic = %specific_impl_fn.loc10_4.2 (constants.%specific_impl_fn)]
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: fn(%x.param: @Use.%T.as_type.loc8_18.1 (%T.as_type)) {
  364. // CHECK:STDOUT: !entry:
  365. // CHECK:STDOUT: %x.ref: @Use.%T.as_type.loc8_18.1 (%T.as_type) = name_ref x, %x
  366. // CHECK:STDOUT: %Hello.ref: %I.assoc_type = name_ref Hello, @I.%assoc0 [concrete = constants.%assoc0]
  367. // CHECK:STDOUT: %T.as_type.loc10: type = facet_access_type constants.%T [symbolic = %T.as_type.loc8_18.1 (constants.%T.as_type)]
  368. // CHECK:STDOUT: %.loc10_4.1: type = converted constants.%T, %T.as_type.loc10 [symbolic = %T.as_type.loc8_18.1 (constants.%T.as_type)]
  369. // CHECK:STDOUT: %impl.elem0.loc10_4.1: @Use.%.loc10_4.2 (%.234) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_4.2 (constants.%impl.elem0)]
  370. // CHECK:STDOUT: %specific_impl_fn.loc10_4.1: <specific function> = specific_impl_function %impl.elem0.loc10_4.1, @I.Hello(constants.%I.facet) [symbolic = %specific_impl_fn.loc10_4.2 (constants.%specific_impl_fn)]
  371. // CHECK:STDOUT: %.loc10_11: init %empty_tuple.type = call %specific_impl_fn.loc10_4.1()
  372. // CHECK:STDOUT: <elided>
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: specific @Use(constants.%T) {
  377. // CHECK:STDOUT: %T.loc8_8.1 => constants.%T
  378. // CHECK:STDOUT: %T.as_type.loc8_18.1 => constants.%T.as_type
  379. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.d22
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: --- access_assoc_method_indirect.carbon
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: constants {
  385. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  386. // CHECK:STDOUT: %I.Copy.type: type = fn_type @I.Copy [concrete]
  387. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  388. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.Copy.decl [concrete]
  389. // CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic]
  390. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  391. // CHECK:STDOUT: %pattern_type.d22d6c.2: type = pattern_type %T.as_type [symbolic]
  392. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  393. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type, (%I.lookup_impl_witness) [symbolic]
  394. // CHECK:STDOUT: %.ee3: type = fn_type_with_self_type %I.Copy.type, %I.facet [symbolic]
  395. // CHECK:STDOUT: %impl.elem0: %.ee3 = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  396. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @I.Copy(%I.facet) [symbolic]
  397. // CHECK:STDOUT: }
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: imports {
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: generic fn @UseIndirect(%T.loc8_16.2: %I.type) {
  403. // CHECK:STDOUT: <elided>
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: !definition:
  406. // CHECK:STDOUT: <elided>
  407. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc8_16.1, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  408. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type.loc8_26.1, (%I.lookup_impl_witness) [symbolic = %I.facet (constants.%I.facet)]
  409. // CHECK:STDOUT: %.loc10_14.2: type = fn_type_with_self_type constants.%I.Copy.type, %I.facet [symbolic = %.loc10_14.2 (constants.%.ee3)]
  410. // CHECK:STDOUT: %impl.elem0.loc10_14.2: @UseIndirect.%.loc10_14.2 (%.ee3) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_14.2 (constants.%impl.elem0)]
  411. // CHECK:STDOUT: %specific_impl_fn.loc10_14.2: <specific function> = specific_impl_function %impl.elem0.loc10_14.2, @I.Copy(%I.facet) [symbolic = %specific_impl_fn.loc10_14.2 (constants.%specific_impl_fn)]
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: fn(%x.param: @UseIndirect.%T.as_type.loc8_26.1 (%T.as_type)) -> %return.param: @UseIndirect.%T.as_type.loc8_26.1 (%T.as_type) {
  414. // CHECK:STDOUT: !entry:
  415. // CHECK:STDOUT: %x.ref: @UseIndirect.%T.as_type.loc8_26.1 (%T.as_type) = name_ref x, %x
  416. // CHECK:STDOUT: %T.ref.loc10: %I.type = name_ref T, %T.loc8_16.2 [symbolic = %T.loc8_16.1 (constants.%T)]
  417. // CHECK:STDOUT: %Copy.ref: %I.assoc_type = name_ref Copy, @I.%assoc0 [concrete = constants.%assoc0]
  418. // CHECK:STDOUT: %T.as_type.loc10: type = facet_access_type %T.ref.loc10 [symbolic = %T.as_type.loc8_26.1 (constants.%T.as_type)]
  419. // CHECK:STDOUT: %.loc10_14.1: type = converted %T.ref.loc10, %T.as_type.loc10 [symbolic = %T.as_type.loc8_26.1 (constants.%T.as_type)]
  420. // CHECK:STDOUT: %impl.elem0.loc10_14.1: @UseIndirect.%.loc10_14.2 (%.ee3) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_14.2 (constants.%impl.elem0)]
  421. // CHECK:STDOUT: %bound_method.loc10_11: <bound method> = bound_method %x.ref, %impl.elem0.loc10_14.1
  422. // CHECK:STDOUT: %specific_impl_fn.loc10_14.1: <specific function> = specific_impl_function %impl.elem0.loc10_14.1, @I.Copy(constants.%I.facet) [symbolic = %specific_impl_fn.loc10_14.2 (constants.%specific_impl_fn)]
  423. // CHECK:STDOUT: %bound_method.loc10_21: <bound method> = bound_method %x.ref, %specific_impl_fn.loc10_14.1
  424. // CHECK:STDOUT: <elided>
  425. // CHECK:STDOUT: %.loc10_21: init @UseIndirect.%T.as_type.loc8_26.1 (%T.as_type) = call %bound_method.loc10_21(%x.ref) to %.loc8_29
  426. // CHECK:STDOUT: return %.loc10_21 to %return
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: specific @UseIndirect(constants.%T) {
  431. // CHECK:STDOUT: %T.loc8_16.1 => constants.%T
  432. // CHECK:STDOUT: %T.as_type.loc8_26.1 => constants.%T.as_type
  433. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.d22d6c.2
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: --- access_constant_in_self_facet.carbon
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: constants {
  439. // CHECK:STDOUT: %A.type: type = facet_type <@A> [concrete]
  440. // CHECK:STDOUT: %A.assoc_type: type = assoc_entity_type @A [concrete]
  441. // CHECK:STDOUT: %assoc0: %A.assoc_type = assoc_entity element0, @A.%X [concrete]
  442. // CHECK:STDOUT: %.Self.56d: %A.type = bind_symbolic_name .Self [symbolic_self]
  443. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.56d [symbolic_self]
  444. // CHECK:STDOUT: %A.lookup_impl_witness.033: <witness> = lookup_impl_witness %.Self.56d, @A [symbolic_self]
  445. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %A.lookup_impl_witness.033, element0 [symbolic_self]
  446. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  447. // CHECK:STDOUT: %A_where.type: type = facet_type <@A where %impl.elem0 = %empty_tuple.type> [concrete]
  448. // CHECK:STDOUT: %AA: %A_where.type = bind_symbolic_name AA, 0 [symbolic]
  449. // CHECK:STDOUT: %pattern_type.14a: type = pattern_type %A_where.type [concrete]
  450. // CHECK:STDOUT: %AA.as_type: type = facet_access_type %AA [symbolic]
  451. // CHECK:STDOUT: %A.lookup_impl_witness.614: <witness> = lookup_impl_witness %AA, @A [symbolic]
  452. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  453. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  454. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  455. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: imports {
  459. // CHECK:STDOUT: }
  460. // CHECK:STDOUT:
  461. // CHECK:STDOUT: file {
  462. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  463. // CHECK:STDOUT: %AA.patt: %pattern_type.14a = symbolic_binding_pattern AA, 0 [concrete]
  464. // CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern [concrete]
  465. // CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern %return.patt, call_param0 [concrete]
  466. // CHECK:STDOUT: } {
  467. // CHECK:STDOUT: %AA.ref: %A_where.type = name_ref AA, %AA.loc6_6.2 [symbolic = %AA.loc6_6.1 (constants.%AA)]
  468. // CHECK:STDOUT: %X.ref.loc6_33: %A.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
  469. // CHECK:STDOUT: %AA.as_type.loc6_33.2: type = facet_access_type %AA.ref [symbolic = %AA.as_type.loc6_33.1 (constants.%AA.as_type)]
  470. // CHECK:STDOUT: %.loc6_33: type = converted %AA.ref, %AA.as_type.loc6_33.2 [symbolic = %AA.as_type.loc6_33.1 (constants.%AA.as_type)]
  471. // CHECK:STDOUT: %impl.elem0.loc6_33: type = impl_witness_access constants.%A.lookup_impl_witness.614, element0 [concrete = constants.%empty_tuple.type]
  472. // CHECK:STDOUT: %.loc6_13.1: type = splice_block %.loc6_13.2 [concrete = constants.%A_where.type] {
  473. // CHECK:STDOUT: <elided>
  474. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A.type]
  475. // CHECK:STDOUT: <elided>
  476. // CHECK:STDOUT: %.Self.ref: %A.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.56d]
  477. // CHECK:STDOUT: %X.ref.loc6_19: %A.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
  478. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
  479. // CHECK:STDOUT: %.loc6_19: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
  480. // CHECK:STDOUT: %impl.elem0.loc6_19: type = impl_witness_access constants.%A.lookup_impl_witness.033, element0 [symbolic_self = constants.%impl.elem0]
  481. // CHECK:STDOUT: %.loc6_25.1: %empty_tuple.type = tuple_literal ()
  482. // CHECK:STDOUT: %.loc6_25.2: type = converted %.loc6_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  483. // CHECK:STDOUT: %.loc6_13.2: type = where_expr %.Self.2 [concrete = constants.%A_where.type] {
  484. // CHECK:STDOUT: requirement_base_facet_type constants.%A.type
  485. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc6_19, %.loc6_25.2
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT: %AA.loc6_6.2: %A_where.type = bind_symbolic_name AA, 0 [symbolic = %AA.loc6_6.1 (constants.%AA)]
  489. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  490. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT: }
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: generic fn @F(%AA.loc6_6.2: %A_where.type) {
  495. // CHECK:STDOUT: %AA.loc6_6.1: %A_where.type = bind_symbolic_name AA, 0 [symbolic = %AA.loc6_6.1 (constants.%AA)]
  496. // CHECK:STDOUT: %AA.as_type.loc6_33.1: type = facet_access_type %AA.loc6_6.1 [symbolic = %AA.as_type.loc6_33.1 (constants.%AA.as_type)]
  497. // CHECK:STDOUT: %A.lookup_impl_witness: <witness> = lookup_impl_witness %AA.loc6_6.1, @A [symbolic = %A.lookup_impl_witness (constants.%A.lookup_impl_witness.614)]
  498. // CHECK:STDOUT:
  499. // CHECK:STDOUT: !definition:
  500. // CHECK:STDOUT:
  501. // CHECK:STDOUT: fn() -> %empty_tuple.type {
  502. // CHECK:STDOUT: !entry:
  503. // CHECK:STDOUT: %.loc7_11.1: %empty_tuple.type = tuple_literal ()
  504. // CHECK:STDOUT: %.loc7_11.2: init %empty_tuple.type = tuple_init () to %return [concrete = constants.%empty_tuple]
  505. // CHECK:STDOUT: %.loc7_12: init %empty_tuple.type = converted %.loc7_11.1, %.loc7_11.2 [concrete = constants.%empty_tuple]
  506. // CHECK:STDOUT: return %.loc7_12 to %return
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: specific @F(constants.%AA) {
  511. // CHECK:STDOUT: %AA.loc6_6.1 => constants.%AA
  512. // CHECK:STDOUT: %AA.as_type.loc6_33.1 => constants.%AA.as_type
  513. // CHECK:STDOUT: %A.lookup_impl_witness => constants.%A.lookup_impl_witness.614
  514. // CHECK:STDOUT: }
  515. // CHECK:STDOUT:
  516. // CHECK:STDOUT: --- access_constant_in_self_facet_with_multiple_interfaces.carbon
  517. // CHECK:STDOUT:
  518. // CHECK:STDOUT: constants {
  519. // CHECK:STDOUT: %A.type: type = facet_type <@A> [concrete]
  520. // CHECK:STDOUT: %A.assoc_type: type = assoc_entity_type @A [concrete]
  521. // CHECK:STDOUT: %assoc0.752: %A.assoc_type = assoc_entity element0, @A.%X [concrete]
  522. // CHECK:STDOUT: %B.type: type = facet_type <@B> [concrete]
  523. // CHECK:STDOUT: %B.assoc_type: type = assoc_entity_type @B [concrete]
  524. // CHECK:STDOUT: %assoc0.081: %B.assoc_type = assoc_entity element0, @B.%Y [concrete]
  525. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  526. // CHECK:STDOUT: %BitAndWith.type.8a6: type = facet_type <@BitAndWith, @BitAndWith(type)> [concrete]
  527. // CHECK:STDOUT: %BitAndWith.Op.type.9a3: type = fn_type @BitAndWith.Op, @BitAndWith(type) [concrete]
  528. // CHECK:STDOUT: %BitAndWith.impl_witness: <witness> = impl_witness imports.%BitAndWith.impl_witness_table [concrete]
  529. // CHECK:STDOUT: %BitAndWith.facet: %BitAndWith.type.8a6 = facet_value type, (%BitAndWith.impl_witness) [concrete]
  530. // CHECK:STDOUT: %.fa7: type = fn_type_with_self_type %BitAndWith.Op.type.9a3, %BitAndWith.facet [concrete]
  531. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.type: type = fn_type @type.as.BitAndWith.impl.Op [concrete]
  532. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op: %type.as.BitAndWith.impl.Op.type = struct_value () [concrete]
  533. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.bound: <bound method> = bound_method %A.type, %type.as.BitAndWith.impl.Op [concrete]
  534. // CHECK:STDOUT: %facet_type.c5c: type = facet_type <@A & @B> [concrete]
  535. // CHECK:STDOUT: %.Self.f55: %facet_type.c5c = bind_symbolic_name .Self [symbolic_self]
  536. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.f55 [symbolic_self]
  537. // CHECK:STDOUT: %A.lookup_impl_witness.a95: <witness> = lookup_impl_witness %.Self.f55, @A [symbolic_self]
  538. // CHECK:STDOUT: %impl.elem0.ade: type = impl_witness_access %A.lookup_impl_witness.a95, element0 [symbolic_self]
  539. // CHECK:STDOUT: %B.lookup_impl_witness.214: <witness> = lookup_impl_witness %.Self.f55, @B [symbolic_self]
  540. // CHECK:STDOUT: %impl.elem0.818: type = impl_witness_access %B.lookup_impl_witness.214, element0 [symbolic_self]
  541. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  542. // CHECK:STDOUT: %facet_type.a18: type = facet_type <@A & @B where %impl.elem0.ade = %empty_tuple.type and %impl.elem0.818 = %empty_struct_type> [concrete]
  543. // CHECK:STDOUT: %AB: %facet_type.a18 = bind_symbolic_name AB, 0 [symbolic]
  544. // CHECK:STDOUT: %pattern_type.e98: type = pattern_type %facet_type.a18 [concrete]
  545. // CHECK:STDOUT: %AB.as_type: type = facet_access_type %AB [symbolic]
  546. // CHECK:STDOUT: %A.lookup_impl_witness.d9a: <witness> = lookup_impl_witness %AB, @A [symbolic]
  547. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  548. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  549. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  550. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  551. // CHECK:STDOUT: %B.lookup_impl_witness.628: <witness> = lookup_impl_witness %AB, @B [symbolic]
  552. // CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
  553. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  554. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  555. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  556. // CHECK:STDOUT: }
  557. // CHECK:STDOUT:
  558. // CHECK:STDOUT: imports {
  559. // CHECK:STDOUT: %Core.import_ref.636: %type.as.BitAndWith.impl.Op.type = import_ref Core//prelude/parts/as, loc25_42, loaded [concrete = constants.%type.as.BitAndWith.impl.Op]
  560. // CHECK:STDOUT: %BitAndWith.impl_witness_table = impl_witness_table (%Core.import_ref.636), @type.as.BitAndWith.impl [concrete]
  561. // CHECK:STDOUT: }
  562. // CHECK:STDOUT:
  563. // CHECK:STDOUT: file {
  564. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  565. // CHECK:STDOUT: %AB.patt: %pattern_type.e98 = symbolic_binding_pattern AB, 0 [concrete]
  566. // CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern [concrete]
  567. // CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern %return.patt, call_param0 [concrete]
  568. // CHECK:STDOUT: } {
  569. // CHECK:STDOUT: %AB.ref: %facet_type.a18 = name_ref AB, %AB.loc14_6.2 [symbolic = %AB.loc14_6.1 (constants.%AB)]
  570. // CHECK:STDOUT: %X.ref.loc14_49: %A.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0.752]
  571. // CHECK:STDOUT: %AB.as_type.loc14_49.2: type = facet_access_type %AB.ref [symbolic = %AB.as_type.loc14_49.1 (constants.%AB.as_type)]
  572. // CHECK:STDOUT: %.loc14_49: type = converted %AB.ref, %AB.as_type.loc14_49.2 [symbolic = %AB.as_type.loc14_49.1 (constants.%AB.as_type)]
  573. // CHECK:STDOUT: %impl.elem0.loc14_49: type = impl_witness_access constants.%A.lookup_impl_witness.d9a, element0 [concrete = constants.%empty_tuple.type]
  574. // CHECK:STDOUT: %.loc14_17.1: type = splice_block %.loc14_17.2 [concrete = constants.%facet_type.a18] {
  575. // CHECK:STDOUT: <elided>
  576. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A.type]
  577. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B.type]
  578. // CHECK:STDOUT: %impl.elem0.loc14_13: %.fa7 = impl_witness_access constants.%BitAndWith.impl_witness, element0 [concrete = constants.%type.as.BitAndWith.impl.Op]
  579. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %A.ref, %impl.elem0.loc14_13 [concrete = constants.%type.as.BitAndWith.impl.Op.bound]
  580. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.call: init type = call %bound_method(%A.ref, %B.ref) [concrete = constants.%facet_type.c5c]
  581. // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %type.as.BitAndWith.impl.Op.call [concrete = constants.%facet_type.c5c]
  582. // CHECK:STDOUT: %.loc14_13.2: type = converted %type.as.BitAndWith.impl.Op.call, %.loc14_13.1 [concrete = constants.%facet_type.c5c]
  583. // CHECK:STDOUT: <elided>
  584. // CHECK:STDOUT: %.Self.ref.loc14_23: %facet_type.c5c = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.f55]
  585. // CHECK:STDOUT: %X.ref.loc14_23: %A.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0.752]
  586. // CHECK:STDOUT: %.Self.as_type.loc14_23: type = facet_access_type %.Self.ref.loc14_23 [symbolic_self = constants.%.Self.as_type]
  587. // CHECK:STDOUT: %.loc14_23: type = converted %.Self.ref.loc14_23, %.Self.as_type.loc14_23 [symbolic_self = constants.%.Self.as_type]
  588. // CHECK:STDOUT: %impl.elem0.loc14_23: type = impl_witness_access constants.%A.lookup_impl_witness.a95, element0 [symbolic_self = constants.%impl.elem0.ade]
  589. // CHECK:STDOUT: %.loc14_29.1: %empty_tuple.type = tuple_literal ()
  590. // CHECK:STDOUT: %.loc14_29.2: type = converted %.loc14_29.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  591. // CHECK:STDOUT: %.Self.ref.loc14_35: %facet_type.c5c = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.f55]
  592. // CHECK:STDOUT: %Y.ref: %B.assoc_type = name_ref Y, @Y.%assoc0 [concrete = constants.%assoc0.081]
  593. // CHECK:STDOUT: %.Self.as_type.loc14_35: type = facet_access_type %.Self.ref.loc14_35 [symbolic_self = constants.%.Self.as_type]
  594. // CHECK:STDOUT: %.loc14_35: type = converted %.Self.ref.loc14_35, %.Self.as_type.loc14_35 [symbolic_self = constants.%.Self.as_type]
  595. // CHECK:STDOUT: %impl.elem0.loc14_35: type = impl_witness_access constants.%B.lookup_impl_witness.214, element0 [symbolic_self = constants.%impl.elem0.818]
  596. // CHECK:STDOUT: %.loc14_41.1: %empty_struct_type = struct_literal ()
  597. // CHECK:STDOUT: %.loc14_41.2: type = converted %.loc14_41.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  598. // CHECK:STDOUT: %.loc14_17.2: type = where_expr %.Self.2 [concrete = constants.%facet_type.a18] {
  599. // CHECK:STDOUT: requirement_base_facet_type constants.%facet_type.c5c
  600. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc14_23, %.loc14_29.2
  601. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc14_35, %.loc14_41.2
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT: }
  604. // CHECK:STDOUT: %AB.loc14_6.2: %facet_type.a18 = bind_symbolic_name AB, 0 [symbolic = %AB.loc14_6.1 (constants.%AB)]
  605. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  606. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  607. // CHECK:STDOUT: }
  608. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  609. // CHECK:STDOUT: %AB.patt: %pattern_type.e98 = symbolic_binding_pattern AB, 0 [concrete]
  610. // CHECK:STDOUT: %return.patt: %pattern_type.a96 = return_slot_pattern [concrete]
  611. // CHECK:STDOUT: %return.param_patt: %pattern_type.a96 = out_param_pattern %return.patt, call_param0 [concrete]
  612. // CHECK:STDOUT: } {
  613. // CHECK:STDOUT: %AB.ref: %facet_type.a18 = name_ref AB, %AB.loc18_6.2 [symbolic = %AB.loc18_6.1 (constants.%AB)]
  614. // CHECK:STDOUT: %Y.ref.loc18_49: %B.assoc_type = name_ref Y, @Y.%assoc0 [concrete = constants.%assoc0.081]
  615. // CHECK:STDOUT: %AB.as_type.loc18_49.2: type = facet_access_type %AB.ref [symbolic = %AB.as_type.loc18_49.1 (constants.%AB.as_type)]
  616. // CHECK:STDOUT: %.loc18_49: type = converted %AB.ref, %AB.as_type.loc18_49.2 [symbolic = %AB.as_type.loc18_49.1 (constants.%AB.as_type)]
  617. // CHECK:STDOUT: %impl.elem0.loc18_49: type = impl_witness_access constants.%B.lookup_impl_witness.628, element0 [concrete = constants.%empty_struct_type]
  618. // CHECK:STDOUT: %.loc18_17.1: type = splice_block %.loc18_17.2 [concrete = constants.%facet_type.a18] {
  619. // CHECK:STDOUT: <elided>
  620. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A.type]
  621. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B.type]
  622. // CHECK:STDOUT: %impl.elem0.loc18_13: %.fa7 = impl_witness_access constants.%BitAndWith.impl_witness, element0 [concrete = constants.%type.as.BitAndWith.impl.Op]
  623. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %A.ref, %impl.elem0.loc18_13 [concrete = constants.%type.as.BitAndWith.impl.Op.bound]
  624. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.call: init type = call %bound_method(%A.ref, %B.ref) [concrete = constants.%facet_type.c5c]
  625. // CHECK:STDOUT: %.loc18_13.1: type = value_of_initializer %type.as.BitAndWith.impl.Op.call [concrete = constants.%facet_type.c5c]
  626. // CHECK:STDOUT: %.loc18_13.2: type = converted %type.as.BitAndWith.impl.Op.call, %.loc18_13.1 [concrete = constants.%facet_type.c5c]
  627. // CHECK:STDOUT: <elided>
  628. // CHECK:STDOUT: %.Self.ref.loc18_23: %facet_type.c5c = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.f55]
  629. // CHECK:STDOUT: %X.ref: %A.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0.752]
  630. // CHECK:STDOUT: %.Self.as_type.loc18_23: type = facet_access_type %.Self.ref.loc18_23 [symbolic_self = constants.%.Self.as_type]
  631. // CHECK:STDOUT: %.loc18_23: type = converted %.Self.ref.loc18_23, %.Self.as_type.loc18_23 [symbolic_self = constants.%.Self.as_type]
  632. // CHECK:STDOUT: %impl.elem0.loc18_23: type = impl_witness_access constants.%A.lookup_impl_witness.a95, element0 [symbolic_self = constants.%impl.elem0.ade]
  633. // CHECK:STDOUT: %.loc18_29.1: %empty_tuple.type = tuple_literal ()
  634. // CHECK:STDOUT: %.loc18_29.2: type = converted %.loc18_29.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  635. // CHECK:STDOUT: %.Self.ref.loc18_35: %facet_type.c5c = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.f55]
  636. // CHECK:STDOUT: %Y.ref.loc18_35: %B.assoc_type = name_ref Y, @Y.%assoc0 [concrete = constants.%assoc0.081]
  637. // CHECK:STDOUT: %.Self.as_type.loc18_35: type = facet_access_type %.Self.ref.loc18_35 [symbolic_self = constants.%.Self.as_type]
  638. // CHECK:STDOUT: %.loc18_35: type = converted %.Self.ref.loc18_35, %.Self.as_type.loc18_35 [symbolic_self = constants.%.Self.as_type]
  639. // CHECK:STDOUT: %impl.elem0.loc18_35: type = impl_witness_access constants.%B.lookup_impl_witness.214, element0 [symbolic_self = constants.%impl.elem0.818]
  640. // CHECK:STDOUT: %.loc18_41.1: %empty_struct_type = struct_literal ()
  641. // CHECK:STDOUT: %.loc18_41.2: type = converted %.loc18_41.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  642. // CHECK:STDOUT: %.loc18_17.2: type = where_expr %.Self.2 [concrete = constants.%facet_type.a18] {
  643. // CHECK:STDOUT: requirement_base_facet_type constants.%facet_type.c5c
  644. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc18_23, %.loc18_29.2
  645. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc18_35, %.loc18_41.2
  646. // CHECK:STDOUT: }
  647. // CHECK:STDOUT: }
  648. // CHECK:STDOUT: %AB.loc18_6.2: %facet_type.a18 = bind_symbolic_name AB, 0 [symbolic = %AB.loc18_6.1 (constants.%AB)]
  649. // CHECK:STDOUT: %return.param: ref %empty_struct_type = out_param call_param0
  650. // CHECK:STDOUT: %return: ref %empty_struct_type = return_slot %return.param
  651. // CHECK:STDOUT: }
  652. // CHECK:STDOUT: }
  653. // CHECK:STDOUT:
  654. // CHECK:STDOUT: generic fn @F(%AB.loc14_6.2: %facet_type.a18) {
  655. // CHECK:STDOUT: %AB.loc14_6.1: %facet_type.a18 = bind_symbolic_name AB, 0 [symbolic = %AB.loc14_6.1 (constants.%AB)]
  656. // CHECK:STDOUT: %AB.as_type.loc14_49.1: type = facet_access_type %AB.loc14_6.1 [symbolic = %AB.as_type.loc14_49.1 (constants.%AB.as_type)]
  657. // CHECK:STDOUT: %A.lookup_impl_witness: <witness> = lookup_impl_witness %AB.loc14_6.1, @A [symbolic = %A.lookup_impl_witness (constants.%A.lookup_impl_witness.d9a)]
  658. // CHECK:STDOUT:
  659. // CHECK:STDOUT: !definition:
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: fn() -> %empty_tuple.type {
  662. // CHECK:STDOUT: !entry:
  663. // CHECK:STDOUT: %.loc15_11.1: %empty_tuple.type = tuple_literal ()
  664. // CHECK:STDOUT: %.loc15_11.2: init %empty_tuple.type = tuple_init () to %return [concrete = constants.%empty_tuple]
  665. // CHECK:STDOUT: %.loc15_12: init %empty_tuple.type = converted %.loc15_11.1, %.loc15_11.2 [concrete = constants.%empty_tuple]
  666. // CHECK:STDOUT: return %.loc15_12 to %return
  667. // CHECK:STDOUT: }
  668. // CHECK:STDOUT: }
  669. // CHECK:STDOUT:
  670. // CHECK:STDOUT: generic fn @G(%AB.loc18_6.2: %facet_type.a18) {
  671. // CHECK:STDOUT: %AB.loc18_6.1: %facet_type.a18 = bind_symbolic_name AB, 0 [symbolic = %AB.loc18_6.1 (constants.%AB)]
  672. // CHECK:STDOUT: %AB.as_type.loc18_49.1: type = facet_access_type %AB.loc18_6.1 [symbolic = %AB.as_type.loc18_49.1 (constants.%AB.as_type)]
  673. // CHECK:STDOUT: %B.lookup_impl_witness: <witness> = lookup_impl_witness %AB.loc18_6.1, @B [symbolic = %B.lookup_impl_witness (constants.%B.lookup_impl_witness.628)]
  674. // CHECK:STDOUT:
  675. // CHECK:STDOUT: !definition:
  676. // CHECK:STDOUT:
  677. // CHECK:STDOUT: fn() -> %empty_struct_type {
  678. // CHECK:STDOUT: !entry:
  679. // CHECK:STDOUT: %.loc19_11.1: %empty_struct_type = struct_literal ()
  680. // CHECK:STDOUT: %.loc19_11.2: init %empty_struct_type = struct_init () to %return [concrete = constants.%empty_struct]
  681. // CHECK:STDOUT: %.loc19_12: init %empty_struct_type = converted %.loc19_11.1, %.loc19_11.2 [concrete = constants.%empty_struct]
  682. // CHECK:STDOUT: return %.loc19_12 to %return
  683. // CHECK:STDOUT: }
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT:
  686. // CHECK:STDOUT: specific @F(constants.%AB) {
  687. // CHECK:STDOUT: %AB.loc14_6.1 => constants.%AB
  688. // CHECK:STDOUT: %AB.as_type.loc14_49.1 => constants.%AB.as_type
  689. // CHECK:STDOUT: %A.lookup_impl_witness => constants.%A.lookup_impl_witness.d9a
  690. // CHECK:STDOUT: }
  691. // CHECK:STDOUT:
  692. // CHECK:STDOUT: specific @G(constants.%AB) {
  693. // CHECK:STDOUT: %AB.loc18_6.1 => constants.%AB
  694. // CHECK:STDOUT: %AB.as_type.loc18_49.1 => constants.%AB.as_type
  695. // CHECK:STDOUT: %B.lookup_impl_witness => constants.%B.lookup_impl_witness.628
  696. // CHECK:STDOUT: }
  697. // CHECK:STDOUT: