interface_args.carbon 55 KB

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