interface_args.carbon 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  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+3]]: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. 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: %empty_tuple.type: type = tuple_type () [template]
  63. // CHECK:STDOUT: %Action: %Action.type.1 = struct_value () [template]
  64. // CHECK:STDOUT: %Action.type.2: type = facet_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: %.1: type = assoc_entity_type %Action.type.2, %Op.type.1 [symbolic]
  69. // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @Action.%Op.decl [symbolic]
  70. // CHECK:STDOUT: %A: type = class_type @A [template]
  71. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  72. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [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 = facet_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: %.5: type = assoc_entity_type %Action.type.3, %Op.type.3 [template]
  81. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, @Action.%Op.decl [template]
  82. // CHECK:STDOUT: %.7: <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: %.8: type = ptr_type %.3 [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 = value_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: %T.param: type = value_param runtime_param<invalid>
  101. // CHECK:STDOUT: %T.loc4_18.1: type = bind_symbolic_name T, 0, %T.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 = facet_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 = value_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: %a.param: %A = value_param runtime_param0
  118. // CHECK:STDOUT: %a: %A = bind_name a, %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 = facet_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.%.1)]
  132. // CHECK:STDOUT: %.loc5_10.3: @Action.%.loc5_10.2 (%.1) = assoc_entity element0, %Op.decl [symbolic = %.loc5_10.3 (constants.%.2)]
  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 (%.1) = assoc_entity element0, %Op.decl [symbolic = %.loc5_10.3 (constants.%.2)]
  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.%.7]
  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 %.3 [template = constants.%.4]
  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 %.3 [template = constants.%.4]
  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 %.3 [template = constants.%.4]
  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 = facet_type <@Action, @Action(constants.%B)> [template = constants.%Action.type.3]
  192. // CHECK:STDOUT: %.loc16_26: %.5 = specific_constant @Action.%.loc5_10.1, @Action(constants.%B) [template = constants.%.6]
  193. // CHECK:STDOUT: %Op.ref: %.5 = name_ref Op, %.loc16_26 [template = constants.%.6]
  194. // CHECK:STDOUT: %.loc16_15: %Op.type.3 = interface_witness_access constants.%.7, element0 [template = constants.%Op.2]
  195. // CHECK:STDOUT: %Op.call: init %empty_tuple.type = 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.%.5
  221. // CHECK:STDOUT: %.loc5_10.3 => constants.%.6
  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: %empty_tuple.type: 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 = facet_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 = facet_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: %.3: type = assoc_entity_type %Action.type.2, %Op.type.1 [symbolic]
  245. // CHECK:STDOUT: %.4: %.3 = 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: %.5: type = assoc_entity_type %Action.type.3, %Op.type.2 [template]
  249. // CHECK:STDOUT: %.6: %.5 = 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: %.7: type = ptr_type %.1 [template]
  253. // CHECK:STDOUT: %.8: %.3 = 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: %.9: <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 (%.3) = import_ref Main//action, inst+20, loaded [symbolic = @Action.%.2 (constants.%.8)]
  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.%.9]
  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 = value_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: %a.param: %A = value_param runtime_param0
  296. // CHECK:STDOUT: %a: %A = bind_name a, %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 = facet_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.%.3)]
  310. // CHECK:STDOUT: %.2: @Action.%.1 (%.3) = assoc_entity element0, imports.%import_ref.15 [symbolic = %.2 (constants.%.4)]
  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 = facet_type <@Action, @Action(constants.%B)> [template = constants.%Action.type.3]
  347. // CHECK:STDOUT: %.loc4_26: %.5 = specific_constant imports.%import_ref.8, @Action(constants.%B) [template = constants.%.6]
  348. // CHECK:STDOUT: %Op.ref: %.5 = name_ref Op, %.loc4_26 [template = constants.%.6]
  349. // CHECK:STDOUT: %.loc4_15: %Op.type.2 = interface_witness_access constants.%.9, element0 [template = constants.%Op.3]
  350. // CHECK:STDOUT: %Op.call: init %empty_tuple.type = 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.%.5
  371. // CHECK:STDOUT: %.2 => constants.%.6
  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: %empty_tuple.type: 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 = facet_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 = facet_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: %.3: type = assoc_entity_type %Action.type.2, %Op.type.1 [symbolic]
  400. // CHECK:STDOUT: %.4: %.3 = 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: %.5: type = assoc_entity_type %Action.type.3, %Op.type.2 [template]
  404. // CHECK:STDOUT: %.6: %.5 = 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: %.7: type = ptr_type %.1 [template]
  408. // CHECK:STDOUT: %C: type = class_type @C [template]
  409. // CHECK:STDOUT: %Action.type.4: type = facet_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: %.8: type = assoc_entity_type %Action.type.4, %Op.type.3 [template]
  413. // CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.15 [template]
  414. // CHECK:STDOUT: %.10: %.3 = 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 (%.3) = import_ref Main//action, inst+20, loaded [symbolic = @Action.%.2 (constants.%.10)]
  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 = value_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: %a.param: %A = value_param runtime_param0
  455. // CHECK:STDOUT: %a: %A = bind_name a, %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 = facet_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.%.3)]
  469. // CHECK:STDOUT: %.2: @Action.%.1 (%.3) = assoc_entity element0, imports.%import_ref.15 [symbolic = %.2 (constants.%.4)]
  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 = facet_type <@Action, @Action(constants.%C)> [template = constants.%Action.type.4]
  511. // CHECK:STDOUT: %.loc8: %.8 = specific_constant imports.%import_ref.8, @Action(constants.%C) [template = constants.%.9]
  512. // CHECK:STDOUT: %Op.ref: %.8 = name_ref Op, %.loc8 [template = constants.%.9]
  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.%.5
  531. // CHECK:STDOUT: %.2 => constants.%.6
  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.%.8
  551. // CHECK:STDOUT: %.2 => constants.%.9
  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: %empty_tuple.type: type = tuple_type () [template]
  561. // CHECK:STDOUT: %Factory: %Factory.type.1 = struct_value () [template]
  562. // CHECK:STDOUT: %Factory.type.2: type = facet_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: %.1: type = assoc_entity_type %Factory.type.2, %Make.type.1 [symbolic]
  567. // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @Factory.%Make.decl [symbolic]
  568. // CHECK:STDOUT: %A: type = class_type @A [template]
  569. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  570. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  571. // CHECK:STDOUT: %B: type = class_type @B [template]
  572. // CHECK:STDOUT: %Factory.type.3: type = facet_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: %.5: type = assoc_entity_type %Factory.type.3, %Make.type.3 [template]
  578. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, @Factory.%Make.decl [template]
  579. // CHECK:STDOUT: %.7: <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 = value_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: %T.param: type = value_param runtime_param<invalid>
  593. // CHECK:STDOUT: %T.loc4_19.1: type = bind_symbolic_name T, 0, %T.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 = facet_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 = facet_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.%.1)]
  615. // CHECK:STDOUT: %.loc5_17.3: @Factory.%.loc5_17.2 (%.1) = assoc_entity element0, %Make.decl [symbolic = %.loc5_17.3 (constants.%.2)]
  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: %return.patt: @Make.1.%T (%T) = return_slot_pattern
  621. // CHECK:STDOUT: %return.param_patt: @Make.1.%T (%T) = out_param_pattern %return.patt, runtime_param0
  622. // CHECK:STDOUT: } {
  623. // CHECK:STDOUT: %T.ref: type = name_ref T, @Factory.%T.loc4_19.1 [symbolic = %T (constants.%T)]
  624. // CHECK:STDOUT: %return.param: ref @Make.1.%T (%T) = out_param runtime_param0
  625. // CHECK:STDOUT: %return: ref @Make.1.%T (%T) = return_slot %return.param
  626. // CHECK:STDOUT: }
  627. // CHECK:STDOUT: %.loc5_17.1: @Factory.%.loc5_17.2 (%.1) = assoc_entity element0, %Make.decl [symbolic = %.loc5_17.3 (constants.%.2)]
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: !members:
  630. // CHECK:STDOUT: .Self = %Self.1
  631. // CHECK:STDOUT: .Make = %.loc5_17.1
  632. // CHECK:STDOUT: witness = (%Make.decl)
  633. // CHECK:STDOUT: }
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT:
  636. // CHECK:STDOUT: impl @impl: %A.ref as %Factory.type {
  637. // CHECK:STDOUT: %Make.decl: %Make.type.2 = fn_decl @Make.2 [template = constants.%Make.2] {
  638. // CHECK:STDOUT: %return.patt: %B = return_slot_pattern
  639. // CHECK:STDOUT: %return.param_patt: %B = out_param_pattern %return.patt, runtime_param0
  640. // CHECK:STDOUT: } {
  641. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  642. // CHECK:STDOUT: %return.param: ref %B = out_param runtime_param0
  643. // CHECK:STDOUT: %return: ref %B = return_slot %return.param
  644. // CHECK:STDOUT: }
  645. // CHECK:STDOUT: %.loc11: <witness> = interface_witness (%Make.decl) [template = constants.%.7]
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: !members:
  648. // CHECK:STDOUT: .Make = %Make.decl
  649. // CHECK:STDOUT: witness = %.loc11
  650. // CHECK:STDOUT: }
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: class @A {
  653. // CHECK:STDOUT: %.loc8: <witness> = complete_type_witness %.3 [template = constants.%.4]
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: !members:
  656. // CHECK:STDOUT: .Self = constants.%A
  657. // CHECK:STDOUT: }
  658. // CHECK:STDOUT:
  659. // CHECK:STDOUT: class @B {
  660. // CHECK:STDOUT: %.loc9: <witness> = complete_type_witness %.3 [template = constants.%.4]
  661. // CHECK:STDOUT:
  662. // CHECK:STDOUT: !members:
  663. // CHECK:STDOUT: .Self = constants.%B
  664. // CHECK:STDOUT: }
  665. // CHECK:STDOUT:
  666. // CHECK:STDOUT: generic fn @Make.1(@Factory.%T.loc4_19.1: type, @Factory.%Self.1: @Factory.%Factory.type (%Factory.type.2)) {
  667. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  668. // CHECK:STDOUT:
  669. // CHECK:STDOUT: fn() -> @Make.1.%T (%T);
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT:
  672. // CHECK:STDOUT: fn @Make.2() -> %B;
  673. // CHECK:STDOUT:
  674. // CHECK:STDOUT: specific @Factory(constants.%T) {
  675. // CHECK:STDOUT: %T.loc4_19.2 => constants.%T
  676. // CHECK:STDOUT: %T.patt.loc4_19.2 => constants.%T
  677. // CHECK:STDOUT: }
  678. // CHECK:STDOUT:
  679. // CHECK:STDOUT: specific @Make.1(constants.%T, constants.%Self) {
  680. // CHECK:STDOUT: %T => constants.%T
  681. // CHECK:STDOUT: }
  682. // CHECK:STDOUT:
  683. // CHECK:STDOUT: specific @Factory(@Factory.%T.loc4_19.2) {
  684. // CHECK:STDOUT: %T.loc4_19.2 => constants.%T
  685. // CHECK:STDOUT: %T.patt.loc4_19.2 => constants.%T
  686. // CHECK:STDOUT: }
  687. // CHECK:STDOUT:
  688. // CHECK:STDOUT: specific @Factory(constants.%B) {
  689. // CHECK:STDOUT: %T.loc4_19.2 => constants.%B
  690. // CHECK:STDOUT: %T.patt.loc4_19.2 => constants.%B
  691. // CHECK:STDOUT:
  692. // CHECK:STDOUT: !definition:
  693. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.3
  694. // CHECK:STDOUT: %Self.2 => constants.%Self
  695. // CHECK:STDOUT: %Make.type => constants.%Make.type.3
  696. // CHECK:STDOUT: %Make => constants.%Make.3
  697. // CHECK:STDOUT: %.loc5_17.2 => constants.%.5
  698. // CHECK:STDOUT: %.loc5_17.3 => constants.%.6
  699. // CHECK:STDOUT: }
  700. // CHECK:STDOUT:
  701. // CHECK:STDOUT: specific @Make.1(constants.%B, constants.%A) {
  702. // CHECK:STDOUT: %T => constants.%B
  703. // CHECK:STDOUT: }
  704. // CHECK:STDOUT:
  705. // CHECK:STDOUT: --- factory.impl.carbon
  706. // CHECK:STDOUT:
  707. // CHECK:STDOUT: constants {
  708. // CHECK:STDOUT: %B: type = class_type @B [template]
  709. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  710. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  711. // CHECK:STDOUT: %Factory.type.1: type = generic_interface_type @Factory [template]
  712. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  713. // CHECK:STDOUT: %Factory: %Factory.type.1 = struct_value () [template]
  714. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  715. // CHECK:STDOUT: %Factory.type.2: type = facet_type <@Factory, @Factory(%T)> [symbolic]
  716. // CHECK:STDOUT: %Self.1: @Factory.%Factory.type (%Factory.type.2) = bind_symbolic_name Self, 1 [symbolic]
  717. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  718. // CHECK:STDOUT: %Factory.type.3: type = facet_type <@Factory, @Factory(%B)> [template]
  719. // CHECK:STDOUT: %A: type = class_type @A [template]
  720. // CHECK:STDOUT: %Self.2: %Factory.type.2 = bind_symbolic_name Self, 1 [symbolic]
  721. // CHECK:STDOUT: %Make.type.1: type = fn_type @Make.1, @Factory(%T) [symbolic]
  722. // CHECK:STDOUT: %Make.1: %Make.type.1 = struct_value () [symbolic]
  723. // CHECK:STDOUT: %.3: type = assoc_entity_type %Factory.type.2, %Make.type.1 [symbolic]
  724. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.13 [symbolic]
  725. // CHECK:STDOUT: %Make.type.2: type = fn_type @Make.1, @Factory(%B) [template]
  726. // CHECK:STDOUT: %Make.2: %Make.type.2 = struct_value () [template]
  727. // CHECK:STDOUT: %.5: type = assoc_entity_type %Factory.type.3, %Make.type.2 [template]
  728. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.14 [template]
  729. // CHECK:STDOUT: %MakeB.type: type = fn_type @MakeB [template]
  730. // CHECK:STDOUT: %MakeB: %MakeB.type = struct_value () [template]
  731. // CHECK:STDOUT: %.7: type = ptr_type %.1 [template]
  732. // CHECK:STDOUT: %.8: %.3 = assoc_entity element0, imports.%import_ref.15 [symbolic]
  733. // CHECK:STDOUT: %Make.type.3: type = fn_type @Make.2 [template]
  734. // CHECK:STDOUT: %Make.3: %Make.type.3 = struct_value () [template]
  735. // CHECK:STDOUT: %.9: <witness> = interface_witness (%Make.3) [template]
  736. // CHECK:STDOUT: }
  737. // CHECK:STDOUT:
  738. // CHECK:STDOUT: imports {
  739. // CHECK:STDOUT: %import_ref.1: %Factory.type.1 = import_ref Main//factory, inst+7, loaded [template = constants.%Factory]
  740. // CHECK:STDOUT: %import_ref.2: type = import_ref Main//factory, inst+34, loaded [template = constants.%A]
  741. // CHECK:STDOUT: %import_ref.3: type = import_ref Main//factory, inst+39, loaded [template = constants.%B]
  742. // CHECK:STDOUT: %import_ref.4 = import_ref Main//factory, inst+40, unloaded
  743. // CHECK:STDOUT: %import_ref.5 = import_ref Main//factory, inst+14, unloaded
  744. // CHECK:STDOUT: %import_ref.6: @Factory.%.1 (%.3) = import_ref Main//factory, inst+26, loaded [symbolic = @Factory.%.2 (constants.%.8)]
  745. // CHECK:STDOUT: %import_ref.7 = import_ref Main//factory, inst+21, unloaded
  746. // CHECK:STDOUT: %import_ref.8 = import_ref Main//factory, inst+35, unloaded
  747. // CHECK:STDOUT: %import_ref.9: type = import_ref Main//factory, inst+42, loaded [template = constants.%A]
  748. // CHECK:STDOUT: %import_ref.10: type = import_ref Main//factory, inst+45, loaded [template = constants.%Factory.type.3]
  749. // CHECK:STDOUT: %import_ref.11: <witness> = import_ref Main//factory, inst+60, loaded [template = constants.%.9]
  750. // CHECK:STDOUT: %import_ref.12 = import_ref Main//factory, inst+53, unloaded
  751. // CHECK:STDOUT: %import_ref.13 = import_ref Main//factory, inst+21, unloaded
  752. // CHECK:STDOUT: %import_ref.14 = import_ref Main//factory, inst+21, unloaded
  753. // CHECK:STDOUT: %import_ref.15 = import_ref Main//factory, inst+21, unloaded
  754. // CHECK:STDOUT: }
  755. // CHECK:STDOUT:
  756. // CHECK:STDOUT: file {
  757. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  758. // CHECK:STDOUT: .Factory = imports.%import_ref.1
  759. // CHECK:STDOUT: .A = imports.%import_ref.2
  760. // CHECK:STDOUT: .B = imports.%import_ref.3
  761. // CHECK:STDOUT: .MakeB = %MakeB.decl
  762. // CHECK:STDOUT: }
  763. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  764. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  765. // CHECK:STDOUT: %MakeB.decl: %MakeB.type = fn_decl @MakeB [template = constants.%MakeB] {
  766. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  767. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
  768. // CHECK:STDOUT: %return.patt: %B = return_slot_pattern
  769. // CHECK:STDOUT: %return.param_patt: %B = out_param_pattern %return.patt, runtime_param1
  770. // CHECK:STDOUT: } {
  771. // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.2 [template = constants.%A]
  772. // CHECK:STDOUT: %B.ref.loc4: type = name_ref B, imports.%import_ref.3 [template = constants.%B]
  773. // CHECK:STDOUT: %a.param: %A = value_param runtime_param0
  774. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  775. // CHECK:STDOUT: %return.param: ref %B = out_param runtime_param1
  776. // CHECK:STDOUT: %return: ref %B = return_slot %return.param
  777. // CHECK:STDOUT: }
  778. // CHECK:STDOUT: }
  779. // CHECK:STDOUT:
  780. // CHECK:STDOUT: generic interface @Factory(constants.%T: type) {
  781. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  782. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  783. // CHECK:STDOUT:
  784. // CHECK:STDOUT: !definition:
  785. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(%T)> [symbolic = %Factory.type (constants.%Factory.type.2)]
  786. // CHECK:STDOUT: %Self: %Factory.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  787. // CHECK:STDOUT: %Make.type: type = fn_type @Make.1, @Factory(%T) [symbolic = %Make.type (constants.%Make.type.1)]
  788. // CHECK:STDOUT: %Make: @Factory.%Make.type (%Make.type.1) = struct_value () [symbolic = %Make (constants.%Make.1)]
  789. // CHECK:STDOUT: %.1: type = assoc_entity_type @Factory.%Factory.type (%Factory.type.2), @Factory.%Make.type (%Make.type.1) [symbolic = %.1 (constants.%.3)]
  790. // CHECK:STDOUT: %.2: @Factory.%.1 (%.3) = assoc_entity element0, imports.%import_ref.13 [symbolic = %.2 (constants.%.4)]
  791. // CHECK:STDOUT:
  792. // CHECK:STDOUT: interface {
  793. // CHECK:STDOUT: !members:
  794. // CHECK:STDOUT: .Self = imports.%import_ref.5
  795. // CHECK:STDOUT: .Make = imports.%import_ref.6
  796. // CHECK:STDOUT: witness = (imports.%import_ref.7)
  797. // CHECK:STDOUT: }
  798. // CHECK:STDOUT: }
  799. // CHECK:STDOUT:
  800. // CHECK:STDOUT: impl @impl: imports.%import_ref.9 as imports.%import_ref.10 {
  801. // CHECK:STDOUT: !members:
  802. // CHECK:STDOUT: .Make = imports.%import_ref.12
  803. // CHECK:STDOUT: witness = imports.%import_ref.11
  804. // CHECK:STDOUT: }
  805. // CHECK:STDOUT:
  806. // CHECK:STDOUT: class @B {
  807. // CHECK:STDOUT: !members:
  808. // CHECK:STDOUT: .Self = imports.%import_ref.4
  809. // CHECK:STDOUT: }
  810. // CHECK:STDOUT:
  811. // CHECK:STDOUT: class @A {
  812. // CHECK:STDOUT: !members:
  813. // CHECK:STDOUT: .Self = imports.%import_ref.8
  814. // CHECK:STDOUT: }
  815. // CHECK:STDOUT:
  816. // CHECK:STDOUT: generic fn @Make.1(constants.%T: type, constants.%Self.1: @Factory.%Factory.type (%Factory.type.2)) {
  817. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  818. // CHECK:STDOUT:
  819. // CHECK:STDOUT: fn() -> @Make.1.%T (%T);
  820. // CHECK:STDOUT: }
  821. // CHECK:STDOUT:
  822. // CHECK:STDOUT: fn @MakeB(%a.param_patt: %A) -> %return: %B {
  823. // CHECK:STDOUT: !entry:
  824. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  825. // CHECK:STDOUT: %Factory.ref: %Factory.type.1 = name_ref Factory, imports.%import_ref.1 [template = constants.%Factory]
  826. // CHECK:STDOUT: %B.ref.loc5: type = name_ref B, imports.%import_ref.3 [template = constants.%B]
  827. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(constants.%B)> [template = constants.%Factory.type.3]
  828. // CHECK:STDOUT: %.loc5_23: %.5 = specific_constant imports.%import_ref.6, @Factory(constants.%B) [template = constants.%.6]
  829. // CHECK:STDOUT: %Make.ref: %.5 = name_ref Make, %.loc5_23 [template = constants.%.6]
  830. // CHECK:STDOUT: %.loc5_11: %Make.type.2 = interface_witness_access constants.%.9, element0 [template = constants.%Make.3]
  831. // CHECK:STDOUT: %.loc4_16.2: ref %B = splice_block %return {}
  832. // CHECK:STDOUT: %Make.call: init %B = call %.loc5_11() to %.loc4_16.2
  833. // CHECK:STDOUT: return %Make.call to %return
  834. // CHECK:STDOUT: }
  835. // CHECK:STDOUT:
  836. // CHECK:STDOUT: fn @Make.2() -> %B;
  837. // CHECK:STDOUT:
  838. // CHECK:STDOUT: specific @Factory(constants.%T) {
  839. // CHECK:STDOUT: %T => constants.%T
  840. // CHECK:STDOUT: %T.patt => constants.%T
  841. // CHECK:STDOUT: }
  842. // CHECK:STDOUT:
  843. // CHECK:STDOUT: specific @Factory(constants.%B) {
  844. // CHECK:STDOUT: %T => constants.%B
  845. // CHECK:STDOUT: %T.patt => constants.%B
  846. // CHECK:STDOUT:
  847. // CHECK:STDOUT: !definition:
  848. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.3
  849. // CHECK:STDOUT: %Self => constants.%Self.2
  850. // CHECK:STDOUT: %Make.type => constants.%Make.type.2
  851. // CHECK:STDOUT: %Make => constants.%Make.2
  852. // CHECK:STDOUT: %.1 => constants.%.5
  853. // CHECK:STDOUT: %.2 => constants.%.6
  854. // CHECK:STDOUT: }
  855. // CHECK:STDOUT:
  856. // CHECK:STDOUT: specific @Factory(@Factory.%T) {
  857. // CHECK:STDOUT: %T => constants.%T
  858. // CHECK:STDOUT: %T.patt => constants.%T
  859. // CHECK:STDOUT: }
  860. // CHECK:STDOUT:
  861. // CHECK:STDOUT: specific @Make.1(constants.%T, constants.%Self.1) {
  862. // CHECK:STDOUT: %T => constants.%T
  863. // CHECK:STDOUT: }
  864. // CHECK:STDOUT:
  865. // CHECK:STDOUT: --- fail_factory.impl.carbon
  866. // CHECK:STDOUT:
  867. // CHECK:STDOUT: constants {
  868. // CHECK:STDOUT: %B: type = class_type @B [template]
  869. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  870. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  871. // CHECK:STDOUT: %Factory.type.1: type = generic_interface_type @Factory [template]
  872. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  873. // CHECK:STDOUT: %Factory: %Factory.type.1 = struct_value () [template]
  874. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  875. // CHECK:STDOUT: %Factory.type.2: type = facet_type <@Factory, @Factory(%T)> [symbolic]
  876. // CHECK:STDOUT: %Self.1: @Factory.%Factory.type (%Factory.type.2) = bind_symbolic_name Self, 1 [symbolic]
  877. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  878. // CHECK:STDOUT: %Factory.type.3: type = facet_type <@Factory, @Factory(%B)> [template]
  879. // CHECK:STDOUT: %A: type = class_type @A [template]
  880. // CHECK:STDOUT: %Self.2: %Factory.type.2 = bind_symbolic_name Self, 1 [symbolic]
  881. // CHECK:STDOUT: %Make.type.1: type = fn_type @Make, @Factory(%T) [symbolic]
  882. // CHECK:STDOUT: %Make.1: %Make.type.1 = struct_value () [symbolic]
  883. // CHECK:STDOUT: %.3: type = assoc_entity_type %Factory.type.2, %Make.type.1 [symbolic]
  884. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.13 [symbolic]
  885. // CHECK:STDOUT: %Make.type.2: type = fn_type @Make, @Factory(%B) [template]
  886. // CHECK:STDOUT: %Make.2: %Make.type.2 = struct_value () [template]
  887. // CHECK:STDOUT: %.5: type = assoc_entity_type %Factory.type.3, %Make.type.2 [template]
  888. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.14 [template]
  889. // CHECK:STDOUT: %C: type = class_type @C [template]
  890. // CHECK:STDOUT: %MakeC.type: type = fn_type @MakeC [template]
  891. // CHECK:STDOUT: %MakeC: %MakeC.type = struct_value () [template]
  892. // CHECK:STDOUT: %.7: type = ptr_type %.1 [template]
  893. // CHECK:STDOUT: %Factory.type.4: type = facet_type <@Factory, @Factory(%C)> [template]
  894. // CHECK:STDOUT: %Make.type.3: type = fn_type @Make, @Factory(%C) [template]
  895. // CHECK:STDOUT: %Make.3: %Make.type.3 = struct_value () [template]
  896. // CHECK:STDOUT: %.8: type = assoc_entity_type %Factory.type.4, %Make.type.3 [template]
  897. // CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.13 [template]
  898. // CHECK:STDOUT: %.10: %.3 = assoc_entity element0, imports.%import_ref.15 [symbolic]
  899. // CHECK:STDOUT: }
  900. // CHECK:STDOUT:
  901. // CHECK:STDOUT: imports {
  902. // CHECK:STDOUT: %import_ref.1: %Factory.type.1 = import_ref Main//factory, inst+7, loaded [template = constants.%Factory]
  903. // CHECK:STDOUT: %import_ref.2: type = import_ref Main//factory, inst+34, loaded [template = constants.%A]
  904. // CHECK:STDOUT: %import_ref.3 = import_ref Main//factory, inst+39, unloaded
  905. // CHECK:STDOUT: %import_ref.4 = import_ref Main//factory, inst+40, unloaded
  906. // CHECK:STDOUT: %import_ref.5 = import_ref Main//factory, inst+14, unloaded
  907. // CHECK:STDOUT: %import_ref.6: @Factory.%.1 (%.3) = import_ref Main//factory, inst+26, loaded [symbolic = @Factory.%.2 (constants.%.10)]
  908. // CHECK:STDOUT: %import_ref.7 = import_ref Main//factory, inst+21, unloaded
  909. // CHECK:STDOUT: %import_ref.8 = import_ref Main//factory, inst+35, unloaded
  910. // CHECK:STDOUT: %import_ref.9: type = import_ref Main//factory, inst+42, loaded [template = constants.%A]
  911. // CHECK:STDOUT: %import_ref.10: type = import_ref Main//factory, inst+45, loaded [template = constants.%Factory.type.3]
  912. // CHECK:STDOUT: %import_ref.11 = import_ref Main//factory, inst+60, unloaded
  913. // CHECK:STDOUT: %import_ref.12 = import_ref Main//factory, inst+53, unloaded
  914. // CHECK:STDOUT: %import_ref.13 = import_ref Main//factory, inst+21, unloaded
  915. // CHECK:STDOUT: %import_ref.14 = import_ref Main//factory, inst+21, unloaded
  916. // CHECK:STDOUT: %import_ref.15 = import_ref Main//factory, inst+21, unloaded
  917. // CHECK:STDOUT: }
  918. // CHECK:STDOUT:
  919. // CHECK:STDOUT: file {
  920. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  921. // CHECK:STDOUT: .Factory = imports.%import_ref.1
  922. // CHECK:STDOUT: .A = imports.%import_ref.2
  923. // CHECK:STDOUT: .B = imports.%import_ref.3
  924. // CHECK:STDOUT: .C = %C.decl
  925. // CHECK:STDOUT: .MakeC = %MakeC.decl
  926. // CHECK:STDOUT: }
  927. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  928. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  929. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  930. // CHECK:STDOUT: %MakeC.decl: %MakeC.type = fn_decl @MakeC [template = constants.%MakeC] {
  931. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  932. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
  933. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  934. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param1
  935. // CHECK:STDOUT: } {
  936. // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.2 [template = constants.%A]
  937. // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, file.%C.decl [template = constants.%C]
  938. // CHECK:STDOUT: %a.param: %A = value_param runtime_param0
  939. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  940. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param1
  941. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  942. // CHECK:STDOUT: }
  943. // CHECK:STDOUT: }
  944. // CHECK:STDOUT:
  945. // CHECK:STDOUT: generic interface @Factory(constants.%T: type) {
  946. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  947. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  948. // CHECK:STDOUT:
  949. // CHECK:STDOUT: !definition:
  950. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(%T)> [symbolic = %Factory.type (constants.%Factory.type.2)]
  951. // CHECK:STDOUT: %Self: %Factory.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  952. // CHECK:STDOUT: %Make.type: type = fn_type @Make, @Factory(%T) [symbolic = %Make.type (constants.%Make.type.1)]
  953. // CHECK:STDOUT: %Make: @Factory.%Make.type (%Make.type.1) = struct_value () [symbolic = %Make (constants.%Make.1)]
  954. // CHECK:STDOUT: %.1: type = assoc_entity_type @Factory.%Factory.type (%Factory.type.2), @Factory.%Make.type (%Make.type.1) [symbolic = %.1 (constants.%.3)]
  955. // CHECK:STDOUT: %.2: @Factory.%.1 (%.3) = assoc_entity element0, imports.%import_ref.13 [symbolic = %.2 (constants.%.4)]
  956. // CHECK:STDOUT:
  957. // CHECK:STDOUT: interface {
  958. // CHECK:STDOUT: !members:
  959. // CHECK:STDOUT: .Self = imports.%import_ref.5
  960. // CHECK:STDOUT: .Make = imports.%import_ref.6
  961. // CHECK:STDOUT: witness = (imports.%import_ref.7)
  962. // CHECK:STDOUT: }
  963. // CHECK:STDOUT: }
  964. // CHECK:STDOUT:
  965. // CHECK:STDOUT: impl @impl: imports.%import_ref.9 as imports.%import_ref.10 {
  966. // CHECK:STDOUT: !members:
  967. // CHECK:STDOUT: .Make = imports.%import_ref.12
  968. // CHECK:STDOUT: witness = imports.%import_ref.11
  969. // CHECK:STDOUT: }
  970. // CHECK:STDOUT:
  971. // CHECK:STDOUT: class @B {
  972. // CHECK:STDOUT: !members:
  973. // CHECK:STDOUT: .Self = imports.%import_ref.4
  974. // CHECK:STDOUT: }
  975. // CHECK:STDOUT:
  976. // CHECK:STDOUT: class @A {
  977. // CHECK:STDOUT: !members:
  978. // CHECK:STDOUT: .Self = imports.%import_ref.8
  979. // CHECK:STDOUT: }
  980. // CHECK:STDOUT:
  981. // CHECK:STDOUT: class @C {
  982. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  983. // CHECK:STDOUT:
  984. // CHECK:STDOUT: !members:
  985. // CHECK:STDOUT: .Self = constants.%C
  986. // CHECK:STDOUT: }
  987. // CHECK:STDOUT:
  988. // CHECK:STDOUT: generic fn @Make(constants.%T: type, constants.%Self.1: @Factory.%Factory.type (%Factory.type.2)) {
  989. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  990. // CHECK:STDOUT:
  991. // CHECK:STDOUT: fn() -> @Make.%T (%T);
  992. // CHECK:STDOUT: }
  993. // CHECK:STDOUT:
  994. // CHECK:STDOUT: fn @MakeC(%a.param_patt: %A) -> %return: %C {
  995. // CHECK:STDOUT: !entry:
  996. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  997. // CHECK:STDOUT: %Factory.ref: %Factory.type.1 = name_ref Factory, imports.%import_ref.1 [template = constants.%Factory]
  998. // CHECK:STDOUT: %C.ref.loc10: type = name_ref C, file.%C.decl [template = constants.%C]
  999. // CHECK:STDOUT: %Factory.type: type = facet_type <@Factory, @Factory(constants.%C)> [template = constants.%Factory.type.4]
  1000. // CHECK:STDOUT: %.loc10: %.8 = specific_constant imports.%import_ref.6, @Factory(constants.%C) [template = constants.%.9]
  1001. // CHECK:STDOUT: %Make.ref: %.8 = name_ref Make, %.loc10 [template = constants.%.9]
  1002. // CHECK:STDOUT: return <error> to %return
  1003. // CHECK:STDOUT: }
  1004. // CHECK:STDOUT:
  1005. // CHECK:STDOUT: specific @Factory(constants.%T) {
  1006. // CHECK:STDOUT: %T => constants.%T
  1007. // CHECK:STDOUT: %T.patt => constants.%T
  1008. // CHECK:STDOUT: }
  1009. // CHECK:STDOUT:
  1010. // CHECK:STDOUT: specific @Factory(constants.%B) {
  1011. // CHECK:STDOUT: %T => constants.%B
  1012. // CHECK:STDOUT: %T.patt => constants.%B
  1013. // CHECK:STDOUT:
  1014. // CHECK:STDOUT: !definition:
  1015. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.3
  1016. // CHECK:STDOUT: %Self => constants.%Self.2
  1017. // CHECK:STDOUT: %Make.type => constants.%Make.type.2
  1018. // CHECK:STDOUT: %Make => constants.%Make.2
  1019. // CHECK:STDOUT: %.1 => constants.%.5
  1020. // CHECK:STDOUT: %.2 => constants.%.6
  1021. // CHECK:STDOUT: }
  1022. // CHECK:STDOUT:
  1023. // CHECK:STDOUT: specific @Factory(@Factory.%T) {
  1024. // CHECK:STDOUT: %T => constants.%T
  1025. // CHECK:STDOUT: %T.patt => constants.%T
  1026. // CHECK:STDOUT: }
  1027. // CHECK:STDOUT:
  1028. // CHECK:STDOUT: specific @Make(constants.%T, constants.%Self.1) {
  1029. // CHECK:STDOUT: %T => constants.%T
  1030. // CHECK:STDOUT: }
  1031. // CHECK:STDOUT:
  1032. // CHECK:STDOUT: specific @Factory(constants.%C) {
  1033. // CHECK:STDOUT: %T => constants.%C
  1034. // CHECK:STDOUT: %T.patt => constants.%C
  1035. // CHECK:STDOUT:
  1036. // CHECK:STDOUT: !definition:
  1037. // CHECK:STDOUT: %Factory.type => constants.%Factory.type.4
  1038. // CHECK:STDOUT: %Self => constants.%Self.2
  1039. // CHECK:STDOUT: %Make.type => constants.%Make.type.3
  1040. // CHECK:STDOUT: %Make => constants.%Make.3
  1041. // CHECK:STDOUT: %.1 => constants.%.8
  1042. // CHECK:STDOUT: %.2 => constants.%.9
  1043. // CHECK:STDOUT: }
  1044. // CHECK:STDOUT: