interface_args.carbon 61 KB

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