interface_args.carbon 59 KB

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