impl_thunk.carbon 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  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. // EXTRA-ARGS: --no-prelude-import
  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/impl/impl_thunk.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/impl_thunk.carbon
  12. // --- no_thunk_param_name_differs.carbon
  13. library "[[@TEST_NAME]]";
  14. interface I { fn F(x: Self); }
  15. // This is OK, and does not require a thunk despite the parameter name differing.
  16. class C {
  17. impl as I {
  18. fn F(not_x: C);
  19. }
  20. }
  21. // --- struct_conversion.carbon
  22. library "[[@TEST_NAME]]";
  23. interface I {
  24. fn F(x: {.a: (), .b: {}}) -> {.c: (), .d: {}};
  25. }
  26. impl () as I {
  27. //@dump-sem-ir-begin
  28. fn F(y: {.b: {}, .a: ()}) -> {.d: {}, .c: ()};
  29. //@dump-sem-ir-end
  30. }
  31. // --- inheritance_conversion.carbon
  32. library "[[@TEST_NAME]]";
  33. base class A {}
  34. base class B { extend base: A; }
  35. class C { extend base: B; }
  36. interface X {
  37. fn F[addr self: Self*](other: Self*) -> Self*;
  38. }
  39. impl B as X {
  40. //@dump-sem-ir-begin
  41. fn F[addr self: A*](other: A*) -> C*;
  42. //@dump-sem-ir-end
  43. }
  44. // --- inheritance_value_conversion.carbon
  45. library "[[@TEST_NAME]]";
  46. base class A {}
  47. class B { extend base: A; }
  48. interface X {
  49. fn F[self: Self](other: Self);
  50. }
  51. impl B as X {
  52. //@dump-sem-ir-begin
  53. fn F[self: A](other: A);
  54. //@dump-sem-ir-end
  55. }
  56. // --- inheritance_value_conversion_pointer.carbon
  57. library "[[@TEST_NAME]]";
  58. base class A {}
  59. base class B { extend base: A; }
  60. class C { extend base: B; }
  61. interface X {
  62. fn F[addr self: Self*](other: Self*) -> Self*;
  63. }
  64. impl B as X {
  65. //@dump-sem-ir-begin
  66. fn F[addr self: A*](other: A*) -> C*;
  67. //@dump-sem-ir-end
  68. }
  69. // --- fail_inheritance_value_conversion_copy_return.carbon
  70. library "[[@TEST_NAME]]";
  71. base class A {}
  72. class B { extend base: A; }
  73. interface X {
  74. fn F() -> Self;
  75. }
  76. impl A as X {
  77. //@dump-sem-ir-begin
  78. // CHECK:STDERR: fail_inheritance_value_conversion_copy_return.carbon:[[@LINE+7]]:3: error: cannot copy value of type `A` [CopyOfUncopyableType]
  79. // CHECK:STDERR: fn F() -> B;
  80. // CHECK:STDERR: ^~~~~~~~~~~~
  81. // CHECK:STDERR: fail_inheritance_value_conversion_copy_return.carbon:[[@LINE-8]]:3: note: while building thunk to match the signature of this function [ThunkSignature]
  82. // CHECK:STDERR: fn F() -> Self;
  83. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  84. // CHECK:STDERR:
  85. fn F() -> B;
  86. //@dump-sem-ir-end
  87. }
  88. // --- fail_param_type_mismatch.carbon
  89. library "[[@TEST_NAME]]";
  90. interface I {
  91. // CHECK:STDERR: fail_param_type_mismatch.carbon:[[@LINE+3]]:8: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
  92. // CHECK:STDERR: fn F(a: Self);
  93. // CHECK:STDERR: ^~~~~~~
  94. fn F(a: Self);
  95. }
  96. class A {}
  97. class B {}
  98. impl A as I {
  99. // CHECK:STDERR: fail_param_type_mismatch.carbon:[[@LINE+7]]:8: note: initializing function parameter [InCallToFunctionParam]
  100. // CHECK:STDERR: fn F(a: B);
  101. // CHECK:STDERR: ^~~~
  102. // CHECK:STDERR: fail_param_type_mismatch.carbon:[[@LINE-10]]:3: note: while building thunk to match the signature of this function [ThunkSignature]
  103. // CHECK:STDERR: fn F(a: Self);
  104. // CHECK:STDERR: ^~~~~~~~~~~~~~
  105. // CHECK:STDERR:
  106. fn F(a: B);
  107. }
  108. // --- fail_return_mismatch.carbon
  109. library "[[@TEST_NAME]]";
  110. interface I {
  111. fn F() -> Self;
  112. }
  113. class A {}
  114. class B {}
  115. impl A as I {
  116. // CHECK:STDERR: fail_return_mismatch.carbon:[[@LINE+7]]:3: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
  117. // CHECK:STDERR: fn F() -> B;
  118. // CHECK:STDERR: ^~~~~~~~~~~~
  119. // CHECK:STDERR: fail_return_mismatch.carbon:[[@LINE-10]]:3: note: while building thunk to match the signature of this function [ThunkSignature]
  120. // CHECK:STDERR: fn F() -> Self;
  121. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  122. // CHECK:STDERR:
  123. fn F() -> B;
  124. }
  125. // --- return_empty_tuple_mismatch_allowed.carbon
  126. library "[[@TEST_NAME]]";
  127. interface I {
  128. fn HasReturn() -> Self;
  129. fn NoReturn();
  130. fn EmptyTupleReturn() -> ();
  131. }
  132. impl () as I {
  133. // OK, can `return HasReturn();` in thunk.
  134. fn HasReturn();
  135. // OK, exact match.
  136. fn NoReturn();
  137. // OK, same as `HasReturn`.
  138. fn EmptyTupleReturn();
  139. }
  140. // --- fail_return_empty_tuple_mismatch.carbon
  141. library "[[@TEST_NAME]]";
  142. interface I {
  143. fn NoReturn();
  144. }
  145. impl () as I {
  146. // TODO: The proposal says to reject this. But should we really do so?
  147. // CHECK:STDERR: fail_return_empty_tuple_mismatch.carbon:[[@LINE+7]]:3: error: function redeclaration differs because return type is `()` [FunctionRedeclReturnTypeDiffers]
  148. // CHECK:STDERR: fn NoReturn() -> ();
  149. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  150. // CHECK:STDERR: fail_return_empty_tuple_mismatch.carbon:[[@LINE-8]]:3: note: previously declared with no return type [FunctionRedeclReturnTypePreviousNoReturn]
  151. // CHECK:STDERR: fn NoReturn();
  152. // CHECK:STDERR: ^~~~~~~~~~~~~~
  153. // CHECK:STDERR:
  154. fn NoReturn() -> ();
  155. }
  156. class C {}
  157. impl C as I {
  158. // CHECK:STDERR: fail_return_empty_tuple_mismatch.carbon:[[@LINE+7]]:3: error: function redeclaration differs because return type is `C` [FunctionRedeclReturnTypeDiffers]
  159. // CHECK:STDERR: fn NoReturn() -> C;
  160. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  161. // CHECK:STDERR: fail_return_empty_tuple_mismatch.carbon:[[@LINE-21]]:3: note: previously declared with no return type [FunctionRedeclReturnTypePreviousNoReturn]
  162. // CHECK:STDERR: fn NoReturn();
  163. // CHECK:STDERR: ^~~~~~~~~~~~~~
  164. // CHECK:STDERR:
  165. fn NoReturn() -> C;
  166. }
  167. // --- fail_param_type_incomplete.carbon
  168. library "[[@TEST_NAME]]";
  169. interface I(T:! type) {
  170. // CHECK:STDERR: fail_param_type_incomplete.carbon:[[@LINE+3]]:8: error: parameter has incomplete type `B` in function definition [IncompleteTypeInFunctionParam]
  171. // CHECK:STDERR: fn F(a: T);
  172. // CHECK:STDERR: ^~~~
  173. fn F(a: T);
  174. }
  175. // CHECK:STDERR: fail_param_type_incomplete.carbon:[[@LINE+3]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
  176. // CHECK:STDERR: class B;
  177. // CHECK:STDERR: ^~~~~~~~
  178. class B;
  179. class C {
  180. impl as I(B) {
  181. // CHECK:STDERR: fail_param_type_incomplete.carbon:[[@LINE+14]]:5: note: while building thunk calling this function [ThunkCallee]
  182. // CHECK:STDERR: fn F(c: C);
  183. // CHECK:STDERR: ^~~~~~~~~~~
  184. // CHECK:STDERR:
  185. // CHECK:STDERR: fail_param_type_incomplete.carbon:[[@LINE-14]]:8: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
  186. // CHECK:STDERR: fn F(a: T);
  187. // CHECK:STDERR: ^~~~
  188. // CHECK:STDERR: fail_param_type_incomplete.carbon:[[@LINE+7]]:10: note: initializing function parameter [InCallToFunctionParam]
  189. // CHECK:STDERR: fn F(c: C);
  190. // CHECK:STDERR: ^~~~
  191. // CHECK:STDERR: fail_param_type_incomplete.carbon:[[@LINE-20]]:3: note: while building thunk to match the signature of this function [ThunkSignature]
  192. // CHECK:STDERR: fn F(a: T);
  193. // CHECK:STDERR: ^~~~~~~~~~~
  194. // CHECK:STDERR:
  195. fn F(c: C);
  196. }
  197. }
  198. // --- generic_function.carbon
  199. library "[[@TEST_NAME]]";
  200. interface I {
  201. fn F[T:! type](x: T*) -> T*;
  202. }
  203. impl () as I {
  204. //@dump-sem-ir-begin
  205. fn F[U:! type](x: U) -> U { return x; }
  206. //@dump-sem-ir-end
  207. }
  208. // --- fail_todo_generic_method.carbon
  209. library "[[@TEST_NAME]]";
  210. interface I {
  211. fn F[self: Self, T:! type](x: T*) -> T*;
  212. }
  213. // TODO: This fails because `x.(y)`, where `y` is a generic method, fails with
  214. // an "expression cannot be used as a value" error.
  215. impl () as I {
  216. //@dump-sem-ir-begin
  217. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE+7]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
  218. // CHECK:STDERR: fn F[self: (), U:! type](x: U) -> U { return x; }
  219. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  220. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE-10]]:3: note: while building thunk to match the signature of this function [ThunkSignature]
  221. // CHECK:STDERR: fn F[self: Self, T:! type](x: T*) -> T*;
  222. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  223. // CHECK:STDERR:
  224. fn F[self: (), U:! type](x: U) -> U { return x; }
  225. //@dump-sem-ir-end
  226. }
  227. // --- generic_interface.carbon
  228. library "[[@TEST_NAME]]";
  229. interface I(T:! type) {
  230. fn F() -> {.a: T, .b: T};
  231. }
  232. impl () as I({}) {
  233. //@dump-sem-ir-begin
  234. fn F() -> {.b: {}, .a: {}};
  235. //@dump-sem-ir-end
  236. }
  237. // CHECK:STDOUT: --- struct_conversion.carbon
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: constants {
  240. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  241. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  242. // CHECK:STDOUT: %struct_type.a.b.391: type = struct_type {.a: %empty_tuple.type, .b: %empty_struct_type} [concrete]
  243. // CHECK:STDOUT: %struct_type.c.d.15a: type = struct_type {.c: %empty_tuple.type, .d: %empty_struct_type} [concrete]
  244. // CHECK:STDOUT: %struct_type.b.a.40c: type = struct_type {.b: %empty_struct_type, .a: %empty_tuple.type} [concrete]
  245. // CHECK:STDOUT: %pattern_type.231: type = pattern_type %struct_type.b.a.40c [concrete]
  246. // CHECK:STDOUT: %struct_type.d.c.b36: type = struct_type {.d: %empty_struct_type, .c: %empty_tuple.type} [concrete]
  247. // CHECK:STDOUT: %pattern_type.844: type = pattern_type %struct_type.d.c.b36 [concrete]
  248. // CHECK:STDOUT: %F.type.39e918.1: type = fn_type @F.2 [concrete]
  249. // CHECK:STDOUT: %F.c04b92.1: %F.type.39e918.1 = struct_value () [concrete]
  250. // CHECK:STDOUT: %F.type.39e918.2: type = fn_type @F.3 [concrete]
  251. // CHECK:STDOUT: %F.c04b92.2: %F.type.39e918.2 = struct_value () [concrete]
  252. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  253. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  254. // CHECK:STDOUT: %struct: %struct_type.c.d.15a = struct_value (%empty_tuple, %empty_struct) [concrete]
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: impl @impl: %.loc8_7.2 as %I.ref {
  258. // CHECK:STDOUT: %F.decl.loc10_48.1: %F.type.39e918.1 = fn_decl @F.2 [concrete = constants.%F.c04b92.1] {
  259. // CHECK:STDOUT: %y.patt: %pattern_type.231 = binding_pattern y [concrete]
  260. // CHECK:STDOUT: %y.param_patt: %pattern_type.231 = value_param_pattern %y.patt, call_param0 [concrete]
  261. // CHECK:STDOUT: %return.patt: %pattern_type.844 = return_slot_pattern [concrete]
  262. // CHECK:STDOUT: %return.param_patt: %pattern_type.844 = out_param_pattern %return.patt, call_param1 [concrete]
  263. // CHECK:STDOUT: } {
  264. // CHECK:STDOUT: %.loc10_38.1: %empty_struct_type = struct_literal ()
  265. // CHECK:STDOUT: %.loc10_38.2: type = converted %.loc10_38.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  266. // CHECK:STDOUT: %.loc10_46.1: %empty_tuple.type = tuple_literal ()
  267. // CHECK:STDOUT: %.loc10_46.2: type = converted %.loc10_46.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  268. // CHECK:STDOUT: %struct_type.d.c: type = struct_type {.d: %empty_struct_type, .c: %empty_tuple.type} [concrete = constants.%struct_type.d.c.b36]
  269. // CHECK:STDOUT: %y.param: %struct_type.b.a.40c = value_param call_param0
  270. // CHECK:STDOUT: %.loc10_26: type = splice_block %struct_type.b.a [concrete = constants.%struct_type.b.a.40c] {
  271. // CHECK:STDOUT: %.loc10_17.1: %empty_struct_type = struct_literal ()
  272. // CHECK:STDOUT: %.loc10_17.2: type = converted %.loc10_17.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  273. // CHECK:STDOUT: %.loc10_25.1: %empty_tuple.type = tuple_literal ()
  274. // CHECK:STDOUT: %.loc10_25.2: type = converted %.loc10_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  275. // CHECK:STDOUT: %struct_type.b.a: type = struct_type {.b: %empty_struct_type, .a: %empty_tuple.type} [concrete = constants.%struct_type.b.a.40c]
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT: %y: %struct_type.b.a.40c = bind_name y, %y.param
  278. // CHECK:STDOUT: %return.param: ref %struct_type.d.c.b36 = out_param call_param1
  279. // CHECK:STDOUT: %return: ref %struct_type.d.c.b36 = return_slot %return.param
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT: %F.decl.loc10_48.2: %F.type.39e918.2 = fn_decl @F.3 [concrete = constants.%F.c04b92.2] {
  282. // CHECK:STDOUT: <elided>
  283. // CHECK:STDOUT: } {
  284. // CHECK:STDOUT: <elided>
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: !members:
  288. // CHECK:STDOUT: .F = %F.decl.loc10_48.1
  289. // CHECK:STDOUT: witness = file.%I.impl_witness
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: fn @F.2(%y.param: %struct_type.b.a.40c) -> %return.param: %struct_type.d.c.b36;
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: fn @F.3(%x.param: %struct_type.a.b.391) -> %return.param: %struct_type.c.d.15a {
  295. // CHECK:STDOUT: !entry:
  296. // CHECK:STDOUT: %F.ref: %F.type.39e918.1 = name_ref F, @impl.%F.decl.loc10_48.1 [concrete = constants.%F.c04b92.1]
  297. // CHECK:STDOUT: <elided>
  298. // CHECK:STDOUT: %.loc10_48.1: ref %struct_type.d.c.b36 = temporary_storage
  299. // CHECK:STDOUT: <elided>
  300. // CHECK:STDOUT: %F.call: init %struct_type.d.c.b36 = call %F.ref(%.loc5_9.3) to %.loc10_48.1
  301. // CHECK:STDOUT: %.loc10_48.2: ref %struct_type.d.c.b36 = temporary %.loc10_48.1, %F.call
  302. // CHECK:STDOUT: %.loc10_48.3: ref %empty_tuple.type = struct_access %.loc10_48.2, element1
  303. // CHECK:STDOUT: %.loc10_48.4: ref %empty_tuple.type = struct_access %return, element1
  304. // CHECK:STDOUT: %.loc10_48.5: init %empty_tuple.type = tuple_init () to %.loc10_48.4 [concrete = constants.%empty_tuple]
  305. // CHECK:STDOUT: %.loc10_48.6: init %empty_tuple.type = converted %.loc10_48.3, %.loc10_48.5 [concrete = constants.%empty_tuple]
  306. // CHECK:STDOUT: %.loc10_48.7: ref %empty_struct_type = struct_access %.loc10_48.2, element0
  307. // CHECK:STDOUT: %.loc10_48.8: ref %empty_struct_type = struct_access %return, element0
  308. // CHECK:STDOUT: %.loc10_48.9: init %empty_struct_type = struct_init () to %.loc10_48.8 [concrete = constants.%empty_struct]
  309. // CHECK:STDOUT: %.loc10_48.10: init %empty_struct_type = converted %.loc10_48.7, %.loc10_48.9 [concrete = constants.%empty_struct]
  310. // CHECK:STDOUT: %.loc10_48.11: init %struct_type.c.d.15a = struct_init (%.loc10_48.6, %.loc10_48.10) to %return [concrete = constants.%struct]
  311. // CHECK:STDOUT: %.loc10_48.12: init %struct_type.c.d.15a = converted %F.call, %.loc10_48.11 [concrete = constants.%struct]
  312. // CHECK:STDOUT: return %.loc10_48.12 to %return
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: --- inheritance_conversion.carbon
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: constants {
  318. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  319. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  320. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  321. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  322. // CHECK:STDOUT: %ptr.6db: type = ptr_type %A [concrete]
  323. // CHECK:STDOUT: %pattern_type.5f8: type = pattern_type %ptr.6db [concrete]
  324. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  325. // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete]
  326. // CHECK:STDOUT: %F.type.f1b0b1.1: type = fn_type @F.2 [concrete]
  327. // CHECK:STDOUT: %F.5161e9.1: %F.type.f1b0b1.1 = struct_value () [concrete]
  328. // CHECK:STDOUT: %ptr.e79: type = ptr_type %B [concrete]
  329. // CHECK:STDOUT: %F.type.f1b0b1.2: type = fn_type @F.3 [concrete]
  330. // CHECK:STDOUT: %F.5161e9.2: %F.type.f1b0b1.2 = struct_value () [concrete]
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: impl @impl: %B.ref as %X.ref {
  334. // CHECK:STDOUT: %F.decl.loc14_39.1: %F.type.f1b0b1.1 = fn_decl @F.2 [concrete = constants.%F.5161e9.1] {
  335. // CHECK:STDOUT: %self.patt: %pattern_type.5f8 = binding_pattern self [concrete]
  336. // CHECK:STDOUT: %self.param_patt: %pattern_type.5f8 = value_param_pattern %self.patt, call_param0 [concrete]
  337. // CHECK:STDOUT: %.loc14_8: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  338. // CHECK:STDOUT: %other.patt: %pattern_type.5f8 = binding_pattern other [concrete]
  339. // CHECK:STDOUT: %other.param_patt: %pattern_type.5f8 = value_param_pattern %other.patt, call_param1 [concrete]
  340. // CHECK:STDOUT: %return.patt: %pattern_type.44a = return_slot_pattern [concrete]
  341. // CHECK:STDOUT: %return.param_patt: %pattern_type.44a = out_param_pattern %return.patt, call_param2 [concrete]
  342. // CHECK:STDOUT: } {
  343. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  344. // CHECK:STDOUT: %ptr.loc14_38: type = ptr_type %C.ref [concrete = constants.%ptr.019]
  345. // CHECK:STDOUT: %self.param: %ptr.6db = value_param call_param0
  346. // CHECK:STDOUT: %.loc14_20: type = splice_block %ptr.loc14_20 [concrete = constants.%ptr.6db] {
  347. // CHECK:STDOUT: %A.ref.loc14_19: type = name_ref A, file.%A.decl [concrete = constants.%A]
  348. // CHECK:STDOUT: %ptr.loc14_20: type = ptr_type %A.ref.loc14_19 [concrete = constants.%ptr.6db]
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT: %self: %ptr.6db = bind_name self, %self.param
  351. // CHECK:STDOUT: %other.param: %ptr.6db = value_param call_param1
  352. // CHECK:STDOUT: %.loc14_31: type = splice_block %ptr.loc14_31 [concrete = constants.%ptr.6db] {
  353. // CHECK:STDOUT: %A.ref.loc14_30: type = name_ref A, file.%A.decl [concrete = constants.%A]
  354. // CHECK:STDOUT: %ptr.loc14_31: type = ptr_type %A.ref.loc14_30 [concrete = constants.%ptr.6db]
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT: %other: %ptr.6db = bind_name other, %other.param
  357. // CHECK:STDOUT: %return.param: ref %ptr.019 = out_param call_param2
  358. // CHECK:STDOUT: %return: ref %ptr.019 = return_slot %return.param
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT: %F.decl.loc14_39.2: %F.type.f1b0b1.2 = fn_decl @F.3 [concrete = constants.%F.5161e9.2] {
  361. // CHECK:STDOUT: <elided>
  362. // CHECK:STDOUT: } {
  363. // CHECK:STDOUT: <elided>
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: !members:
  367. // CHECK:STDOUT: .A = <poisoned>
  368. // CHECK:STDOUT: .C = <poisoned>
  369. // CHECK:STDOUT: .F = %F.decl.loc14_39.1
  370. // CHECK:STDOUT: witness = file.%X.impl_witness
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT:
  373. // CHECK:STDOUT: fn @F.2(%self.param: %ptr.6db, %other.param: %ptr.6db) -> %ptr.019;
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: fn @F.3(%self.param: %ptr.e79, %other.param: %ptr.e79) -> %ptr.e79 {
  376. // CHECK:STDOUT: !entry:
  377. // CHECK:STDOUT: %F.ref: %F.type.f1b0b1.1 = name_ref F, @impl.%F.decl.loc14_39.1 [concrete = constants.%F.5161e9.1]
  378. // CHECK:STDOUT: <elided>
  379. // CHECK:STDOUT: %F.bound: <bound method> = bound_method %.loc9_17.1, %F.ref
  380. // CHECK:STDOUT: <elided>
  381. // CHECK:STDOUT: %F.call: init %ptr.019 = call %F.bound(%.loc9_17.4, %.loc9_31.3)
  382. // CHECK:STDOUT: %.loc14_39.1: %ptr.019 = value_of_initializer %F.call
  383. // CHECK:STDOUT: %.loc14_39.2: %ptr.019 = converted %F.call, %.loc14_39.1
  384. // CHECK:STDOUT: %.loc14_39.3: ref %C = deref %.loc14_39.2
  385. // CHECK:STDOUT: %.loc14_39.4: ref %B = class_element_access %.loc14_39.3, element0
  386. // CHECK:STDOUT: %addr.loc14: %ptr.e79 = addr_of %.loc14_39.4
  387. // CHECK:STDOUT: %.loc14_39.5: %ptr.e79 = converted %F.call, %addr.loc14
  388. // CHECK:STDOUT: return %.loc14_39.5
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: --- inheritance_value_conversion.carbon
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: constants {
  394. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  395. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  396. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  397. // CHECK:STDOUT: %pattern_type.c10: type = pattern_type %A [concrete]
  398. // CHECK:STDOUT: %F.type.f1b0b1.1: type = fn_type @F.2 [concrete]
  399. // CHECK:STDOUT: %F.5161e9.1: %F.type.f1b0b1.1 = struct_value () [concrete]
  400. // CHECK:STDOUT: %F.type.f1b0b1.2: type = fn_type @F.3 [concrete]
  401. // CHECK:STDOUT: %F.5161e9.2: %F.type.f1b0b1.2 = struct_value () [concrete]
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: impl @impl: %B.ref as %X.ref {
  405. // CHECK:STDOUT: %F.decl.loc13_26.1: %F.type.f1b0b1.1 = fn_decl @F.2 [concrete = constants.%F.5161e9.1] {
  406. // CHECK:STDOUT: %self.patt: %pattern_type.c10 = binding_pattern self [concrete]
  407. // CHECK:STDOUT: %self.param_patt: %pattern_type.c10 = value_param_pattern %self.patt, call_param0 [concrete]
  408. // CHECK:STDOUT: %other.patt: %pattern_type.c10 = binding_pattern other [concrete]
  409. // CHECK:STDOUT: %other.param_patt: %pattern_type.c10 = value_param_pattern %other.patt, call_param1 [concrete]
  410. // CHECK:STDOUT: } {
  411. // CHECK:STDOUT: %self.param: %A = value_param call_param0
  412. // CHECK:STDOUT: %A.ref.loc13_14: type = name_ref A, file.%A.decl [concrete = constants.%A]
  413. // CHECK:STDOUT: %self: %A = bind_name self, %self.param
  414. // CHECK:STDOUT: %other.param: %A = value_param call_param1
  415. // CHECK:STDOUT: %A.ref.loc13_24: type = name_ref A, file.%A.decl [concrete = constants.%A]
  416. // CHECK:STDOUT: %other: %A = bind_name other, %other.param
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT: %F.decl.loc13_26.2: %F.type.f1b0b1.2 = fn_decl @F.3 [concrete = constants.%F.5161e9.2] {
  419. // CHECK:STDOUT: <elided>
  420. // CHECK:STDOUT: } {
  421. // CHECK:STDOUT: <elided>
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: !members:
  425. // CHECK:STDOUT: .A = <poisoned>
  426. // CHECK:STDOUT: .F = %F.decl.loc13_26.1
  427. // CHECK:STDOUT: witness = file.%X.impl_witness
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: fn @F.2(%self.param: %A, %other.param: %A);
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: fn @F.3(%self.param: %B, %other.param: %B) {
  433. // CHECK:STDOUT: !entry:
  434. // CHECK:STDOUT: %F.ref: %F.type.f1b0b1.1 = name_ref F, @impl.%F.decl.loc13_26.1 [concrete = constants.%F.5161e9.1]
  435. // CHECK:STDOUT: <elided>
  436. // CHECK:STDOUT: %F.bound: <bound method> = bound_method %self.ref, %F.ref
  437. // CHECK:STDOUT: <elided>
  438. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.bound(%.loc8_12.3, %.loc8_25.3)
  439. // CHECK:STDOUT: return
  440. // CHECK:STDOUT: }
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: --- inheritance_value_conversion_pointer.carbon
  443. // CHECK:STDOUT:
  444. // CHECK:STDOUT: constants {
  445. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  446. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  447. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  448. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  449. // CHECK:STDOUT: %ptr.6db: type = ptr_type %A [concrete]
  450. // CHECK:STDOUT: %pattern_type.5f8: type = pattern_type %ptr.6db [concrete]
  451. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  452. // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete]
  453. // CHECK:STDOUT: %F.type.f1b0b1.1: type = fn_type @F.2 [concrete]
  454. // CHECK:STDOUT: %F.5161e9.1: %F.type.f1b0b1.1 = struct_value () [concrete]
  455. // CHECK:STDOUT: %ptr.e79: type = ptr_type %B [concrete]
  456. // CHECK:STDOUT: %F.type.f1b0b1.2: type = fn_type @F.3 [concrete]
  457. // CHECK:STDOUT: %F.5161e9.2: %F.type.f1b0b1.2 = struct_value () [concrete]
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT:
  460. // CHECK:STDOUT: impl @impl: %B.ref as %X.ref {
  461. // CHECK:STDOUT: %F.decl.loc14_39.1: %F.type.f1b0b1.1 = fn_decl @F.2 [concrete = constants.%F.5161e9.1] {
  462. // CHECK:STDOUT: %self.patt: %pattern_type.5f8 = binding_pattern self [concrete]
  463. // CHECK:STDOUT: %self.param_patt: %pattern_type.5f8 = value_param_pattern %self.patt, call_param0 [concrete]
  464. // CHECK:STDOUT: %.loc14_8: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  465. // CHECK:STDOUT: %other.patt: %pattern_type.5f8 = binding_pattern other [concrete]
  466. // CHECK:STDOUT: %other.param_patt: %pattern_type.5f8 = value_param_pattern %other.patt, call_param1 [concrete]
  467. // CHECK:STDOUT: %return.patt: %pattern_type.44a = return_slot_pattern [concrete]
  468. // CHECK:STDOUT: %return.param_patt: %pattern_type.44a = out_param_pattern %return.patt, call_param2 [concrete]
  469. // CHECK:STDOUT: } {
  470. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  471. // CHECK:STDOUT: %ptr.loc14_38: type = ptr_type %C.ref [concrete = constants.%ptr.019]
  472. // CHECK:STDOUT: %self.param: %ptr.6db = value_param call_param0
  473. // CHECK:STDOUT: %.loc14_20: type = splice_block %ptr.loc14_20 [concrete = constants.%ptr.6db] {
  474. // CHECK:STDOUT: %A.ref.loc14_19: type = name_ref A, file.%A.decl [concrete = constants.%A]
  475. // CHECK:STDOUT: %ptr.loc14_20: type = ptr_type %A.ref.loc14_19 [concrete = constants.%ptr.6db]
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT: %self: %ptr.6db = bind_name self, %self.param
  478. // CHECK:STDOUT: %other.param: %ptr.6db = value_param call_param1
  479. // CHECK:STDOUT: %.loc14_31: type = splice_block %ptr.loc14_31 [concrete = constants.%ptr.6db] {
  480. // CHECK:STDOUT: %A.ref.loc14_30: type = name_ref A, file.%A.decl [concrete = constants.%A]
  481. // CHECK:STDOUT: %ptr.loc14_31: type = ptr_type %A.ref.loc14_30 [concrete = constants.%ptr.6db]
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT: %other: %ptr.6db = bind_name other, %other.param
  484. // CHECK:STDOUT: %return.param: ref %ptr.019 = out_param call_param2
  485. // CHECK:STDOUT: %return: ref %ptr.019 = return_slot %return.param
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT: %F.decl.loc14_39.2: %F.type.f1b0b1.2 = fn_decl @F.3 [concrete = constants.%F.5161e9.2] {
  488. // CHECK:STDOUT: <elided>
  489. // CHECK:STDOUT: } {
  490. // CHECK:STDOUT: <elided>
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT:
  493. // CHECK:STDOUT: !members:
  494. // CHECK:STDOUT: .A = <poisoned>
  495. // CHECK:STDOUT: .C = <poisoned>
  496. // CHECK:STDOUT: .F = %F.decl.loc14_39.1
  497. // CHECK:STDOUT: witness = file.%X.impl_witness
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: fn @F.2(%self.param: %ptr.6db, %other.param: %ptr.6db) -> %ptr.019;
  501. // CHECK:STDOUT:
  502. // CHECK:STDOUT: fn @F.3(%self.param: %ptr.e79, %other.param: %ptr.e79) -> %ptr.e79 {
  503. // CHECK:STDOUT: !entry:
  504. // CHECK:STDOUT: %F.ref: %F.type.f1b0b1.1 = name_ref F, @impl.%F.decl.loc14_39.1 [concrete = constants.%F.5161e9.1]
  505. // CHECK:STDOUT: <elided>
  506. // CHECK:STDOUT: %F.bound: <bound method> = bound_method %.loc9_17.1, %F.ref
  507. // CHECK:STDOUT: <elided>
  508. // CHECK:STDOUT: %F.call: init %ptr.019 = call %F.bound(%.loc9_17.4, %.loc9_31.3)
  509. // CHECK:STDOUT: %.loc14_39.1: %ptr.019 = value_of_initializer %F.call
  510. // CHECK:STDOUT: %.loc14_39.2: %ptr.019 = converted %F.call, %.loc14_39.1
  511. // CHECK:STDOUT: %.loc14_39.3: ref %C = deref %.loc14_39.2
  512. // CHECK:STDOUT: %.loc14_39.4: ref %B = class_element_access %.loc14_39.3, element0
  513. // CHECK:STDOUT: %addr.loc14: %ptr.e79 = addr_of %.loc14_39.4
  514. // CHECK:STDOUT: %.loc14_39.5: %ptr.e79 = converted %F.call, %addr.loc14
  515. // CHECK:STDOUT: return %.loc14_39.5
  516. // CHECK:STDOUT: }
  517. // CHECK:STDOUT:
  518. // CHECK:STDOUT: --- fail_inheritance_value_conversion_copy_return.carbon
  519. // CHECK:STDOUT:
  520. // CHECK:STDOUT: constants {
  521. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  522. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  523. // CHECK:STDOUT: %pattern_type.049: type = pattern_type %B [concrete]
  524. // CHECK:STDOUT: %F.type.b24d6f.1: type = fn_type @F.2 [concrete]
  525. // CHECK:STDOUT: %F.77e9d5.1: %F.type.b24d6f.1 = struct_value () [concrete]
  526. // CHECK:STDOUT: %F.type.b24d6f.2: type = fn_type @F.3 [concrete]
  527. // CHECK:STDOUT: %F.77e9d5.2: %F.type.b24d6f.2 = struct_value () [concrete]
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: impl @impl: %A.ref as %X.ref {
  531. // CHECK:STDOUT: %F.decl.loc20_14.1: %F.type.b24d6f.1 = fn_decl @F.2 [concrete = constants.%F.77e9d5.1] {
  532. // CHECK:STDOUT: %return.patt: %pattern_type.049 = return_slot_pattern [concrete]
  533. // CHECK:STDOUT: %return.param_patt: %pattern_type.049 = out_param_pattern %return.patt, call_param0 [concrete]
  534. // CHECK:STDOUT: } {
  535. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  536. // CHECK:STDOUT: %return.param: ref %B = out_param call_param0
  537. // CHECK:STDOUT: %return: ref %B = return_slot %return.param
  538. // CHECK:STDOUT: }
  539. // CHECK:STDOUT: %F.decl.loc20_14.2: %F.type.b24d6f.2 = fn_decl @F.3 [concrete = constants.%F.77e9d5.2] {
  540. // CHECK:STDOUT: <elided>
  541. // CHECK:STDOUT: } {
  542. // CHECK:STDOUT: <elided>
  543. // CHECK:STDOUT: }
  544. // CHECK:STDOUT:
  545. // CHECK:STDOUT: !members:
  546. // CHECK:STDOUT: .B = <poisoned>
  547. // CHECK:STDOUT: .F = %F.decl.loc20_14.1
  548. // CHECK:STDOUT: witness = file.%X.impl_witness
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: fn @F.2() -> %return.param: %B;
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: fn @F.3() -> %return.param: %A {
  554. // CHECK:STDOUT: !entry:
  555. // CHECK:STDOUT: %F.ref: %F.type.b24d6f.1 = name_ref F, @impl.%F.decl.loc20_14.1 [concrete = constants.%F.77e9d5.1]
  556. // CHECK:STDOUT: %.loc20_14.1: ref %B = temporary_storage
  557. // CHECK:STDOUT: %F.call: init %B = call %F.ref() to %.loc20_14.1
  558. // CHECK:STDOUT: %.loc20_14.2: ref %B = temporary %.loc20_14.1, %F.call
  559. // CHECK:STDOUT: %.loc20_14.3: ref %A = class_element_access %.loc20_14.2, element0
  560. // CHECK:STDOUT: %.loc20_14.4: ref %A = converted %F.call, %.loc20_14.3
  561. // CHECK:STDOUT: %.loc20_14.5: %A = bind_value %.loc20_14.4
  562. // CHECK:STDOUT: return <error> to %return
  563. // CHECK:STDOUT: }
  564. // CHECK:STDOUT:
  565. // CHECK:STDOUT: --- generic_function.carbon
  566. // CHECK:STDOUT:
  567. // CHECK:STDOUT: constants {
  568. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  569. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic]
  570. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %U [symbolic]
  571. // CHECK:STDOUT: %F.type.39e918.1: type = fn_type @F.2 [concrete]
  572. // CHECK:STDOUT: %F.c04b92.1: %F.type.39e918.1 = struct_value () [concrete]
  573. // CHECK:STDOUT: %T.8b3: type = bind_symbolic_name T, 0 [symbolic]
  574. // CHECK:STDOUT: %ptr.79f: type = ptr_type %T.8b3 [symbolic]
  575. // CHECK:STDOUT: %pattern_type.afe: type = pattern_type %ptr.79f [symbolic]
  576. // CHECK:STDOUT: %F.type.39e918.2: type = fn_type @F.3 [concrete]
  577. // CHECK:STDOUT: %F.c04b92.2: %F.type.39e918.2 = struct_value () [concrete]
  578. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %U [symbolic]
  579. // CHECK:STDOUT: %require_complete.6e5: <witness> = require_complete_type %ptr.79f [symbolic]
  580. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.c04b92.1, @F.2(%ptr.79f) [symbolic]
  581. // CHECK:STDOUT: }
  582. // CHECK:STDOUT:
  583. // CHECK:STDOUT: impl @impl: %.loc8_7.2 as %I.ref {
  584. // CHECK:STDOUT: %F.decl.loc10_29.1: %F.type.39e918.1 = fn_decl @F.2 [concrete = constants.%F.c04b92.1] {
  585. // CHECK:STDOUT: %U.patt: %pattern_type.98f = symbolic_binding_pattern U, 0 [concrete]
  586. // CHECK:STDOUT: %x.patt: @F.2.%pattern_type (%pattern_type.7dc) = binding_pattern x [concrete]
  587. // CHECK:STDOUT: %x.param_patt: @F.2.%pattern_type (%pattern_type.7dc) = value_param_pattern %x.patt, call_param0 [concrete]
  588. // CHECK:STDOUT: %return.patt: @F.2.%pattern_type (%pattern_type.7dc) = return_slot_pattern [concrete]
  589. // CHECK:STDOUT: %return.param_patt: @F.2.%pattern_type (%pattern_type.7dc) = out_param_pattern %return.patt, call_param1 [concrete]
  590. // CHECK:STDOUT: } {
  591. // CHECK:STDOUT: %U.ref.loc10_27: type = name_ref U, %U.loc10_8.2 [symbolic = %U.loc10_8.1 (constants.%U)]
  592. // CHECK:STDOUT: %U.loc10_8.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc10_8.1 (constants.%U)]
  593. // CHECK:STDOUT: %x.param: @F.2.%U.loc10_8.1 (%U) = value_param call_param0
  594. // CHECK:STDOUT: %U.ref.loc10_21: type = name_ref U, %U.loc10_8.2 [symbolic = %U.loc10_8.1 (constants.%U)]
  595. // CHECK:STDOUT: %x: @F.2.%U.loc10_8.1 (%U) = bind_name x, %x.param
  596. // CHECK:STDOUT: %return.param: ref @F.2.%U.loc10_8.1 (%U) = out_param call_param1
  597. // CHECK:STDOUT: %return: ref @F.2.%U.loc10_8.1 (%U) = return_slot %return.param
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT: %F.decl.loc10_29.2: %F.type.39e918.2 = fn_decl @F.3 [concrete = constants.%F.c04b92.2] {
  600. // CHECK:STDOUT: <elided>
  601. // CHECK:STDOUT: } {
  602. // CHECK:STDOUT: <elided>
  603. // CHECK:STDOUT: }
  604. // CHECK:STDOUT:
  605. // CHECK:STDOUT: !members:
  606. // CHECK:STDOUT: .F = %F.decl.loc10_29.1
  607. // CHECK:STDOUT: witness = file.%I.impl_witness
  608. // CHECK:STDOUT: }
  609. // CHECK:STDOUT:
  610. // CHECK:STDOUT: generic fn @F.2(%U.loc10_8.2: type) {
  611. // CHECK:STDOUT: %U.loc10_8.1: type = bind_symbolic_name U, 0 [symbolic = %U.loc10_8.1 (constants.%U)]
  612. // CHECK:STDOUT: %pattern_type: type = pattern_type %U.loc10_8.1 [symbolic = %pattern_type (constants.%pattern_type.7dc)]
  613. // CHECK:STDOUT:
  614. // CHECK:STDOUT: !definition:
  615. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %U.loc10_8.1 [symbolic = %require_complete (constants.%require_complete.4ae)]
  616. // CHECK:STDOUT:
  617. // CHECK:STDOUT: fn(%x.param: @F.2.%U.loc10_8.1 (%U)) -> @F.2.%U.loc10_8.1 (%U) {
  618. // CHECK:STDOUT: !entry:
  619. // CHECK:STDOUT: %x.ref: @F.2.%U.loc10_8.1 (%U) = name_ref x, %x
  620. // CHECK:STDOUT: return %x.ref
  621. // CHECK:STDOUT: }
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT:
  624. // CHECK:STDOUT: generic fn @F.3(%T.loc5_8.2: type) {
  625. // CHECK:STDOUT: <elided>
  626. // CHECK:STDOUT:
  627. // CHECK:STDOUT: !definition:
  628. // CHECK:STDOUT: %F.specific_fn.loc10_29.2: <specific function> = specific_function constants.%F.c04b92.1, @F.2(%ptr) [symbolic = %F.specific_fn.loc10_29.2 (constants.%F.specific_fn)]
  629. // CHECK:STDOUT: <elided>
  630. // CHECK:STDOUT:
  631. // CHECK:STDOUT: fn(%x.param: @F.3.%ptr (%ptr.79f)) -> @F.3.%ptr (%ptr.79f) {
  632. // CHECK:STDOUT: !entry:
  633. // CHECK:STDOUT: %F.ref: %F.type.39e918.1 = name_ref F, @impl.%F.decl.loc10_29.1 [concrete = constants.%F.c04b92.1]
  634. // CHECK:STDOUT: <elided>
  635. // CHECK:STDOUT: %F.specific_fn.loc10_29.1: <specific function> = specific_function %F.ref, @F.2(constants.%ptr.79f) [symbolic = %F.specific_fn.loc10_29.2 (constants.%F.specific_fn)]
  636. // CHECK:STDOUT: %F.call: init @F.3.%ptr (%ptr.79f) = call %F.specific_fn.loc10_29.1(%x.ref)
  637. // CHECK:STDOUT: %.loc10_29.1: @F.3.%ptr (%ptr.79f) = value_of_initializer %F.call
  638. // CHECK:STDOUT: %.loc10_29.2: @F.3.%ptr (%ptr.79f) = converted %F.call, %.loc10_29.1
  639. // CHECK:STDOUT: return %.loc10_29.2
  640. // CHECK:STDOUT: }
  641. // CHECK:STDOUT: }
  642. // CHECK:STDOUT:
  643. // CHECK:STDOUT: specific @F.2(constants.%U) {
  644. // CHECK:STDOUT: %U.loc10_8.1 => constants.%U
  645. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dc
  646. // CHECK:STDOUT: }
  647. // CHECK:STDOUT:
  648. // CHECK:STDOUT: specific @F.3(constants.%T.8b3) {
  649. // CHECK:STDOUT: %T.loc5_8.1 => constants.%T.8b3
  650. // CHECK:STDOUT: %ptr => constants.%ptr.79f
  651. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.afe
  652. // CHECK:STDOUT: }
  653. // CHECK:STDOUT:
  654. // CHECK:STDOUT: specific @F.2(constants.%ptr.79f) {
  655. // CHECK:STDOUT: %U.loc10_8.1 => constants.%ptr.79f
  656. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.afe
  657. // CHECK:STDOUT:
  658. // CHECK:STDOUT: !definition:
  659. // CHECK:STDOUT: %require_complete => constants.%require_complete.6e5
  660. // CHECK:STDOUT: }
  661. // CHECK:STDOUT:
  662. // CHECK:STDOUT: --- fail_todo_generic_method.carbon
  663. // CHECK:STDOUT:
  664. // CHECK:STDOUT: constants {
  665. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  666. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  667. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  668. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic]
  669. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %U [symbolic]
  670. // CHECK:STDOUT: %F.type.39e918.1: type = fn_type @F.2 [concrete]
  671. // CHECK:STDOUT: %F.c04b92.1: %F.type.39e918.1 = struct_value () [concrete]
  672. // CHECK:STDOUT: %T.8b3: type = bind_symbolic_name T, 0 [symbolic]
  673. // CHECK:STDOUT: %ptr.79f: type = ptr_type %T.8b3 [symbolic]
  674. // CHECK:STDOUT: %pattern_type.afe: type = pattern_type %ptr.79f [symbolic]
  675. // CHECK:STDOUT: %F.type.39e918.2: type = fn_type @F.3 [concrete]
  676. // CHECK:STDOUT: %F.c04b92.2: %F.type.39e918.2 = struct_value () [concrete]
  677. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %U [symbolic]
  678. // CHECK:STDOUT: }
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: impl @impl: %.loc10_7.2 as %I.ref {
  681. // CHECK:STDOUT: %F.decl.loc19_39.1: %F.type.39e918.1 = fn_decl @F.2 [concrete = constants.%F.c04b92.1] {
  682. // CHECK:STDOUT: %self.patt: %pattern_type.cb1 = binding_pattern self [concrete]
  683. // CHECK:STDOUT: %self.param_patt: %pattern_type.cb1 = value_param_pattern %self.patt, call_param0 [concrete]
  684. // CHECK:STDOUT: %U.patt: %pattern_type.98f = symbolic_binding_pattern U, 0 [concrete]
  685. // CHECK:STDOUT: %x.patt: @F.2.%pattern_type (%pattern_type.7dc) = binding_pattern x [concrete]
  686. // CHECK:STDOUT: %x.param_patt: @F.2.%pattern_type (%pattern_type.7dc) = value_param_pattern %x.patt, call_param1 [concrete]
  687. // CHECK:STDOUT: %return.patt: @F.2.%pattern_type (%pattern_type.7dc) = return_slot_pattern [concrete]
  688. // CHECK:STDOUT: %return.param_patt: @F.2.%pattern_type (%pattern_type.7dc) = out_param_pattern %return.patt, call_param2 [concrete]
  689. // CHECK:STDOUT: } {
  690. // CHECK:STDOUT: %U.ref.loc19_37: type = name_ref U, %U.loc19_18.2 [symbolic = %U.loc19_18.1 (constants.%U)]
  691. // CHECK:STDOUT: %self.param: %empty_tuple.type = value_param call_param0
  692. // CHECK:STDOUT: %.loc19_15.1: type = splice_block %.loc19_15.3 [concrete = constants.%empty_tuple.type] {
  693. // CHECK:STDOUT: %.loc19_15.2: %empty_tuple.type = tuple_literal ()
  694. // CHECK:STDOUT: %.loc19_15.3: type = converted %.loc19_15.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  695. // CHECK:STDOUT: }
  696. // CHECK:STDOUT: %self: %empty_tuple.type = bind_name self, %self.param
  697. // CHECK:STDOUT: %U.loc19_18.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc19_18.1 (constants.%U)]
  698. // CHECK:STDOUT: %x.param: @F.2.%U.loc19_18.1 (%U) = value_param call_param1
  699. // CHECK:STDOUT: %U.ref.loc19_31: type = name_ref U, %U.loc19_18.2 [symbolic = %U.loc19_18.1 (constants.%U)]
  700. // CHECK:STDOUT: %x: @F.2.%U.loc19_18.1 (%U) = bind_name x, %x.param
  701. // CHECK:STDOUT: %return.param: ref @F.2.%U.loc19_18.1 (%U) = out_param call_param2
  702. // CHECK:STDOUT: %return: ref @F.2.%U.loc19_18.1 (%U) = return_slot %return.param
  703. // CHECK:STDOUT: }
  704. // CHECK:STDOUT: %F.decl.loc19_39.2: %F.type.39e918.2 = fn_decl @F.3 [concrete = constants.%F.c04b92.2] {
  705. // CHECK:STDOUT: <elided>
  706. // CHECK:STDOUT: } {
  707. // CHECK:STDOUT: <elided>
  708. // CHECK:STDOUT: }
  709. // CHECK:STDOUT:
  710. // CHECK:STDOUT: !members:
  711. // CHECK:STDOUT: .F = %F.decl.loc19_39.1
  712. // CHECK:STDOUT: witness = file.%I.impl_witness
  713. // CHECK:STDOUT: }
  714. // CHECK:STDOUT:
  715. // CHECK:STDOUT: generic fn @F.2(%U.loc19_18.2: type) {
  716. // CHECK:STDOUT: %U.loc19_18.1: type = bind_symbolic_name U, 0 [symbolic = %U.loc19_18.1 (constants.%U)]
  717. // CHECK:STDOUT: %pattern_type: type = pattern_type %U.loc19_18.1 [symbolic = %pattern_type (constants.%pattern_type.7dc)]
  718. // CHECK:STDOUT:
  719. // CHECK:STDOUT: !definition:
  720. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %U.loc19_18.1 [symbolic = %require_complete (constants.%require_complete.4ae)]
  721. // CHECK:STDOUT:
  722. // CHECK:STDOUT: fn(%self.param: %empty_tuple.type, %x.param: @F.2.%U.loc19_18.1 (%U)) -> @F.2.%U.loc19_18.1 (%U) {
  723. // CHECK:STDOUT: !entry:
  724. // CHECK:STDOUT: %x.ref: @F.2.%U.loc19_18.1 (%U) = name_ref x, %x
  725. // CHECK:STDOUT: return %x.ref
  726. // CHECK:STDOUT: }
  727. // CHECK:STDOUT: }
  728. // CHECK:STDOUT:
  729. // CHECK:STDOUT: generic fn @F.3(%T.loc5_20.2: type) {
  730. // CHECK:STDOUT: <elided>
  731. // CHECK:STDOUT:
  732. // CHECK:STDOUT: !definition:
  733. // CHECK:STDOUT:
  734. // CHECK:STDOUT: fn(%self.param: %empty_tuple.type, %x.param: @F.3.%ptr (%ptr.79f)) -> @F.3.%ptr (%ptr.79f) {
  735. // CHECK:STDOUT: !entry:
  736. // CHECK:STDOUT: %F.ref: %F.type.39e918.1 = name_ref F, @impl.%F.decl.loc19_39.1 [concrete = constants.%F.c04b92.1]
  737. // CHECK:STDOUT: <elided>
  738. // CHECK:STDOUT: return <error>
  739. // CHECK:STDOUT: }
  740. // CHECK:STDOUT: }
  741. // CHECK:STDOUT:
  742. // CHECK:STDOUT: specific @F.2(constants.%U) {
  743. // CHECK:STDOUT: %U.loc19_18.1 => constants.%U
  744. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dc
  745. // CHECK:STDOUT: }
  746. // CHECK:STDOUT:
  747. // CHECK:STDOUT: specific @F.3(constants.%T.8b3) {
  748. // CHECK:STDOUT: %T.loc5_20.1 => constants.%T.8b3
  749. // CHECK:STDOUT: %ptr => constants.%ptr.79f
  750. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.afe
  751. // CHECK:STDOUT: }
  752. // CHECK:STDOUT:
  753. // CHECK:STDOUT: --- generic_interface.carbon
  754. // CHECK:STDOUT:
  755. // CHECK:STDOUT: constants {
  756. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  757. // CHECK:STDOUT: %struct_type.b.a.1b0: type = struct_type {.b: %empty_struct_type, .a: %empty_struct_type} [concrete]
  758. // CHECK:STDOUT: %pattern_type.914: type = pattern_type %struct_type.b.a.1b0 [concrete]
  759. // CHECK:STDOUT: %F.type.29ab63.1: type = fn_type @F.2 [concrete]
  760. // CHECK:STDOUT: %F.975709.1: %F.type.29ab63.1 = struct_value () [concrete]
  761. // CHECK:STDOUT: %struct_type.a.b.f95: type = struct_type {.a: %empty_struct_type, .b: %empty_struct_type} [concrete]
  762. // CHECK:STDOUT: %F.type.29ab63.2: type = fn_type @F.3 [concrete]
  763. // CHECK:STDOUT: %F.975709.2: %F.type.29ab63.2 = struct_value () [concrete]
  764. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  765. // CHECK:STDOUT: %struct: %struct_type.a.b.f95 = struct_value (%empty_struct, %empty_struct) [concrete]
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT:
  768. // CHECK:STDOUT: impl @impl: %.loc8_7.2 as %I.type {
  769. // CHECK:STDOUT: %F.decl.loc10_29.1: %F.type.29ab63.1 = fn_decl @F.2 [concrete = constants.%F.975709.1] {
  770. // CHECK:STDOUT: %return.patt: %pattern_type.914 = return_slot_pattern [concrete]
  771. // CHECK:STDOUT: %return.param_patt: %pattern_type.914 = out_param_pattern %return.patt, call_param0 [concrete]
  772. // CHECK:STDOUT: } {
  773. // CHECK:STDOUT: %.loc10_19.1: %empty_struct_type = struct_literal ()
  774. // CHECK:STDOUT: %.loc10_19.2: type = converted %.loc10_19.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  775. // CHECK:STDOUT: %.loc10_27.1: %empty_struct_type = struct_literal ()
  776. // CHECK:STDOUT: %.loc10_27.2: type = converted %.loc10_27.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  777. // CHECK:STDOUT: %struct_type.b.a: type = struct_type {.b: %empty_struct_type, .a: %empty_struct_type} [concrete = constants.%struct_type.b.a.1b0]
  778. // CHECK:STDOUT: %return.param: ref %struct_type.b.a.1b0 = out_param call_param0
  779. // CHECK:STDOUT: %return: ref %struct_type.b.a.1b0 = return_slot %return.param
  780. // CHECK:STDOUT: }
  781. // CHECK:STDOUT: %F.decl.loc10_29.2: %F.type.29ab63.2 = fn_decl @F.3 [concrete = constants.%F.975709.2] {
  782. // CHECK:STDOUT: <elided>
  783. // CHECK:STDOUT: } {
  784. // CHECK:STDOUT: <elided>
  785. // CHECK:STDOUT: }
  786. // CHECK:STDOUT:
  787. // CHECK:STDOUT: !members:
  788. // CHECK:STDOUT: .F = %F.decl.loc10_29.1
  789. // CHECK:STDOUT: witness = file.%I.impl_witness
  790. // CHECK:STDOUT: }
  791. // CHECK:STDOUT:
  792. // CHECK:STDOUT: fn @F.2() -> %return.param: %struct_type.b.a.1b0;
  793. // CHECK:STDOUT:
  794. // CHECK:STDOUT: fn @F.3() -> %return.param: %struct_type.a.b.f95 {
  795. // CHECK:STDOUT: !entry:
  796. // CHECK:STDOUT: %F.ref: %F.type.29ab63.1 = name_ref F, @impl.%F.decl.loc10_29.1 [concrete = constants.%F.975709.1]
  797. // CHECK:STDOUT: %.loc10_29.1: ref %struct_type.b.a.1b0 = temporary_storage
  798. // CHECK:STDOUT: %F.call: init %struct_type.b.a.1b0 = call %F.ref() to %.loc10_29.1
  799. // CHECK:STDOUT: %.loc10_29.2: ref %struct_type.b.a.1b0 = temporary %.loc10_29.1, %F.call
  800. // CHECK:STDOUT: %.loc10_29.3: ref %empty_struct_type = struct_access %.loc10_29.2, element1
  801. // CHECK:STDOUT: %.loc10_29.4: ref %empty_struct_type = struct_access %return, element1
  802. // CHECK:STDOUT: %.loc10_29.5: init %empty_struct_type = struct_init () to %.loc10_29.4 [concrete = constants.%empty_struct]
  803. // CHECK:STDOUT: %.loc10_29.6: init %empty_struct_type = converted %.loc10_29.3, %.loc10_29.5 [concrete = constants.%empty_struct]
  804. // CHECK:STDOUT: %.loc10_29.7: ref %empty_struct_type = struct_access %.loc10_29.2, element0
  805. // CHECK:STDOUT: %.loc10_29.8: ref %empty_struct_type = struct_access %return, element0
  806. // CHECK:STDOUT: %.loc10_29.9: init %empty_struct_type = struct_init () to %.loc10_29.8 [concrete = constants.%empty_struct]
  807. // CHECK:STDOUT: %.loc10_29.10: init %empty_struct_type = converted %.loc10_29.7, %.loc10_29.9 [concrete = constants.%empty_struct]
  808. // CHECK:STDOUT: %.loc10_29.11: init %struct_type.a.b.f95 = struct_init (%.loc10_29.6, %.loc10_29.10) to %return [concrete = constants.%struct]
  809. // CHECK:STDOUT: %.loc10_29.12: init %struct_type.a.b.f95 = converted %F.call, %.loc10_29.11 [concrete = constants.%struct]
  810. // CHECK:STDOUT: return %.loc10_29.12 to %return
  811. // CHECK:STDOUT: }
  812. // CHECK:STDOUT: