interface_args.carbon 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/no_prelude/interface_args.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/interface_args.carbon
  10. // --- action.carbon
  11. library "[[@TEST_NAME]]";
  12. interface Action(T:! type) {
  13. fn Op();
  14. }
  15. class A {}
  16. class B {}
  17. class C {}
  18. impl A as Action(B) {
  19. fn Op() {}
  20. }
  21. fn F(a: A) { a.(Action(B).Op)(); }
  22. // --- action.impl.carbon
  23. impl library "[[@TEST_NAME]]";
  24. fn G(a: A) { a.(Action(B).Op)(); }
  25. // --- fail_action.impl.carbon
  26. impl library "[[@TEST_NAME]]";
  27. // CHECK:STDERR: fail_action.impl.carbon:[[@LINE+4]]:14: error: cannot access member of interface `Action(C)` in type `A` that does not implement that interface [MissingImplInMemberAccess]
  28. // CHECK:STDERR: fn G(a: A) { a.(Action(C).Op)(); }
  29. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  30. // CHECK:STDERR:
  31. fn G(a: A) { a.(Action(C).Op)(); }
  32. // --- factory.carbon
  33. library "[[@TEST_NAME]]";
  34. interface Factory(T:! type) {
  35. fn Make() -> T;
  36. }
  37. class A {}
  38. class B {}
  39. impl A as Factory(B) {
  40. fn Make() -> B;
  41. }
  42. // --- factory.impl.carbon
  43. impl library "[[@TEST_NAME]]";
  44. fn MakeB(a: A) -> B {
  45. return a.(Factory(B).Make)();
  46. }
  47. // --- fail_factory.impl.carbon
  48. impl library "[[@TEST_NAME]]";
  49. class C {}
  50. fn MakeC(a: A) -> C {
  51. // CHECK:STDERR: fail_factory.impl.carbon:[[@LINE+4]]:10: error: cannot access member of interface `Factory(C)` in type `A` that does not implement that interface [MissingImplInMemberAccess]
  52. // CHECK:STDERR: return a.(Factory(C).Make)();
  53. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  54. // CHECK:STDERR:
  55. return a.(Factory(C).Make)();
  56. }
  57. // CHECK:STDOUT: --- action.carbon
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: constants {
  60. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  61. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  62. // CHECK:STDOUT: %Action.type.29c: type = generic_interface_type @Action [concrete]
  63. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  64. // CHECK:STDOUT: %Action.generic: %Action.type.29c = struct_value () [concrete]
  65. // CHECK:STDOUT: %Action.type.cca: type = facet_type <@Action, @Action(%T)> [symbolic]
  66. // CHECK:STDOUT: %Self: %Action.type.cca = bind_symbolic_name Self, 1 [symbolic]
  67. // CHECK:STDOUT: %Op.type.036: type = fn_type @Op.1, @Action(%T) [symbolic]
  68. // CHECK:STDOUT: %Op.6ed: %Op.type.036 = struct_value () [symbolic]
  69. // CHECK:STDOUT: %Action.assoc_type.8f9: type = assoc_entity_type %Action.type.cca [symbolic]
  70. // CHECK:STDOUT: %assoc0.69b: %Action.assoc_type.8f9 = assoc_entity element0, @Action.%Op.decl [symbolic]
  71. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  72. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  73. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  74. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  75. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  76. // CHECK:STDOUT: %Action.type.cb0: type = facet_type <@Action, @Action(%B)> [concrete]
  77. // CHECK:STDOUT: %Op.type.54d: type = fn_type @Op.1, @Action(%B) [concrete]
  78. // CHECK:STDOUT: %Op.dba: %Op.type.54d = struct_value () [concrete]
  79. // CHECK:STDOUT: %Action.assoc_type.827: type = assoc_entity_type %Action.type.cb0 [concrete]
  80. // CHECK:STDOUT: %assoc0.035: %Action.assoc_type.827 = assoc_entity element0, @Action.%Op.decl [concrete]
  81. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Op.decl) [concrete]
  82. // CHECK:STDOUT: %Op.type.4b4: type = fn_type @Op.2 [concrete]
  83. // CHECK:STDOUT: %Op.40d: %Op.type.4b4 = struct_value () [concrete]
  84. // CHECK:STDOUT: %Action.facet: %Action.type.cb0 = facet_value %A, %impl_witness [concrete]
  85. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  86. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  87. // CHECK:STDOUT: %.920: type = fn_type_with_self_type %Op.type.54d, %Action.facet [concrete]
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: file {
  91. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  92. // CHECK:STDOUT: .Action = %Action.decl
  93. // CHECK:STDOUT: .A = %A.decl
  94. // CHECK:STDOUT: .B = %B.decl
  95. // CHECK:STDOUT: .C = %C.decl
  96. // CHECK:STDOUT: .F = %F.decl
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: %Action.decl: %Action.type.29c = interface_decl @Action [concrete = constants.%Action.generic] {
  99. // CHECK:STDOUT: %T.patt.loc4_18.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_18.2 (constants.%T.patt)]
  100. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_18.1, runtime_param<none> [symbolic = %T.patt.loc4_18.2 (constants.%T.patt)]
  101. // CHECK:STDOUT: } {
  102. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  103. // CHECK:STDOUT: %T.loc4_18.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_18.2 (constants.%T)]
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  106. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  107. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  108. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  109. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  110. // CHECK:STDOUT: %Action.ref: %Action.type.29c = name_ref Action, file.%Action.decl [concrete = constants.%Action.generic]
  111. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  112. // CHECK:STDOUT: %Action.type: type = facet_type <@Action, @Action(constants.%B)> [concrete = constants.%Action.type.cb0]
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Op.decl) [concrete = constants.%impl_witness]
  115. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  116. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  117. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
  118. // CHECK:STDOUT: } {
  119. // CHECK:STDOUT: %a.param: %A = value_param runtime_param0
  120. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  121. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: generic interface @Action(%T.loc4_18.1: type) {
  126. // CHECK:STDOUT: %T.loc4_18.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_18.2 (constants.%T)]
  127. // CHECK:STDOUT: %T.patt.loc4_18.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_18.2 (constants.%T.patt)]
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: !definition:
  130. // CHECK:STDOUT: %Action.type: type = facet_type <@Action, @Action(%T.loc4_18.2)> [symbolic = %Action.type (constants.%Action.type.cca)]
  131. // CHECK:STDOUT: %Self.2: %Action.type.cca = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  132. // CHECK:STDOUT: %Op.type: type = fn_type @Op.1, @Action(%T.loc4_18.2) [symbolic = %Op.type (constants.%Op.type.036)]
  133. // CHECK:STDOUT: %Op: @Action.%Op.type (%Op.type.036) = struct_value () [symbolic = %Op (constants.%Op.6ed)]
  134. // CHECK:STDOUT: %Action.assoc_type: type = assoc_entity_type @Action.%Action.type (%Action.type.cca) [symbolic = %Action.assoc_type (constants.%Action.assoc_type.8f9)]
  135. // CHECK:STDOUT: %assoc0.loc5_10.2: @Action.%Action.assoc_type (%Action.assoc_type.8f9) = assoc_entity element0, %Op.decl [symbolic = %assoc0.loc5_10.2 (constants.%assoc0.69b)]
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: interface {
  138. // CHECK:STDOUT: %Self.1: @Action.%Action.type (%Action.type.cca) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  139. // CHECK:STDOUT: %Op.decl: @Action.%Op.type (%Op.type.036) = fn_decl @Op.1 [symbolic = @Action.%Op (constants.%Op.6ed)] {} {}
  140. // CHECK:STDOUT: %assoc0.loc5_10.1: @Action.%Action.assoc_type (%Action.assoc_type.8f9) = assoc_entity element0, %Op.decl [symbolic = %assoc0.loc5_10.2 (constants.%assoc0.69b)]
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: !members:
  143. // CHECK:STDOUT: .Self = %Self.1
  144. // CHECK:STDOUT: .Op = %assoc0.loc5_10.1
  145. // CHECK:STDOUT: witness = (%Op.decl)
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: impl @impl: %A.ref as %Action.type {
  150. // CHECK:STDOUT: %Op.decl: %Op.type.4b4 = fn_decl @Op.2 [concrete = constants.%Op.40d] {} {}
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: !members:
  153. // CHECK:STDOUT: .Op = %Op.decl
  154. // CHECK:STDOUT: witness = file.%impl_witness
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: class @A {
  158. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  159. // CHECK:STDOUT: complete_type_witness = %complete_type
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: !members:
  162. // CHECK:STDOUT: .Self = constants.%A
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: class @B {
  166. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  167. // CHECK:STDOUT: complete_type_witness = %complete_type
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: !members:
  170. // CHECK:STDOUT: .Self = constants.%B
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: class @C {
  174. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  175. // CHECK:STDOUT: complete_type_witness = %complete_type
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: !members:
  178. // CHECK:STDOUT: .Self = constants.%C
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: generic fn @Op.1(@Action.%T.loc4_18.1: type, @Action.%Self.1: @Action.%Action.type (%Action.type.cca)) {
  182. // CHECK:STDOUT: fn();
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: fn @Op.2() {
  186. // CHECK:STDOUT: !entry:
  187. // CHECK:STDOUT: return
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: fn @F(%a.param_patt: %A) {
  191. // CHECK:STDOUT: !entry:
  192. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  193. // CHECK:STDOUT: %Action.ref: %Action.type.29c = name_ref Action, file.%Action.decl [concrete = constants.%Action.generic]
  194. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  195. // CHECK:STDOUT: %Action.type: type = facet_type <@Action, @Action(constants.%B)> [concrete = constants.%Action.type.cb0]
  196. // CHECK:STDOUT: %.loc16: %Action.assoc_type.827 = specific_constant @Action.%assoc0.loc5_10.1, @Action(constants.%B) [concrete = constants.%assoc0.035]
  197. // CHECK:STDOUT: %Op.ref: %Action.assoc_type.827 = name_ref Op, %.loc16 [concrete = constants.%assoc0.035]
  198. // CHECK:STDOUT: %impl.elem0: %.920 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%Op.40d]
  199. // CHECK:STDOUT: %Op.call: init %empty_tuple.type = call %impl.elem0()
  200. // CHECK:STDOUT: return
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: specific @Action(constants.%T) {
  204. // CHECK:STDOUT: %T.loc4_18.2 => constants.%T
  205. // CHECK:STDOUT: %T.patt.loc4_18.2 => constants.%T
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: specific @Op.1(constants.%T, constants.%Self) {}
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: specific @Action(%T.loc4_18.2) {}
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: specific @Action(constants.%B) {
  213. // CHECK:STDOUT: %T.loc4_18.2 => constants.%B
  214. // CHECK:STDOUT: %T.patt.loc4_18.2 => constants.%B
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: !definition:
  217. // CHECK:STDOUT: %Action.type => constants.%Action.type.cb0
  218. // CHECK:STDOUT: %Self.2 => constants.%Self
  219. // CHECK:STDOUT: %Op.type => constants.%Op.type.54d
  220. // CHECK:STDOUT: %Op => constants.%Op.dba
  221. // CHECK:STDOUT: %Action.assoc_type => constants.%Action.assoc_type.827
  222. // CHECK:STDOUT: %assoc0.loc5_10.2 => constants.%assoc0.035
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: specific @Op.1(constants.%B, constants.%Action.facet) {}
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: --- action.impl.carbon
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: constants {
  230. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  231. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  232. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  233. // CHECK:STDOUT: %Action.type.29c: type = generic_interface_type @Action [concrete]
  234. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  235. // CHECK:STDOUT: %Action.generic: %Action.type.29c = struct_value () [concrete]
  236. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  237. // CHECK:STDOUT: %Action.type.cca: type = facet_type <@Action, @Action(%T)> [symbolic]
  238. // CHECK:STDOUT: %Self: %Action.type.cca = bind_symbolic_name Self, 1 [symbolic]
  239. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  240. // CHECK:STDOUT: %Action.type.cb0: type = facet_type <@Action, @Action(%B)> [concrete]
  241. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  242. // CHECK:STDOUT: %Op.type.036: type = fn_type @Op.1, @Action(%T) [symbolic]
  243. // CHECK:STDOUT: %Op.6ed: %Op.type.036 = struct_value () [symbolic]
  244. // CHECK:STDOUT: %Action.assoc_type.8f9: type = assoc_entity_type %Action.type.cca [symbolic]
  245. // CHECK:STDOUT: %assoc0.905ab9.1: %Action.assoc_type.8f9 = assoc_entity element0, imports.%Main.import_ref.0e3753.1 [symbolic]
  246. // CHECK:STDOUT: %Op.type.54d: type = fn_type @Op.1, @Action(%B) [concrete]
  247. // CHECK:STDOUT: %Op.dba: %Op.type.54d = struct_value () [concrete]
  248. // CHECK:STDOUT: %Action.assoc_type.827: type = assoc_entity_type %Action.type.cb0 [concrete]
  249. // CHECK:STDOUT: %assoc0.4cc: %Action.assoc_type.827 = assoc_entity element0, imports.%Main.import_ref.1f6 [concrete]
  250. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  251. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  252. // CHECK:STDOUT: %assoc0.905ab9.2: %Action.assoc_type.8f9 = assoc_entity element0, imports.%Main.import_ref.0e3753.2 [symbolic]
  253. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (imports.%Main.import_ref.d0b) [concrete]
  254. // CHECK:STDOUT: %Action.facet: %Action.type.cb0 = facet_value %A, %impl_witness [concrete]
  255. // CHECK:STDOUT: %.ae7: type = fn_type_with_self_type %Op.type.54d, %Action.facet [concrete]
  256. // CHECK:STDOUT: %Op.type.4b4: type = fn_type @Op.2 [concrete]
  257. // CHECK:STDOUT: %Op.40d: %Op.type.4b4 = struct_value () [concrete]
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: imports {
  261. // CHECK:STDOUT: %Main.Action: %Action.type.29c = import_ref Main//action, Action, loaded [concrete = constants.%Action.generic]
  262. // CHECK:STDOUT: %Main.A: type = import_ref Main//action, A, loaded [concrete = constants.%A]
  263. // CHECK:STDOUT: %Main.B: type = import_ref Main//action, B, loaded [concrete = constants.%B]
  264. // CHECK:STDOUT: %Main.C = import_ref Main//action, C, unloaded
  265. // CHECK:STDOUT: %Main.F = import_ref Main//action, F, unloaded
  266. // CHECK:STDOUT: %Main.import_ref.71c: <witness> = import_ref Main//action, loc12_21, loaded [concrete = constants.%impl_witness]
  267. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//action, loc9_10, loaded [concrete = constants.%complete_type]
  268. // CHECK:STDOUT: %Main.import_ref.54a = import_ref Main//action, inst46 [no loc], unloaded
  269. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//action, loc4_18, loaded [symbolic = @Action.%T (constants.%T)]
  270. // CHECK:STDOUT: %Main.import_ref.ddc = import_ref Main//action, inst26 [no loc], unloaded
  271. // CHECK:STDOUT: %Main.import_ref.318: @Action.%Action.assoc_type (%Action.assoc_type.8f9) = import_ref Main//action, loc5_10, loaded [symbolic = @Action.%assoc0 (constants.%assoc0.905ab9.2)]
  272. // CHECK:STDOUT: %Main.Op = import_ref Main//action, Op, unloaded
  273. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//action, loc8_10, loaded [concrete = constants.%complete_type]
  274. // CHECK:STDOUT: %Main.import_ref.da3 = import_ref Main//action, inst41 [no loc], unloaded
  275. // CHECK:STDOUT: %Main.import_ref.984: type = import_ref Main//action, loc12_6, loaded [concrete = constants.%A]
  276. // CHECK:STDOUT: %Main.import_ref.bb2: type = import_ref Main//action, loc12_19, loaded [concrete = constants.%Action.type.cb0]
  277. // CHECK:STDOUT: %Main.import_ref.7b5 = import_ref Main//action, loc13_11, unloaded
  278. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//action, loc4_18, loaded [symbolic = @Action.%T (constants.%T)]
  279. // CHECK:STDOUT: %Main.import_ref.835: @Action.%Action.type (%Action.type.cca) = import_ref Main//action, inst26 [no loc], loaded [symbolic = @Action.%Self (constants.%Self)]
  280. // CHECK:STDOUT: %Main.import_ref.0e3753.1 = import_ref Main//action, loc5_10, unloaded
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: file {
  284. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  285. // CHECK:STDOUT: .Action = imports.%Main.Action
  286. // CHECK:STDOUT: .A = imports.%Main.A
  287. // CHECK:STDOUT: .B = imports.%Main.B
  288. // CHECK:STDOUT: .C = imports.%Main.C
  289. // CHECK:STDOUT: .F = imports.%Main.F
  290. // CHECK:STDOUT: .G = %G.decl
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT: %default.import.loc2_6.1 = import <none>
  293. // CHECK:STDOUT: %default.import.loc2_6.2 = import <none>
  294. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  295. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  296. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
  297. // CHECK:STDOUT: } {
  298. // CHECK:STDOUT: %a.param: %A = value_param runtime_param0
  299. // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%Main.A [concrete = constants.%A]
  300. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: generic interface @Action(imports.%Main.import_ref.f6b058.1: type) [from "action.carbon"] {
  305. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  306. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: !definition:
  309. // CHECK:STDOUT: %Action.type: type = facet_type <@Action, @Action(%T)> [symbolic = %Action.type (constants.%Action.type.cca)]
  310. // CHECK:STDOUT: %Self: %Action.type.cca = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  311. // CHECK:STDOUT: %Op.type: type = fn_type @Op.1, @Action(%T) [symbolic = %Op.type (constants.%Op.type.036)]
  312. // CHECK:STDOUT: %Op: @Action.%Op.type (%Op.type.036) = struct_value () [symbolic = %Op (constants.%Op.6ed)]
  313. // CHECK:STDOUT: %Action.assoc_type: type = assoc_entity_type @Action.%Action.type (%Action.type.cca) [symbolic = %Action.assoc_type (constants.%Action.assoc_type.8f9)]
  314. // CHECK:STDOUT: %assoc0: @Action.%Action.assoc_type (%Action.assoc_type.8f9) = assoc_entity element0, imports.%Main.import_ref.0e3753.1 [symbolic = %assoc0 (constants.%assoc0.905ab9.1)]
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: interface {
  317. // CHECK:STDOUT: !members:
  318. // CHECK:STDOUT: .Self = imports.%Main.import_ref.ddc
  319. // CHECK:STDOUT: .Op = imports.%Main.import_ref.318
  320. // CHECK:STDOUT: witness = (imports.%Main.Op)
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: impl @impl: imports.%Main.import_ref.984 as imports.%Main.import_ref.bb2 [from "action.carbon"] {
  325. // CHECK:STDOUT: !members:
  326. // CHECK:STDOUT: .Op = imports.%Main.import_ref.7b5
  327. // CHECK:STDOUT: witness = imports.%Main.import_ref.71c
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: class @B [from "action.carbon"] {
  331. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: !members:
  334. // CHECK:STDOUT: .Self = imports.%Main.import_ref.54a
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: class @A [from "action.carbon"] {
  338. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: !members:
  341. // CHECK:STDOUT: .Self = imports.%Main.import_ref.da3
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: generic fn @Op.1(imports.%Main.import_ref.f6b058.2: type, imports.%Main.import_ref.835: @Action.%Action.type (%Action.type.cca)) [from "action.carbon"] {
  345. // CHECK:STDOUT: fn();
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: fn @G(%a.param_patt: %A) {
  349. // CHECK:STDOUT: !entry:
  350. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  351. // CHECK:STDOUT: %Action.ref: %Action.type.29c = name_ref Action, imports.%Main.Action [concrete = constants.%Action.generic]
  352. // CHECK:STDOUT: %B.ref: type = name_ref B, imports.%Main.B [concrete = constants.%B]
  353. // CHECK:STDOUT: %Action.type: type = facet_type <@Action, @Action(constants.%B)> [concrete = constants.%Action.type.cb0]
  354. // CHECK:STDOUT: %.loc4: %Action.assoc_type.827 = specific_constant imports.%Main.import_ref.318, @Action(constants.%B) [concrete = constants.%assoc0.4cc]
  355. // CHECK:STDOUT: %Op.ref: %Action.assoc_type.827 = name_ref Op, %.loc4 [concrete = constants.%assoc0.4cc]
  356. // CHECK:STDOUT: %impl.elem0: %.ae7 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%Op.40d]
  357. // CHECK:STDOUT: %Op.call: init %empty_tuple.type = call %impl.elem0()
  358. // CHECK:STDOUT: return
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: fn @Op.2() [from "action.carbon"];
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: specific @Action(constants.%T) {
  364. // CHECK:STDOUT: %T => constants.%T
  365. // CHECK:STDOUT: %T.patt => constants.%T
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: specific @Action(constants.%B) {
  369. // CHECK:STDOUT: %T => constants.%B
  370. // CHECK:STDOUT: %T.patt => constants.%B
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: !definition:
  373. // CHECK:STDOUT: %Action.type => constants.%Action.type.cb0
  374. // CHECK:STDOUT: %Self => constants.%Self
  375. // CHECK:STDOUT: %Op.type => constants.%Op.type.54d
  376. // CHECK:STDOUT: %Op => constants.%Op.dba
  377. // CHECK:STDOUT: %Action.assoc_type => constants.%Action.assoc_type.827
  378. // CHECK:STDOUT: %assoc0 => constants.%assoc0.4cc
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: specific @Action(%T) {}
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: specific @Op.1(constants.%T, constants.%Self) {}
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: --- fail_action.impl.carbon
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: constants {
  388. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  389. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  390. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  391. // CHECK:STDOUT: %Action.type.29c: type = generic_interface_type @Action [concrete]
  392. // CHECK:STDOUT: %Action.generic: %Action.type.29c = struct_value () [concrete]
  393. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  394. // CHECK:STDOUT: %Action.type.cca: type = facet_type <@Action, @Action(%T)> [symbolic]
  395. // CHECK:STDOUT: %Self: %Action.type.cca = bind_symbolic_name Self, 1 [symbolic]
  396. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  397. // CHECK:STDOUT: %Action.type.cb0: type = facet_type <@Action, @Action(%B)> [concrete]
  398. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  399. // CHECK:STDOUT: %Op.type.036: type = fn_type @Op, @Action(%T) [symbolic]
  400. // CHECK:STDOUT: %Op.6ed: %Op.type.036 = struct_value () [symbolic]
  401. // CHECK:STDOUT: %Action.assoc_type.8f9: type = assoc_entity_type %Action.type.cca [symbolic]
  402. // CHECK:STDOUT: %assoc0.905ab9.1: %Action.assoc_type.8f9 = assoc_entity element0, imports.%Main.import_ref.0e3753.1 [symbolic]
  403. // CHECK:STDOUT: %Op.type.54d: type = fn_type @Op, @Action(%B) [concrete]
  404. // CHECK:STDOUT: %Op.dba: %Op.type.54d = struct_value () [concrete]
  405. // CHECK:STDOUT: %Action.assoc_type.827: type = assoc_entity_type %Action.type.cb0 [concrete]
  406. // CHECK:STDOUT: %assoc0.8f8: %Action.assoc_type.827 = assoc_entity element0, imports.%Main.import_ref.0e3753.2 [concrete]
  407. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  408. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  409. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  410. // CHECK:STDOUT: %Action.type.e2b: type = facet_type <@Action, @Action(%C)> [concrete]
  411. // CHECK:STDOUT: %Op.type.5ad: type = fn_type @Op, @Action(%C) [concrete]
  412. // CHECK:STDOUT: %Op.b10: %Op.type.5ad = struct_value () [concrete]
  413. // CHECK:STDOUT: %Action.assoc_type.0a7: type = assoc_entity_type %Action.type.e2b [concrete]
  414. // CHECK:STDOUT: %assoc0.85d: %Action.assoc_type.0a7 = assoc_entity element0, imports.%Main.import_ref.0e3753.1 [concrete]
  415. // CHECK:STDOUT: %assoc0.905ab9.2: %Action.assoc_type.8f9 = assoc_entity element0, imports.%Main.import_ref.0e3753.3 [symbolic]
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: imports {
  419. // CHECK:STDOUT: %Main.Action: %Action.type.29c = import_ref Main//action, Action, loaded [concrete = constants.%Action.generic]
  420. // CHECK:STDOUT: %Main.A: type = import_ref Main//action, A, loaded [concrete = constants.%A]
  421. // CHECK:STDOUT: %Main.B = import_ref Main//action, B, unloaded
  422. // CHECK:STDOUT: %Main.C: type = import_ref Main//action, C, loaded [concrete = constants.%C]
  423. // CHECK:STDOUT: %Main.F = import_ref Main//action, F, unloaded
  424. // CHECK:STDOUT: %Main.import_ref.7a1 = import_ref Main//action, loc12_21, unloaded
  425. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//action, loc9_10, loaded [concrete = constants.%complete_type]
  426. // CHECK:STDOUT: %Main.import_ref.54a = import_ref Main//action, inst46 [no loc], unloaded
  427. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//action, loc4_18, loaded [symbolic = @Action.%T (constants.%T)]
  428. // CHECK:STDOUT: %Main.import_ref.ddc = import_ref Main//action, inst26 [no loc], unloaded
  429. // CHECK:STDOUT: %Main.import_ref.318: @Action.%Action.assoc_type (%Action.assoc_type.8f9) = import_ref Main//action, loc5_10, loaded [symbolic = @Action.%assoc0 (constants.%assoc0.905ab9.2)]
  430. // CHECK:STDOUT: %Main.Op = import_ref Main//action, Op, unloaded
  431. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//action, loc8_10, loaded [concrete = constants.%complete_type]
  432. // CHECK:STDOUT: %Main.import_ref.da3 = import_ref Main//action, inst41 [no loc], unloaded
  433. // CHECK:STDOUT: %Main.import_ref.984: type = import_ref Main//action, loc12_6, loaded [concrete = constants.%A]
  434. // CHECK:STDOUT: %Main.import_ref.bb2: type = import_ref Main//action, loc12_19, loaded [concrete = constants.%Action.type.cb0]
  435. // CHECK:STDOUT: %Main.import_ref.7b5 = import_ref Main//action, loc13_11, unloaded
  436. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//action, loc4_18, loaded [symbolic = @Action.%T (constants.%T)]
  437. // CHECK:STDOUT: %Main.import_ref.835: @Action.%Action.type (%Action.type.cca) = import_ref Main//action, inst26 [no loc], loaded [symbolic = @Action.%Self (constants.%Self)]
  438. // CHECK:STDOUT: %Main.import_ref.0e3753.1 = import_ref Main//action, loc5_10, unloaded
  439. // CHECK:STDOUT: %Main.import_ref.8f24d3.3: <witness> = import_ref Main//action, loc10_10, loaded [concrete = constants.%complete_type]
  440. // CHECK:STDOUT: %Main.import_ref.2c4 = import_ref Main//action, inst49 [no loc], unloaded
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: file {
  444. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  445. // CHECK:STDOUT: .Action = imports.%Main.Action
  446. // CHECK:STDOUT: .A = imports.%Main.A
  447. // CHECK:STDOUT: .B = imports.%Main.B
  448. // CHECK:STDOUT: .C = imports.%Main.C
  449. // CHECK:STDOUT: .F = imports.%Main.F
  450. // CHECK:STDOUT: .G = %G.decl
  451. // CHECK:STDOUT: }
  452. // CHECK:STDOUT: %default.import.loc2_6.1 = import <none>
  453. // CHECK:STDOUT: %default.import.loc2_6.2 = import <none>
  454. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  455. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  456. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
  457. // CHECK:STDOUT: } {
  458. // CHECK:STDOUT: %a.param: %A = value_param runtime_param0
  459. // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%Main.A [concrete = constants.%A]
  460. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  461. // CHECK:STDOUT: }
  462. // CHECK:STDOUT: }
  463. // CHECK:STDOUT:
  464. // CHECK:STDOUT: generic interface @Action(imports.%Main.import_ref.f6b058.1: type) [from "action.carbon"] {
  465. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  466. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: !definition:
  469. // CHECK:STDOUT: %Action.type: type = facet_type <@Action, @Action(%T)> [symbolic = %Action.type (constants.%Action.type.cca)]
  470. // CHECK:STDOUT: %Self: %Action.type.cca = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  471. // CHECK:STDOUT: %Op.type: type = fn_type @Op, @Action(%T) [symbolic = %Op.type (constants.%Op.type.036)]
  472. // CHECK:STDOUT: %Op: @Action.%Op.type (%Op.type.036) = struct_value () [symbolic = %Op (constants.%Op.6ed)]
  473. // CHECK:STDOUT: %Action.assoc_type: type = assoc_entity_type @Action.%Action.type (%Action.type.cca) [symbolic = %Action.assoc_type (constants.%Action.assoc_type.8f9)]
  474. // CHECK:STDOUT: %assoc0: @Action.%Action.assoc_type (%Action.assoc_type.8f9) = assoc_entity element0, imports.%Main.import_ref.0e3753.1 [symbolic = %assoc0 (constants.%assoc0.905ab9.1)]
  475. // CHECK:STDOUT:
  476. // CHECK:STDOUT: interface {
  477. // CHECK:STDOUT: !members:
  478. // CHECK:STDOUT: .Self = imports.%Main.import_ref.ddc
  479. // CHECK:STDOUT: .Op = imports.%Main.import_ref.318
  480. // CHECK:STDOUT: witness = (imports.%Main.Op)
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: impl @impl: imports.%Main.import_ref.984 as imports.%Main.import_ref.bb2 [from "action.carbon"] {
  485. // CHECK:STDOUT: !members:
  486. // CHECK:STDOUT: .Op = imports.%Main.import_ref.7b5
  487. // CHECK:STDOUT: witness = imports.%Main.import_ref.7a1
  488. // CHECK:STDOUT: }
  489. // CHECK:STDOUT:
  490. // CHECK:STDOUT: class @B [from "action.carbon"] {
  491. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  492. // CHECK:STDOUT:
  493. // CHECK:STDOUT: !members:
  494. // CHECK:STDOUT: .Self = imports.%Main.import_ref.54a
  495. // CHECK:STDOUT: }
  496. // CHECK:STDOUT:
  497. // CHECK:STDOUT: class @A [from "action.carbon"] {
  498. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: !members:
  501. // CHECK:STDOUT: .Self = imports.%Main.import_ref.da3
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT:
  504. // CHECK:STDOUT: class @C [from "action.carbon"] {
  505. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.3
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: !members:
  508. // CHECK:STDOUT: .Self = imports.%Main.import_ref.2c4
  509. // CHECK:STDOUT: }
  510. // CHECK:STDOUT:
  511. // CHECK:STDOUT: generic fn @Op(imports.%Main.import_ref.f6b058.2: type, imports.%Main.import_ref.835: @Action.%Action.type (%Action.type.cca)) [from "action.carbon"] {
  512. // CHECK:STDOUT: fn();
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: fn @G(%a.param_patt: %A) {
  516. // CHECK:STDOUT: !entry:
  517. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  518. // CHECK:STDOUT: %Action.ref: %Action.type.29c = name_ref Action, imports.%Main.Action [concrete = constants.%Action.generic]
  519. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  520. // CHECK:STDOUT: %Action.type: type = facet_type <@Action, @Action(constants.%C)> [concrete = constants.%Action.type.e2b]
  521. // CHECK:STDOUT: %.loc8: %Action.assoc_type.0a7 = specific_constant imports.%Main.import_ref.318, @Action(constants.%C) [concrete = constants.%assoc0.85d]
  522. // CHECK:STDOUT: %Op.ref: %Action.assoc_type.0a7 = name_ref Op, %.loc8 [concrete = constants.%assoc0.85d]
  523. // CHECK:STDOUT: return
  524. // CHECK:STDOUT: }
  525. // CHECK:STDOUT:
  526. // CHECK:STDOUT: specific @Action(constants.%T) {
  527. // CHECK:STDOUT: %T => constants.%T
  528. // CHECK:STDOUT: %T.patt => constants.%T
  529. // CHECK:STDOUT: }
  530. // CHECK:STDOUT:
  531. // CHECK:STDOUT: specific @Action(constants.%B) {
  532. // CHECK:STDOUT: %T => constants.%B
  533. // CHECK:STDOUT: %T.patt => constants.%B
  534. // CHECK:STDOUT:
  535. // CHECK:STDOUT: !definition:
  536. // CHECK:STDOUT: %Action.type => constants.%Action.type.cb0
  537. // CHECK:STDOUT: %Self => constants.%Self
  538. // CHECK:STDOUT: %Op.type => constants.%Op.type.54d
  539. // CHECK:STDOUT: %Op => constants.%Op.dba
  540. // CHECK:STDOUT: %Action.assoc_type => constants.%Action.assoc_type.827
  541. // CHECK:STDOUT: %assoc0 => constants.%assoc0.8f8
  542. // CHECK:STDOUT: }
  543. // CHECK:STDOUT:
  544. // CHECK:STDOUT: specific @Action(%T) {}
  545. // CHECK:STDOUT:
  546. // CHECK:STDOUT: specific @Op(constants.%T, constants.%Self) {}
  547. // CHECK:STDOUT:
  548. // CHECK:STDOUT: specific @Action(constants.%C) {
  549. // CHECK:STDOUT: %T => constants.%C
  550. // CHECK:STDOUT: %T.patt => constants.%C
  551. // CHECK:STDOUT:
  552. // CHECK:STDOUT: !definition:
  553. // CHECK:STDOUT: %Action.type => constants.%Action.type.e2b
  554. // CHECK:STDOUT: %Self => constants.%Self
  555. // CHECK:STDOUT: %Op.type => constants.%Op.type.5ad
  556. // CHECK:STDOUT: %Op => constants.%Op.b10
  557. // CHECK:STDOUT: %Action.assoc_type => constants.%Action.assoc_type.0a7
  558. // CHECK:STDOUT: %assoc0 => constants.%assoc0.85d
  559. // CHECK:STDOUT: }
  560. // CHECK:STDOUT:
  561. // CHECK:STDOUT: --- factory.carbon
  562. // CHECK:STDOUT:
  563. // CHECK:STDOUT: constants {
  564. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  565. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  566. // CHECK:STDOUT: %Factory.type.1a8: type = generic_interface_type @Factory [concrete]
  567. // CHECK:STDOUT: %Factory.generic: %Factory.type.1a8 = struct_value () [concrete]
  568. // CHECK:STDOUT: %Factory.type.c96: type = facet_type <@Factory, @Factory(%T)> [symbolic]
  569. // CHECK:STDOUT: %Self: %Factory.type.c96 = bind_symbolic_name Self, 1 [symbolic]
  570. // CHECK:STDOUT: %Make.type.598: type = fn_type @Make.1, @Factory(%T) [symbolic]
  571. // CHECK:STDOUT: %Make.737: %Make.type.598 = struct_value () [symbolic]
  572. // CHECK:STDOUT: %Factory.assoc_type.ca7: type = assoc_entity_type %Factory.type.c96 [symbolic]
  573. // CHECK:STDOUT: %assoc0.d7a: %Factory.assoc_type.ca7 = assoc_entity element0, @Factory.%Make.decl [symbolic]
  574. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  575. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  576. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  577. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  578. // CHECK:STDOUT: %Factory.type.a5d: type = facet_type <@Factory, @Factory(%B)> [concrete]
  579. // CHECK:STDOUT: %Make.type.c59: type = fn_type @Make.1, @Factory(%B) [concrete]
  580. // CHECK:STDOUT: %Make.efe: %Make.type.c59 = struct_value () [concrete]
  581. // CHECK:STDOUT: %Factory.assoc_type.668: type = assoc_entity_type %Factory.type.a5d [concrete]
  582. // CHECK:STDOUT: %assoc0.40c: %Factory.assoc_type.668 = assoc_entity element0, @Factory.%Make.decl [concrete]
  583. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Make.decl) [concrete]
  584. // CHECK:STDOUT: %Make.type.ec4: type = fn_type @Make.2 [concrete]
  585. // CHECK:STDOUT: %Make.377: %Make.type.ec4 = struct_value () [concrete]
  586. // CHECK:STDOUT: %Factory.facet: %Factory.type.a5d = facet_value %A, %impl_witness [concrete]
  587. // CHECK:STDOUT: }
  588. // CHECK:STDOUT:
  589. // CHECK:STDOUT: file {
  590. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  591. // CHECK:STDOUT: .Factory = %Factory.decl
  592. // CHECK:STDOUT: .A = %A.decl
  593. // CHECK:STDOUT: .B = %B.decl
  594. // CHECK:STDOUT: }
  595. // CHECK:STDOUT: %Factory.decl: %Factory.type.1a8 = interface_decl @Factory [concrete = constants.%Factory.generic] {
  596. // CHECK:STDOUT: %T.patt.loc4_19.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_19.2 (constants.%T.patt)]
  597. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_19.1, runtime_param<none> [symbolic = %T.patt.loc4_19.2 (constants.%T.patt)]
  598. // CHECK:STDOUT: } {
  599. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  600. // CHECK:STDOUT: %T.loc4_19.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_19.2 (constants.%T)]
  601. // CHECK:STDOUT: }
  602. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  603. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  604. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  605. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  606. // CHECK:STDOUT: %Factory.ref: %Factory.type.1a8 = name_ref Factory, file.%Factory.decl [concrete = constants.%Factory.generic]
  607. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  608. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(constants.%B)> [concrete = constants.%Factory.type.a5d]
  609. // CHECK:STDOUT: }
  610. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Make.decl) [concrete = constants.%impl_witness]
  611. // CHECK:STDOUT: }
  612. // CHECK:STDOUT:
  613. // CHECK:STDOUT: generic interface @Factory(%T.loc4_19.1: type) {
  614. // CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_19.2 (constants.%T)]
  615. // CHECK:STDOUT: %T.patt.loc4_19.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_19.2 (constants.%T.patt)]
  616. // CHECK:STDOUT:
  617. // CHECK:STDOUT: !definition:
  618. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(%T.loc4_19.2)> [symbolic = %Factory.type (constants.%Factory.type.c96)]
  619. // CHECK:STDOUT: %Self.2: %Factory.type.c96 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  620. // CHECK:STDOUT: %Make.type: type = fn_type @Make.1, @Factory(%T.loc4_19.2) [symbolic = %Make.type (constants.%Make.type.598)]
  621. // CHECK:STDOUT: %Make: @Factory.%Make.type (%Make.type.598) = struct_value () [symbolic = %Make (constants.%Make.737)]
  622. // CHECK:STDOUT: %Factory.assoc_type: type = assoc_entity_type @Factory.%Factory.type (%Factory.type.c96) [symbolic = %Factory.assoc_type (constants.%Factory.assoc_type.ca7)]
  623. // CHECK:STDOUT: %assoc0.loc5_17.2: @Factory.%Factory.assoc_type (%Factory.assoc_type.ca7) = assoc_entity element0, %Make.decl [symbolic = %assoc0.loc5_17.2 (constants.%assoc0.d7a)]
  624. // CHECK:STDOUT:
  625. // CHECK:STDOUT: interface {
  626. // CHECK:STDOUT: %Self.1: @Factory.%Factory.type (%Factory.type.c96) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  627. // CHECK:STDOUT: %Make.decl: @Factory.%Make.type (%Make.type.598) = fn_decl @Make.1 [symbolic = @Factory.%Make (constants.%Make.737)] {
  628. // CHECK:STDOUT: %return.patt: @Make.1.%T (%T) = return_slot_pattern
  629. // CHECK:STDOUT: %return.param_patt: @Make.1.%T (%T) = out_param_pattern %return.patt, runtime_param0
  630. // CHECK:STDOUT: } {
  631. // CHECK:STDOUT: %T.ref: type = name_ref T, @Factory.%T.loc4_19.1 [symbolic = %T (constants.%T)]
  632. // CHECK:STDOUT: %return.param: ref @Make.1.%T (%T) = out_param runtime_param0
  633. // CHECK:STDOUT: %return: ref @Make.1.%T (%T) = return_slot %return.param
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT: %assoc0.loc5_17.1: @Factory.%Factory.assoc_type (%Factory.assoc_type.ca7) = assoc_entity element0, %Make.decl [symbolic = %assoc0.loc5_17.2 (constants.%assoc0.d7a)]
  636. // CHECK:STDOUT:
  637. // CHECK:STDOUT: !members:
  638. // CHECK:STDOUT: .Self = %Self.1
  639. // CHECK:STDOUT: .T = <poisoned>
  640. // CHECK:STDOUT: .Make = %assoc0.loc5_17.1
  641. // CHECK:STDOUT: witness = (%Make.decl)
  642. // CHECK:STDOUT: }
  643. // CHECK:STDOUT: }
  644. // CHECK:STDOUT:
  645. // CHECK:STDOUT: impl @impl: %A.ref as %Factory.type {
  646. // CHECK:STDOUT: %Make.decl: %Make.type.ec4 = fn_decl @Make.2 [concrete = constants.%Make.377] {
  647. // CHECK:STDOUT: %return.patt: %B = return_slot_pattern
  648. // CHECK:STDOUT: %return.param_patt: %B = out_param_pattern %return.patt, runtime_param0
  649. // CHECK:STDOUT: } {
  650. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  651. // CHECK:STDOUT: %return.param: ref %B = out_param runtime_param0
  652. // CHECK:STDOUT: %return: ref %B = return_slot %return.param
  653. // CHECK:STDOUT: }
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: !members:
  656. // CHECK:STDOUT: .B = <poisoned>
  657. // CHECK:STDOUT: .Make = %Make.decl
  658. // CHECK:STDOUT: witness = file.%impl_witness
  659. // CHECK:STDOUT: }
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: class @A {
  662. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  663. // CHECK:STDOUT: complete_type_witness = %complete_type
  664. // CHECK:STDOUT:
  665. // CHECK:STDOUT: !members:
  666. // CHECK:STDOUT: .Self = constants.%A
  667. // CHECK:STDOUT: }
  668. // CHECK:STDOUT:
  669. // CHECK:STDOUT: class @B {
  670. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  671. // CHECK:STDOUT: complete_type_witness = %complete_type
  672. // CHECK:STDOUT:
  673. // CHECK:STDOUT: !members:
  674. // CHECK:STDOUT: .Self = constants.%B
  675. // CHECK:STDOUT: }
  676. // CHECK:STDOUT:
  677. // CHECK:STDOUT: generic fn @Make.1(@Factory.%T.loc4_19.1: type, @Factory.%Self.1: @Factory.%Factory.type (%Factory.type.c96)) {
  678. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: fn() -> @Make.1.%T (%T);
  681. // CHECK:STDOUT: }
  682. // CHECK:STDOUT:
  683. // CHECK:STDOUT: fn @Make.2() -> %B;
  684. // CHECK:STDOUT:
  685. // CHECK:STDOUT: specific @Factory(constants.%T) {
  686. // CHECK:STDOUT: %T.loc4_19.2 => constants.%T
  687. // CHECK:STDOUT: %T.patt.loc4_19.2 => constants.%T
  688. // CHECK:STDOUT: }
  689. // CHECK:STDOUT:
  690. // CHECK:STDOUT: specific @Make.1(constants.%T, constants.%Self) {
  691. // CHECK:STDOUT: %T => constants.%T
  692. // CHECK:STDOUT: }
  693. // CHECK:STDOUT:
  694. // CHECK:STDOUT: specific @Factory(%T.loc4_19.2) {}
  695. // CHECK:STDOUT:
  696. // CHECK:STDOUT: specific @Factory(constants.%B) {
  697. // CHECK:STDOUT: %T.loc4_19.2 => constants.%B
  698. // CHECK:STDOUT: %T.patt.loc4_19.2 => constants.%B
  699. // CHECK:STDOUT:
  700. // CHECK:STDOUT: !definition:
  701. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.a5d
  702. // CHECK:STDOUT: %Self.2 => constants.%Self
  703. // CHECK:STDOUT: %Make.type => constants.%Make.type.c59
  704. // CHECK:STDOUT: %Make => constants.%Make.efe
  705. // CHECK:STDOUT: %Factory.assoc_type => constants.%Factory.assoc_type.668
  706. // CHECK:STDOUT: %assoc0.loc5_17.2 => constants.%assoc0.40c
  707. // CHECK:STDOUT: }
  708. // CHECK:STDOUT:
  709. // CHECK:STDOUT: specific @Make.1(constants.%B, constants.%Factory.facet) {
  710. // CHECK:STDOUT: %T => constants.%B
  711. // CHECK:STDOUT: }
  712. // CHECK:STDOUT:
  713. // CHECK:STDOUT: --- factory.impl.carbon
  714. // CHECK:STDOUT:
  715. // CHECK:STDOUT: constants {
  716. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  717. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  718. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  719. // CHECK:STDOUT: %Factory.type.1a8: type = generic_interface_type @Factory [concrete]
  720. // CHECK:STDOUT: %Factory.generic: %Factory.type.1a8 = struct_value () [concrete]
  721. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  722. // CHECK:STDOUT: %Factory.type.c96: type = facet_type <@Factory, @Factory(%T)> [symbolic]
  723. // CHECK:STDOUT: %Self: %Factory.type.c96 = bind_symbolic_name Self, 1 [symbolic]
  724. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  725. // CHECK:STDOUT: %Factory.type.a5d: type = facet_type <@Factory, @Factory(%B)> [concrete]
  726. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  727. // CHECK:STDOUT: %Make.type.598: type = fn_type @Make.1, @Factory(%T) [symbolic]
  728. // CHECK:STDOUT: %Make.737: %Make.type.598 = struct_value () [symbolic]
  729. // CHECK:STDOUT: %Factory.assoc_type.ca7: type = assoc_entity_type %Factory.type.c96 [symbolic]
  730. // CHECK:STDOUT: %assoc0.35472f.1: %Factory.assoc_type.ca7 = assoc_entity element0, imports.%Main.import_ref.21018a.1 [symbolic]
  731. // CHECK:STDOUT: %Make.type.c59: type = fn_type @Make.1, @Factory(%B) [concrete]
  732. // CHECK:STDOUT: %Make.efe: %Make.type.c59 = struct_value () [concrete]
  733. // CHECK:STDOUT: %Factory.assoc_type.668: type = assoc_entity_type %Factory.type.a5d [concrete]
  734. // CHECK:STDOUT: %assoc0.503: %Factory.assoc_type.668 = assoc_entity element0, imports.%Main.import_ref.1aa [concrete]
  735. // CHECK:STDOUT: %MakeB.type: type = fn_type @MakeB [concrete]
  736. // CHECK:STDOUT: %MakeB: %MakeB.type = struct_value () [concrete]
  737. // CHECK:STDOUT: %assoc0.35472f.2: %Factory.assoc_type.ca7 = assoc_entity element0, imports.%Main.import_ref.21018a.2 [symbolic]
  738. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (imports.%Main.import_ref.9ec) [concrete]
  739. // CHECK:STDOUT: %Factory.facet: %Factory.type.a5d = facet_value %A, %impl_witness [concrete]
  740. // CHECK:STDOUT: %.357: type = fn_type_with_self_type %Make.type.c59, %Factory.facet [concrete]
  741. // CHECK:STDOUT: %Make.type.ec4: type = fn_type @Make.2 [concrete]
  742. // CHECK:STDOUT: %Make.377: %Make.type.ec4 = struct_value () [concrete]
  743. // CHECK:STDOUT: }
  744. // CHECK:STDOUT:
  745. // CHECK:STDOUT: imports {
  746. // CHECK:STDOUT: %Main.Factory: %Factory.type.1a8 = import_ref Main//factory, Factory, loaded [concrete = constants.%Factory.generic]
  747. // CHECK:STDOUT: %Main.A: type = import_ref Main//factory, A, loaded [concrete = constants.%A]
  748. // CHECK:STDOUT: %Main.B: type = import_ref Main//factory, B, loaded [concrete = constants.%B]
  749. // CHECK:STDOUT: %Main.import_ref.72b: <witness> = import_ref Main//factory, loc11_22, loaded [concrete = constants.%impl_witness]
  750. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//factory, loc9_10, loaded [concrete = constants.%complete_type]
  751. // CHECK:STDOUT: %Main.import_ref.54a = import_ref Main//factory, inst52 [no loc], unloaded
  752. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//factory, loc4_19, loaded [symbolic = @Factory.%T (constants.%T)]
  753. // CHECK:STDOUT: %Main.import_ref.fbb = import_ref Main//factory, inst26 [no loc], unloaded
  754. // CHECK:STDOUT: %Main.import_ref.8d5: @Factory.%Factory.assoc_type (%Factory.assoc_type.ca7) = import_ref Main//factory, loc5_17, loaded [symbolic = @Factory.%assoc0 (constants.%assoc0.35472f.2)]
  755. // CHECK:STDOUT: %Main.Make = import_ref Main//factory, Make, unloaded
  756. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//factory, loc8_10, loaded [concrete = constants.%complete_type]
  757. // CHECK:STDOUT: %Main.import_ref.da3 = import_ref Main//factory, inst47 [no loc], unloaded
  758. // CHECK:STDOUT: %Main.import_ref.984: type = import_ref Main//factory, loc11_6, loaded [concrete = constants.%A]
  759. // CHECK:STDOUT: %Main.import_ref.bd2: type = import_ref Main//factory, loc11_20, loaded [concrete = constants.%Factory.type.a5d]
  760. // CHECK:STDOUT: %Main.import_ref.a27 = import_ref Main//factory, loc12_17, unloaded
  761. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//factory, loc4_19, loaded [symbolic = @Factory.%T (constants.%T)]
  762. // CHECK:STDOUT: %Main.import_ref.91b: @Factory.%Factory.type (%Factory.type.c96) = import_ref Main//factory, inst26 [no loc], loaded [symbolic = @Factory.%Self (constants.%Self)]
  763. // CHECK:STDOUT: %Main.import_ref.21018a.1 = import_ref Main//factory, loc5_17, unloaded
  764. // CHECK:STDOUT: }
  765. // CHECK:STDOUT:
  766. // CHECK:STDOUT: file {
  767. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  768. // CHECK:STDOUT: .Factory = imports.%Main.Factory
  769. // CHECK:STDOUT: .A = imports.%Main.A
  770. // CHECK:STDOUT: .B = imports.%Main.B
  771. // CHECK:STDOUT: .MakeB = %MakeB.decl
  772. // CHECK:STDOUT: }
  773. // CHECK:STDOUT: %default.import.loc2_6.1 = import <none>
  774. // CHECK:STDOUT: %default.import.loc2_6.2 = import <none>
  775. // CHECK:STDOUT: %MakeB.decl: %MakeB.type = fn_decl @MakeB [concrete = constants.%MakeB] {
  776. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  777. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
  778. // CHECK:STDOUT: %return.patt: %B = return_slot_pattern
  779. // CHECK:STDOUT: %return.param_patt: %B = out_param_pattern %return.patt, runtime_param1
  780. // CHECK:STDOUT: } {
  781. // CHECK:STDOUT: %B.ref.loc4: type = name_ref B, imports.%Main.B [concrete = constants.%B]
  782. // CHECK:STDOUT: %a.param: %A = value_param runtime_param0
  783. // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%Main.A [concrete = constants.%A]
  784. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  785. // CHECK:STDOUT: %return.param: ref %B = out_param runtime_param1
  786. // CHECK:STDOUT: %return: ref %B = return_slot %return.param
  787. // CHECK:STDOUT: }
  788. // CHECK:STDOUT: }
  789. // CHECK:STDOUT:
  790. // CHECK:STDOUT: generic interface @Factory(imports.%Main.import_ref.f6b058.1: type) [from "factory.carbon"] {
  791. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  792. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  793. // CHECK:STDOUT:
  794. // CHECK:STDOUT: !definition:
  795. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(%T)> [symbolic = %Factory.type (constants.%Factory.type.c96)]
  796. // CHECK:STDOUT: %Self: %Factory.type.c96 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  797. // CHECK:STDOUT: %Make.type: type = fn_type @Make.1, @Factory(%T) [symbolic = %Make.type (constants.%Make.type.598)]
  798. // CHECK:STDOUT: %Make: @Factory.%Make.type (%Make.type.598) = struct_value () [symbolic = %Make (constants.%Make.737)]
  799. // CHECK:STDOUT: %Factory.assoc_type: type = assoc_entity_type @Factory.%Factory.type (%Factory.type.c96) [symbolic = %Factory.assoc_type (constants.%Factory.assoc_type.ca7)]
  800. // CHECK:STDOUT: %assoc0: @Factory.%Factory.assoc_type (%Factory.assoc_type.ca7) = assoc_entity element0, imports.%Main.import_ref.21018a.1 [symbolic = %assoc0 (constants.%assoc0.35472f.1)]
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: interface {
  803. // CHECK:STDOUT: !members:
  804. // CHECK:STDOUT: .Self = imports.%Main.import_ref.fbb
  805. // CHECK:STDOUT: .Make = imports.%Main.import_ref.8d5
  806. // CHECK:STDOUT: witness = (imports.%Main.Make)
  807. // CHECK:STDOUT: }
  808. // CHECK:STDOUT: }
  809. // CHECK:STDOUT:
  810. // CHECK:STDOUT: impl @impl: imports.%Main.import_ref.984 as imports.%Main.import_ref.bd2 [from "factory.carbon"] {
  811. // CHECK:STDOUT: !members:
  812. // CHECK:STDOUT: .Make = imports.%Main.import_ref.a27
  813. // CHECK:STDOUT: witness = imports.%Main.import_ref.72b
  814. // CHECK:STDOUT: }
  815. // CHECK:STDOUT:
  816. // CHECK:STDOUT: class @B [from "factory.carbon"] {
  817. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  818. // CHECK:STDOUT:
  819. // CHECK:STDOUT: !members:
  820. // CHECK:STDOUT: .Self = imports.%Main.import_ref.54a
  821. // CHECK:STDOUT: }
  822. // CHECK:STDOUT:
  823. // CHECK:STDOUT: class @A [from "factory.carbon"] {
  824. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  825. // CHECK:STDOUT:
  826. // CHECK:STDOUT: !members:
  827. // CHECK:STDOUT: .Self = imports.%Main.import_ref.da3
  828. // CHECK:STDOUT: }
  829. // CHECK:STDOUT:
  830. // CHECK:STDOUT: generic fn @Make.1(imports.%Main.import_ref.f6b058.2: type, imports.%Main.import_ref.91b: @Factory.%Factory.type (%Factory.type.c96)) [from "factory.carbon"] {
  831. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  832. // CHECK:STDOUT:
  833. // CHECK:STDOUT: fn() -> @Make.1.%T (%T);
  834. // CHECK:STDOUT: }
  835. // CHECK:STDOUT:
  836. // CHECK:STDOUT: fn @MakeB(%a.param_patt: %A) -> %return.param_patt: %B {
  837. // CHECK:STDOUT: !entry:
  838. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  839. // CHECK:STDOUT: %Factory.ref: %Factory.type.1a8 = name_ref Factory, imports.%Main.Factory [concrete = constants.%Factory.generic]
  840. // CHECK:STDOUT: %B.ref.loc5: type = name_ref B, imports.%Main.B [concrete = constants.%B]
  841. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(constants.%B)> [concrete = constants.%Factory.type.a5d]
  842. // CHECK:STDOUT: %.loc5: %Factory.assoc_type.668 = specific_constant imports.%Main.import_ref.8d5, @Factory(constants.%B) [concrete = constants.%assoc0.503]
  843. // CHECK:STDOUT: %Make.ref: %Factory.assoc_type.668 = name_ref Make, %.loc5 [concrete = constants.%assoc0.503]
  844. // CHECK:STDOUT: %impl.elem0: %.357 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%Make.377]
  845. // CHECK:STDOUT: %.loc4: ref %B = splice_block %return {}
  846. // CHECK:STDOUT: %Make.call: init %B = call %impl.elem0() to %.loc4
  847. // CHECK:STDOUT: return %Make.call to %return
  848. // CHECK:STDOUT: }
  849. // CHECK:STDOUT:
  850. // CHECK:STDOUT: fn @Make.2() -> %B [from "factory.carbon"];
  851. // CHECK:STDOUT:
  852. // CHECK:STDOUT: specific @Factory(constants.%T) {
  853. // CHECK:STDOUT: %T => constants.%T
  854. // CHECK:STDOUT: %T.patt => constants.%T
  855. // CHECK:STDOUT: }
  856. // CHECK:STDOUT:
  857. // CHECK:STDOUT: specific @Factory(constants.%B) {
  858. // CHECK:STDOUT: %T => constants.%B
  859. // CHECK:STDOUT: %T.patt => constants.%B
  860. // CHECK:STDOUT:
  861. // CHECK:STDOUT: !definition:
  862. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.a5d
  863. // CHECK:STDOUT: %Self => constants.%Self
  864. // CHECK:STDOUT: %Make.type => constants.%Make.type.c59
  865. // CHECK:STDOUT: %Make => constants.%Make.efe
  866. // CHECK:STDOUT: %Factory.assoc_type => constants.%Factory.assoc_type.668
  867. // CHECK:STDOUT: %assoc0 => constants.%assoc0.503
  868. // CHECK:STDOUT: }
  869. // CHECK:STDOUT:
  870. // CHECK:STDOUT: specific @Factory(%T) {}
  871. // CHECK:STDOUT:
  872. // CHECK:STDOUT: specific @Make.1(constants.%T, constants.%Self) {
  873. // CHECK:STDOUT: %T => constants.%T
  874. // CHECK:STDOUT: }
  875. // CHECK:STDOUT:
  876. // CHECK:STDOUT: --- fail_factory.impl.carbon
  877. // CHECK:STDOUT:
  878. // CHECK:STDOUT: constants {
  879. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  880. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  881. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  882. // CHECK:STDOUT: %Factory.type.1a8: type = generic_interface_type @Factory [concrete]
  883. // CHECK:STDOUT: %Factory.generic: %Factory.type.1a8 = struct_value () [concrete]
  884. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  885. // CHECK:STDOUT: %Factory.type.c96: type = facet_type <@Factory, @Factory(%T)> [symbolic]
  886. // CHECK:STDOUT: %Self: %Factory.type.c96 = bind_symbolic_name Self, 1 [symbolic]
  887. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  888. // CHECK:STDOUT: %Factory.type.a5d: type = facet_type <@Factory, @Factory(%B)> [concrete]
  889. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  890. // CHECK:STDOUT: %Make.type.598: type = fn_type @Make, @Factory(%T) [symbolic]
  891. // CHECK:STDOUT: %Make.737: %Make.type.598 = struct_value () [symbolic]
  892. // CHECK:STDOUT: %Factory.assoc_type.ca7: type = assoc_entity_type %Factory.type.c96 [symbolic]
  893. // CHECK:STDOUT: %assoc0.35472f.1: %Factory.assoc_type.ca7 = assoc_entity element0, imports.%Main.import_ref.21018a.1 [symbolic]
  894. // CHECK:STDOUT: %Make.type.c59: type = fn_type @Make, @Factory(%B) [concrete]
  895. // CHECK:STDOUT: %Make.efe: %Make.type.c59 = struct_value () [concrete]
  896. // CHECK:STDOUT: %Factory.assoc_type.668: type = assoc_entity_type %Factory.type.a5d [concrete]
  897. // CHECK:STDOUT: %assoc0.228: %Factory.assoc_type.668 = assoc_entity element0, imports.%Main.import_ref.21018a.2 [concrete]
  898. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  899. // CHECK:STDOUT: %MakeC.type: type = fn_type @MakeC [concrete]
  900. // CHECK:STDOUT: %MakeC: %MakeC.type = struct_value () [concrete]
  901. // CHECK:STDOUT: %Factory.type.5c5: type = facet_type <@Factory, @Factory(%C)> [concrete]
  902. // CHECK:STDOUT: %Make.type.0de: type = fn_type @Make, @Factory(%C) [concrete]
  903. // CHECK:STDOUT: %Make.8ba: %Make.type.0de = struct_value () [concrete]
  904. // CHECK:STDOUT: %Factory.assoc_type.709: type = assoc_entity_type %Factory.type.5c5 [concrete]
  905. // CHECK:STDOUT: %assoc0.ef9: %Factory.assoc_type.709 = assoc_entity element0, imports.%Main.import_ref.21018a.1 [concrete]
  906. // CHECK:STDOUT: %assoc0.35472f.2: %Factory.assoc_type.ca7 = assoc_entity element0, imports.%Main.import_ref.21018a.3 [symbolic]
  907. // CHECK:STDOUT: }
  908. // CHECK:STDOUT:
  909. // CHECK:STDOUT: imports {
  910. // CHECK:STDOUT: %Main.Factory: %Factory.type.1a8 = import_ref Main//factory, Factory, loaded [concrete = constants.%Factory.generic]
  911. // CHECK:STDOUT: %Main.A: type = import_ref Main//factory, A, loaded [concrete = constants.%A]
  912. // CHECK:STDOUT: %Main.B = import_ref Main//factory, B, unloaded
  913. // CHECK:STDOUT: %Main.import_ref.3e9 = import_ref Main//factory, loc11_22, unloaded
  914. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//factory, loc9_10, loaded [concrete = constants.%complete_type]
  915. // CHECK:STDOUT: %Main.import_ref.54a = import_ref Main//factory, inst52 [no loc], unloaded
  916. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//factory, loc4_19, loaded [symbolic = @Factory.%T (constants.%T)]
  917. // CHECK:STDOUT: %Main.import_ref.fbb = import_ref Main//factory, inst26 [no loc], unloaded
  918. // CHECK:STDOUT: %Main.import_ref.8d5: @Factory.%Factory.assoc_type (%Factory.assoc_type.ca7) = import_ref Main//factory, loc5_17, loaded [symbolic = @Factory.%assoc0 (constants.%assoc0.35472f.2)]
  919. // CHECK:STDOUT: %Main.Make = import_ref Main//factory, Make, unloaded
  920. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//factory, loc8_10, loaded [concrete = constants.%complete_type]
  921. // CHECK:STDOUT: %Main.import_ref.da3 = import_ref Main//factory, inst47 [no loc], unloaded
  922. // CHECK:STDOUT: %Main.import_ref.984: type = import_ref Main//factory, loc11_6, loaded [concrete = constants.%A]
  923. // CHECK:STDOUT: %Main.import_ref.bd2: type = import_ref Main//factory, loc11_20, loaded [concrete = constants.%Factory.type.a5d]
  924. // CHECK:STDOUT: %Main.import_ref.a27 = import_ref Main//factory, loc12_17, unloaded
  925. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//factory, loc4_19, loaded [symbolic = @Factory.%T (constants.%T)]
  926. // CHECK:STDOUT: %Main.import_ref.91b: @Factory.%Factory.type (%Factory.type.c96) = import_ref Main//factory, inst26 [no loc], loaded [symbolic = @Factory.%Self (constants.%Self)]
  927. // CHECK:STDOUT: %Main.import_ref.21018a.1 = import_ref Main//factory, loc5_17, unloaded
  928. // CHECK:STDOUT: }
  929. // CHECK:STDOUT:
  930. // CHECK:STDOUT: file {
  931. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  932. // CHECK:STDOUT: .Factory = imports.%Main.Factory
  933. // CHECK:STDOUT: .A = imports.%Main.A
  934. // CHECK:STDOUT: .B = imports.%Main.B
  935. // CHECK:STDOUT: .C = %C.decl
  936. // CHECK:STDOUT: .MakeC = %MakeC.decl
  937. // CHECK:STDOUT: }
  938. // CHECK:STDOUT: %default.import.loc2_6.1 = import <none>
  939. // CHECK:STDOUT: %default.import.loc2_6.2 = import <none>
  940. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  941. // CHECK:STDOUT: %MakeC.decl: %MakeC.type = fn_decl @MakeC [concrete = constants.%MakeC] {
  942. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  943. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
  944. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  945. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param1
  946. // CHECK:STDOUT: } {
  947. // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, file.%C.decl [concrete = constants.%C]
  948. // CHECK:STDOUT: %a.param: %A = value_param runtime_param0
  949. // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%Main.A [concrete = constants.%A]
  950. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  951. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param1
  952. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  953. // CHECK:STDOUT: }
  954. // CHECK:STDOUT: }
  955. // CHECK:STDOUT:
  956. // CHECK:STDOUT: generic interface @Factory(imports.%Main.import_ref.f6b058.1: type) [from "factory.carbon"] {
  957. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  958. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  959. // CHECK:STDOUT:
  960. // CHECK:STDOUT: !definition:
  961. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(%T)> [symbolic = %Factory.type (constants.%Factory.type.c96)]
  962. // CHECK:STDOUT: %Self: %Factory.type.c96 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  963. // CHECK:STDOUT: %Make.type: type = fn_type @Make, @Factory(%T) [symbolic = %Make.type (constants.%Make.type.598)]
  964. // CHECK:STDOUT: %Make: @Factory.%Make.type (%Make.type.598) = struct_value () [symbolic = %Make (constants.%Make.737)]
  965. // CHECK:STDOUT: %Factory.assoc_type: type = assoc_entity_type @Factory.%Factory.type (%Factory.type.c96) [symbolic = %Factory.assoc_type (constants.%Factory.assoc_type.ca7)]
  966. // CHECK:STDOUT: %assoc0: @Factory.%Factory.assoc_type (%Factory.assoc_type.ca7) = assoc_entity element0, imports.%Main.import_ref.21018a.1 [symbolic = %assoc0 (constants.%assoc0.35472f.1)]
  967. // CHECK:STDOUT:
  968. // CHECK:STDOUT: interface {
  969. // CHECK:STDOUT: !members:
  970. // CHECK:STDOUT: .Self = imports.%Main.import_ref.fbb
  971. // CHECK:STDOUT: .Make = imports.%Main.import_ref.8d5
  972. // CHECK:STDOUT: witness = (imports.%Main.Make)
  973. // CHECK:STDOUT: }
  974. // CHECK:STDOUT: }
  975. // CHECK:STDOUT:
  976. // CHECK:STDOUT: impl @impl: imports.%Main.import_ref.984 as imports.%Main.import_ref.bd2 [from "factory.carbon"] {
  977. // CHECK:STDOUT: !members:
  978. // CHECK:STDOUT: .Make = imports.%Main.import_ref.a27
  979. // CHECK:STDOUT: witness = imports.%Main.import_ref.3e9
  980. // CHECK:STDOUT: }
  981. // CHECK:STDOUT:
  982. // CHECK:STDOUT: class @B [from "factory.carbon"] {
  983. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  984. // CHECK:STDOUT:
  985. // CHECK:STDOUT: !members:
  986. // CHECK:STDOUT: .Self = imports.%Main.import_ref.54a
  987. // CHECK:STDOUT: }
  988. // CHECK:STDOUT:
  989. // CHECK:STDOUT: class @A [from "factory.carbon"] {
  990. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  991. // CHECK:STDOUT:
  992. // CHECK:STDOUT: !members:
  993. // CHECK:STDOUT: .Self = imports.%Main.import_ref.da3
  994. // CHECK:STDOUT: }
  995. // CHECK:STDOUT:
  996. // CHECK:STDOUT: class @C {
  997. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  998. // CHECK:STDOUT: complete_type_witness = %complete_type
  999. // CHECK:STDOUT:
  1000. // CHECK:STDOUT: !members:
  1001. // CHECK:STDOUT: .Self = constants.%C
  1002. // CHECK:STDOUT: }
  1003. // CHECK:STDOUT:
  1004. // CHECK:STDOUT: generic fn @Make(imports.%Main.import_ref.f6b058.2: type, imports.%Main.import_ref.91b: @Factory.%Factory.type (%Factory.type.c96)) [from "factory.carbon"] {
  1005. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  1006. // CHECK:STDOUT:
  1007. // CHECK:STDOUT: fn() -> @Make.%T (%T);
  1008. // CHECK:STDOUT: }
  1009. // CHECK:STDOUT:
  1010. // CHECK:STDOUT: fn @MakeC(%a.param_patt: %A) -> %return.param_patt: %C {
  1011. // CHECK:STDOUT: !entry:
  1012. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  1013. // CHECK:STDOUT: %Factory.ref: %Factory.type.1a8 = name_ref Factory, imports.%Main.Factory [concrete = constants.%Factory.generic]
  1014. // CHECK:STDOUT: %C.ref.loc11: type = name_ref C, file.%C.decl [concrete = constants.%C]
  1015. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(constants.%C)> [concrete = constants.%Factory.type.5c5]
  1016. // CHECK:STDOUT: %.loc11: %Factory.assoc_type.709 = specific_constant imports.%Main.import_ref.8d5, @Factory(constants.%C) [concrete = constants.%assoc0.ef9]
  1017. // CHECK:STDOUT: %Make.ref: %Factory.assoc_type.709 = name_ref Make, %.loc11 [concrete = constants.%assoc0.ef9]
  1018. // CHECK:STDOUT: return <error> to %return
  1019. // CHECK:STDOUT: }
  1020. // CHECK:STDOUT:
  1021. // CHECK:STDOUT: specific @Factory(constants.%T) {
  1022. // CHECK:STDOUT: %T => constants.%T
  1023. // CHECK:STDOUT: %T.patt => constants.%T
  1024. // CHECK:STDOUT: }
  1025. // CHECK:STDOUT:
  1026. // CHECK:STDOUT: specific @Factory(constants.%B) {
  1027. // CHECK:STDOUT: %T => constants.%B
  1028. // CHECK:STDOUT: %T.patt => constants.%B
  1029. // CHECK:STDOUT:
  1030. // CHECK:STDOUT: !definition:
  1031. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.a5d
  1032. // CHECK:STDOUT: %Self => constants.%Self
  1033. // CHECK:STDOUT: %Make.type => constants.%Make.type.c59
  1034. // CHECK:STDOUT: %Make => constants.%Make.efe
  1035. // CHECK:STDOUT: %Factory.assoc_type => constants.%Factory.assoc_type.668
  1036. // CHECK:STDOUT: %assoc0 => constants.%assoc0.228
  1037. // CHECK:STDOUT: }
  1038. // CHECK:STDOUT:
  1039. // CHECK:STDOUT: specific @Factory(%T) {}
  1040. // CHECK:STDOUT:
  1041. // CHECK:STDOUT: specific @Make(constants.%T, constants.%Self) {
  1042. // CHECK:STDOUT: %T => constants.%T
  1043. // CHECK:STDOUT: }
  1044. // CHECK:STDOUT:
  1045. // CHECK:STDOUT: specific @Factory(constants.%C) {
  1046. // CHECK:STDOUT: %T => constants.%C
  1047. // CHECK:STDOUT: %T.patt => constants.%C
  1048. // CHECK:STDOUT:
  1049. // CHECK:STDOUT: !definition:
  1050. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.5c5
  1051. // CHECK:STDOUT: %Self => constants.%Self
  1052. // CHECK:STDOUT: %Make.type => constants.%Make.type.0de
  1053. // CHECK:STDOUT: %Make => constants.%Make.8ba
  1054. // CHECK:STDOUT: %Factory.assoc_type => constants.%Factory.assoc_type.709
  1055. // CHECK:STDOUT: %assoc0 => constants.%assoc0.ef9
  1056. // CHECK:STDOUT: }
  1057. // CHECK:STDOUT: