specific_args.carbon 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  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/lookup/no_prelude/specific_args.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/no_prelude/specific_args.carbon
  10. // --- types.carbon
  11. library "[[@TEST_NAME]]";
  12. interface I(T:! type) { fn F(); }
  13. class C(T:! type) {}
  14. class X {}
  15. // --- impl_in_interface_args.carbon
  16. library "[[@TEST_NAME]]";
  17. import library "types";
  18. class InInterfaceArgs {}
  19. impl X as I(InInterfaceArgs) { fn F() {} }
  20. // --- use_impl_in_interface_args.carbon
  21. library "[[@TEST_NAME]]";
  22. import library "types";
  23. import library "impl_in_interface_args";
  24. fn G(x: X) { x.(I(InInterfaceArgs).F)(); }
  25. // --- impl_in_class_args.carbon
  26. library "[[@TEST_NAME]]";
  27. import library "types";
  28. class InClassArgs {}
  29. impl C(InClassArgs) as I(X) { fn F() {} }
  30. // --- use_impl_in_class_args.carbon
  31. library "[[@TEST_NAME]]";
  32. import library "types";
  33. import library "impl_in_class_args";
  34. fn H(c: C(InClassArgs)) { c.(I(X).F)(); }
  35. // CHECK:STDOUT: --- types.carbon
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: constants {
  38. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  39. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  40. // CHECK:STDOUT: %I.type.dac: type = generic_interface_type @I [template]
  41. // CHECK:STDOUT: %I.generic: %I.type.dac = struct_value () [template]
  42. // CHECK:STDOUT: %I.type.325: type = facet_type <@I, @I(%T)> [symbolic]
  43. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic]
  44. // CHECK:STDOUT: %F.type: type = fn_type @F, @I(%T) [symbolic]
  45. // CHECK:STDOUT: %F: %F.type = struct_value () [symbolic]
  46. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type.325 [symbolic]
  47. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%F.decl [symbolic]
  48. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  49. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  50. // CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic]
  51. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  52. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  53. // CHECK:STDOUT: %X: type = class_type @X [template]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  58. // CHECK:STDOUT: .I = %I.decl
  59. // CHECK:STDOUT: .C = %C.decl
  60. // CHECK:STDOUT: .X = %X.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %I.decl: %I.type.dac = interface_decl @I [template = constants.%I.generic] {
  63. // CHECK:STDOUT: %T.patt.loc4_13.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  64. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_13.1, runtime_param<none> [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  65. // CHECK:STDOUT: } {
  66. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  67. // CHECK:STDOUT: %T.loc4_13.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_13.2 (constants.%T)]
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] {
  70. // CHECK:STDOUT: %T.patt.loc5_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc5_9.2 (constants.%T.patt)]
  71. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc5_9.1, runtime_param<none> [symbolic = %T.patt.loc5_9.2 (constants.%T.patt)]
  72. // CHECK:STDOUT: } {
  73. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  74. // CHECK:STDOUT: %T.loc5_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc5_9.2 (constants.%T)]
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {}
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: generic interface @I(%T.loc4_13.1: type) {
  80. // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_13.2 (constants.%T)]
  81. // CHECK:STDOUT: %T.patt.loc4_13.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: !definition:
  84. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T.loc4_13.2)> [symbolic = %I.type (constants.%I.type.325)]
  85. // CHECK:STDOUT: %Self.2: %I.type.325 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  86. // CHECK:STDOUT: %F.type: type = fn_type @F, @I(%T.loc4_13.2) [symbolic = %F.type (constants.%F.type)]
  87. // CHECK:STDOUT: %F: @I.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F)]
  88. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I.%I.type (%I.type.325) [symbolic = %I.assoc_type (constants.%I.assoc_type)]
  89. // CHECK:STDOUT: %assoc0.loc4_31.2: @I.%I.assoc_type (%I.assoc_type) = assoc_entity element0, %F.decl [symbolic = %assoc0.loc4_31.2 (constants.%assoc0)]
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: interface {
  92. // CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.325) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  93. // CHECK:STDOUT: %F.decl: @I.%F.type (%F.type) = fn_decl @F [symbolic = @I.%F (constants.%F)] {} {}
  94. // CHECK:STDOUT: %assoc0.loc4_31.1: @I.%I.assoc_type (%I.assoc_type) = assoc_entity element0, %F.decl [symbolic = %assoc0.loc4_31.2 (constants.%assoc0)]
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: !members:
  97. // CHECK:STDOUT: .Self = %Self.1
  98. // CHECK:STDOUT: .F = %assoc0.loc4_31.1
  99. // CHECK:STDOUT: witness = (%F.decl)
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: generic class @C(%T.loc5_9.1: type) {
  104. // CHECK:STDOUT: %T.loc5_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc5_9.2 (constants.%T)]
  105. // CHECK:STDOUT: %T.patt.loc5_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc5_9.2 (constants.%T.patt)]
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: !definition:
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: class {
  110. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  111. // CHECK:STDOUT: complete_type_witness = %complete_type
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: !members:
  114. // CHECK:STDOUT: .Self = constants.%C
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: class @X {
  119. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  120. // CHECK:STDOUT: complete_type_witness = %complete_type
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: !members:
  123. // CHECK:STDOUT: .Self = constants.%X
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: generic fn @F(@I.%T.loc4_13.1: type, @I.%Self.1: @I.%I.type (%I.type.325)) {
  127. // CHECK:STDOUT: fn();
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: specific @I(constants.%T) {
  131. // CHECK:STDOUT: %T.loc4_13.2 => constants.%T
  132. // CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%T
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: specific @F(constants.%T, constants.%Self) {}
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: specific @I(%T.loc4_13.2) {}
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: specific @C(constants.%T) {
  140. // CHECK:STDOUT: %T.loc5_9.2 => constants.%T
  141. // CHECK:STDOUT: %T.patt.loc5_9.2 => constants.%T
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: --- impl_in_interface_args.carbon
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: constants {
  147. // CHECK:STDOUT: %InInterfaceArgs: type = class_type @InInterfaceArgs [template]
  148. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  149. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  150. // CHECK:STDOUT: %X: type = class_type @X [template]
  151. // CHECK:STDOUT: %I.type.dac: type = generic_interface_type @I [template]
  152. // CHECK:STDOUT: %I.generic: %I.type.dac = struct_value () [template]
  153. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  154. // CHECK:STDOUT: %I.type.325: type = facet_type <@I, @I(%T)> [symbolic]
  155. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic]
  156. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  157. // CHECK:STDOUT: %F.type.2ae: type = fn_type @F.1, @I(%T) [symbolic]
  158. // CHECK:STDOUT: %F.bb2: %F.type.2ae = struct_value () [symbolic]
  159. // CHECK:STDOUT: %I.assoc_type.955: type = assoc_entity_type %I.type.325 [symbolic]
  160. // CHECK:STDOUT: %assoc0.249: %I.assoc_type.955 = assoc_entity element0, imports.%Main.import_ref.479 [symbolic]
  161. // CHECK:STDOUT: %I.type.e45: type = facet_type <@I, @I(%InInterfaceArgs)> [template]
  162. // CHECK:STDOUT: %F.type.14f: type = fn_type @F.1, @I(%InInterfaceArgs) [template]
  163. // CHECK:STDOUT: %F.b81: %F.type.14f = struct_value () [template]
  164. // CHECK:STDOUT: %I.assoc_type.9f3: type = assoc_entity_type %I.type.e45 [template]
  165. // CHECK:STDOUT: %assoc0.055: %I.assoc_type.9f3 = assoc_entity element0, imports.%Main.import_ref.479 [template]
  166. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F.decl) [template]
  167. // CHECK:STDOUT: %F.type.b63: type = fn_type @F.2 [template]
  168. // CHECK:STDOUT: %F.d5f: %F.type.b63 = struct_value () [template]
  169. // CHECK:STDOUT: %I.facet: %I.type.e45 = facet_value %X, %impl_witness [template]
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: imports {
  173. // CHECK:STDOUT: %Main.I: %I.type.dac = import_ref Main//types, I, loaded [template = constants.%I.generic]
  174. // CHECK:STDOUT: %Main.C = import_ref Main//types, C, unloaded
  175. // CHECK:STDOUT: %Main.X: type = import_ref Main//types, X, loaded [template = constants.%X]
  176. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//types, loc7_10, loaded [template = constants.%complete_type]
  177. // CHECK:STDOUT: %Main.import_ref.acf = import_ref Main//types, inst54 [no loc], unloaded
  178. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  179. // CHECK:STDOUT: %Main.import_ref.884 = import_ref Main//types, inst26 [no loc], unloaded
  180. // CHECK:STDOUT: %Main.import_ref.cbe = import_ref Main//types, loc4_31, unloaded
  181. // CHECK:STDOUT: %Main.F: @I.%F.type (%F.type.2ae) = import_ref Main//types, F, loaded [symbolic = @I.%F (constants.%F.bb2)]
  182. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  183. // CHECK:STDOUT: %Main.import_ref.38e: @I.%I.type (%I.type.325) = import_ref Main//types, inst26 [no loc], loaded [symbolic = @I.%Self (constants.%Self)]
  184. // CHECK:STDOUT: %Main.import_ref.479 = import_ref Main//types, loc4_31, unloaded
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: file {
  188. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  189. // CHECK:STDOUT: .I = imports.%Main.I
  190. // CHECK:STDOUT: .C = imports.%Main.C
  191. // CHECK:STDOUT: .X = imports.%Main.X
  192. // CHECK:STDOUT: .InInterfaceArgs = %InInterfaceArgs.decl
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT: %default.import = import <none>
  195. // CHECK:STDOUT: %InInterfaceArgs.decl: type = class_decl @InInterfaceArgs [template = constants.%InInterfaceArgs] {} {}
  196. // CHECK:STDOUT: impl_decl @impl [template] {} {
  197. // CHECK:STDOUT: %X.ref: type = name_ref X, imports.%Main.X [template = constants.%X]
  198. // CHECK:STDOUT: %I.ref: %I.type.dac = name_ref I, imports.%Main.I [template = constants.%I.generic]
  199. // CHECK:STDOUT: %InInterfaceArgs.ref: type = name_ref InInterfaceArgs, file.%InInterfaceArgs.decl [template = constants.%InInterfaceArgs]
  200. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%InInterfaceArgs)> [template = constants.%I.type.e45]
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F.decl) [template = constants.%impl_witness]
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: generic interface @I(imports.%Main.import_ref.f6b058.1: type) [from "types.carbon"] {
  206. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  207. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: !definition:
  210. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.325)]
  211. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  212. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.2ae)]
  213. // CHECK:STDOUT: %F: @I.%F.type (%F.type.2ae) = struct_value () [symbolic = %F (constants.%F.bb2)]
  214. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I.%I.type (%I.type.325) [symbolic = %I.assoc_type (constants.%I.assoc_type.955)]
  215. // CHECK:STDOUT: %assoc0: @I.%I.assoc_type (%I.assoc_type.955) = assoc_entity element0, imports.%Main.import_ref.479 [symbolic = %assoc0 (constants.%assoc0.249)]
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: interface {
  218. // CHECK:STDOUT: !members:
  219. // CHECK:STDOUT: .Self = imports.%Main.import_ref.884
  220. // CHECK:STDOUT: .F = imports.%Main.import_ref.cbe
  221. // CHECK:STDOUT: witness = (imports.%Main.F)
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: impl @impl: %X.ref as %I.type {
  226. // CHECK:STDOUT: %F.decl: %F.type.b63 = fn_decl @F.2 [template = constants.%F.d5f] {} {}
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: !members:
  229. // CHECK:STDOUT: .F = %F.decl
  230. // CHECK:STDOUT: witness = file.%impl_witness
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: class @InInterfaceArgs {
  234. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  235. // CHECK:STDOUT: complete_type_witness = %complete_type
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: !members:
  238. // CHECK:STDOUT: .Self = constants.%InInterfaceArgs
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: class @X [from "types.carbon"] {
  242. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: !members:
  245. // CHECK:STDOUT: .Self = imports.%Main.import_ref.acf
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: generic fn @F.1(imports.%Main.import_ref.f6b058.2: type, imports.%Main.import_ref.38e: @I.%I.type (%I.type.325)) [from "types.carbon"] {
  249. // CHECK:STDOUT: fn();
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: fn @F.2() {
  253. // CHECK:STDOUT: !entry:
  254. // CHECK:STDOUT: return
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: specific @I(constants.%T) {
  258. // CHECK:STDOUT: %T => constants.%T
  259. // CHECK:STDOUT: %T.patt => constants.%T
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: specific @I(%T) {}
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self) {}
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: specific @I(constants.%InInterfaceArgs) {
  267. // CHECK:STDOUT: %T => constants.%InInterfaceArgs
  268. // CHECK:STDOUT: %T.patt => constants.%InInterfaceArgs
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: !definition:
  271. // CHECK:STDOUT: %I.type => constants.%I.type.e45
  272. // CHECK:STDOUT: %Self => constants.%Self
  273. // CHECK:STDOUT: %F.type => constants.%F.type.14f
  274. // CHECK:STDOUT: %F => constants.%F.b81
  275. // CHECK:STDOUT: %I.assoc_type => constants.%I.assoc_type.9f3
  276. // CHECK:STDOUT: %assoc0 => constants.%assoc0.055
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: specific @F.1(constants.%InInterfaceArgs, constants.%I.facet) {}
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: --- use_impl_in_interface_args.carbon
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: constants {
  284. // CHECK:STDOUT: %X: type = class_type @X [template]
  285. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  286. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  287. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  288. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  289. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  290. // CHECK:STDOUT: %I.type.dac: type = generic_interface_type @I [template]
  291. // CHECK:STDOUT: %I.generic: %I.type.dac = struct_value () [template]
  292. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  293. // CHECK:STDOUT: %I.type.325: type = facet_type <@I, @I(%T)> [symbolic]
  294. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic]
  295. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  296. // CHECK:STDOUT: %F.type.2ae: type = fn_type @F.1, @I(%T) [symbolic]
  297. // CHECK:STDOUT: %F.bb2: %F.type.2ae = struct_value () [symbolic]
  298. // CHECK:STDOUT: %I.assoc_type.955: type = assoc_entity_type %I.type.325 [symbolic]
  299. // CHECK:STDOUT: %assoc0.62c: %I.assoc_type.955 = assoc_entity element0, imports.%Main.import_ref.e54 [symbolic]
  300. // CHECK:STDOUT: %InInterfaceArgs: type = class_type @InInterfaceArgs [template]
  301. // CHECK:STDOUT: %I.type.e45: type = facet_type <@I, @I(%InInterfaceArgs)> [template]
  302. // CHECK:STDOUT: %F.type.14f: type = fn_type @F.1, @I(%InInterfaceArgs) [template]
  303. // CHECK:STDOUT: %F.b81: %F.type.14f = struct_value () [template]
  304. // CHECK:STDOUT: %I.assoc_type.9f3: type = assoc_entity_type %I.type.e45 [template]
  305. // CHECK:STDOUT: %assoc0.0fc: %I.assoc_type.9f3 = assoc_entity element0, imports.%Main.import_ref.e54 [template]
  306. // CHECK:STDOUT: %assoc0.249: %I.assoc_type.955 = assoc_entity element0, imports.%Main.import_ref.479 [symbolic]
  307. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (imports.%Main.import_ref.7f5) [template]
  308. // CHECK:STDOUT: %I.facet: %I.type.e45 = facet_value %X, %impl_witness [template]
  309. // CHECK:STDOUT: %.e37: type = fn_type_with_self_type %F.type.14f, %I.facet [template]
  310. // CHECK:STDOUT: %F.type.b63: type = fn_type @F.2 [template]
  311. // CHECK:STDOUT: %F.d5f: %F.type.b63 = struct_value () [template]
  312. // CHECK:STDOUT: }
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: imports {
  315. // CHECK:STDOUT: %Main.I: %I.type.dac = import_ref Main//types, I, loaded [template = constants.%I.generic]
  316. // CHECK:STDOUT: %Main.C = import_ref Main//types, C, unloaded
  317. // CHECK:STDOUT: %Main.X: type = import_ref Main//types, X, loaded [template = constants.%X]
  318. // CHECK:STDOUT: %Main.InInterfaceArgs: type = import_ref Main//impl_in_interface_args, InInterfaceArgs, loaded [template = constants.%InInterfaceArgs]
  319. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//types, loc7_10, loaded [template = constants.%complete_type]
  320. // CHECK:STDOUT: %Main.import_ref.acf = import_ref Main//types, inst54 [no loc], unloaded
  321. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  322. // CHECK:STDOUT: %Main.import_ref.884 = import_ref Main//types, inst26 [no loc], unloaded
  323. // CHECK:STDOUT: %Main.import_ref.cd3: @I.%I.assoc_type (%I.assoc_type.955) = import_ref Main//types, loc4_31, loaded [symbolic = @I.%assoc0 (constants.%assoc0.249)]
  324. // CHECK:STDOUT: %Main.F = import_ref Main//types, F, unloaded
  325. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  326. // CHECK:STDOUT: %Main.import_ref.38e: @I.%I.type (%I.type.325) = import_ref Main//types, inst26 [no loc], loaded [symbolic = @I.%Self (constants.%Self)]
  327. // CHECK:STDOUT: %Main.import_ref.e54: @I.%F.type (%F.type.2ae) = import_ref Main//types, loc4_31, loaded [symbolic = @I.%F (constants.%F.bb2)]
  328. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//impl_in_interface_args, loc5_24, loaded [template = constants.%complete_type]
  329. // CHECK:STDOUT: %Main.import_ref.bf8 = import_ref Main//impl_in_interface_args, inst18 [no loc], unloaded
  330. // CHECK:STDOUT: %Main.import_ref.f9f: <witness> = import_ref Main//impl_in_interface_args, loc7_30, loaded [template = constants.%impl_witness]
  331. // CHECK:STDOUT: %Main.import_ref.956: type = import_ref Main//impl_in_interface_args, loc7_6, loaded [template = constants.%X]
  332. // CHECK:STDOUT: %Main.import_ref.e8c: type = import_ref Main//impl_in_interface_args, loc7_28, loaded [template = constants.%I.type.e45]
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: file {
  336. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  337. // CHECK:STDOUT: .I = imports.%Main.I
  338. // CHECK:STDOUT: .C = imports.%Main.C
  339. // CHECK:STDOUT: .X = imports.%Main.X
  340. // CHECK:STDOUT: .InInterfaceArgs = imports.%Main.InInterfaceArgs
  341. // CHECK:STDOUT: .G = %G.decl
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT: %default.import = import <none>
  344. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  345. // CHECK:STDOUT: %x.patt: %X = binding_pattern x
  346. // CHECK:STDOUT: %x.param_patt: %X = value_param_pattern %x.patt, runtime_param0
  347. // CHECK:STDOUT: } {
  348. // CHECK:STDOUT: %x.param: %X = value_param runtime_param0
  349. // CHECK:STDOUT: %X.ref: type = name_ref X, imports.%Main.X [template = constants.%X]
  350. // CHECK:STDOUT: %x: %X = bind_name x, %x.param
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: generic interface @I(imports.%Main.import_ref.f6b058.1: type) [from "types.carbon"] {
  355. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  356. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: !definition:
  359. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.325)]
  360. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  361. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.2ae)]
  362. // CHECK:STDOUT: %F: @I.%F.type (%F.type.2ae) = struct_value () [symbolic = %F (constants.%F.bb2)]
  363. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I.%I.type (%I.type.325) [symbolic = %I.assoc_type (constants.%I.assoc_type.955)]
  364. // CHECK:STDOUT: %assoc0: @I.%I.assoc_type (%I.assoc_type.955) = assoc_entity element0, imports.%Main.import_ref.e54 [symbolic = %assoc0 (constants.%assoc0.62c)]
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: interface {
  367. // CHECK:STDOUT: !members:
  368. // CHECK:STDOUT: .Self = imports.%Main.import_ref.884
  369. // CHECK:STDOUT: .F = imports.%Main.import_ref.cd3
  370. // CHECK:STDOUT: witness = (imports.%Main.F)
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: impl @impl: imports.%Main.import_ref.956 as imports.%Main.import_ref.e8c [from "impl_in_interface_args.carbon"] {
  375. // CHECK:STDOUT: !members:
  376. // CHECK:STDOUT: witness = imports.%Main.import_ref.f9f
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: class @X [from "types.carbon"] {
  380. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: !members:
  383. // CHECK:STDOUT: .Self = imports.%Main.import_ref.acf
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: class @InInterfaceArgs [from "impl_in_interface_args.carbon"] {
  387. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: !members:
  390. // CHECK:STDOUT: .Self = imports.%Main.import_ref.bf8
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: fn @G(%x.param_patt: %X) {
  394. // CHECK:STDOUT: !entry:
  395. // CHECK:STDOUT: %x.ref: %X = name_ref x, %x
  396. // CHECK:STDOUT: %I.ref: %I.type.dac = name_ref I, imports.%Main.I [template = constants.%I.generic]
  397. // CHECK:STDOUT: %InInterfaceArgs.ref: type = name_ref InInterfaceArgs, imports.%Main.InInterfaceArgs [template = constants.%InInterfaceArgs]
  398. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%InInterfaceArgs)> [template = constants.%I.type.e45]
  399. // CHECK:STDOUT: %.loc6: %I.assoc_type.9f3 = specific_constant imports.%Main.import_ref.cd3, @I(constants.%InInterfaceArgs) [template = constants.%assoc0.0fc]
  400. // CHECK:STDOUT: %F.ref: %I.assoc_type.9f3 = name_ref F, %.loc6 [template = constants.%assoc0.0fc]
  401. // CHECK:STDOUT: %impl.elem0: %.e37 = impl_witness_access constants.%impl_witness, element0 [template = constants.%F.d5f]
  402. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %impl.elem0()
  403. // CHECK:STDOUT: return
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: generic fn @F.1(imports.%Main.import_ref.f6b058.2: type, imports.%Main.import_ref.38e: @I.%I.type (%I.type.325)) [from "types.carbon"] {
  407. // CHECK:STDOUT: fn();
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: fn @F.2() [from "impl_in_interface_args.carbon"];
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: specific @I(constants.%T) {
  413. // CHECK:STDOUT: %T => constants.%T
  414. // CHECK:STDOUT: %T.patt => constants.%T
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: specific @I(%T) {}
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self) {}
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: specific @I(constants.%InInterfaceArgs) {
  422. // CHECK:STDOUT: %T => constants.%InInterfaceArgs
  423. // CHECK:STDOUT: %T.patt => constants.%InInterfaceArgs
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: !definition:
  426. // CHECK:STDOUT: %I.type => constants.%I.type.e45
  427. // CHECK:STDOUT: %Self => constants.%Self
  428. // CHECK:STDOUT: %F.type => constants.%F.type.14f
  429. // CHECK:STDOUT: %F => constants.%F.b81
  430. // CHECK:STDOUT: %I.assoc_type => constants.%I.assoc_type.9f3
  431. // CHECK:STDOUT: %assoc0 => constants.%assoc0.0fc
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: --- impl_in_class_args.carbon
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: constants {
  437. // CHECK:STDOUT: %InClassArgs: type = class_type @InClassArgs [template]
  438. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  439. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  440. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  441. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  442. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  443. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  444. // CHECK:STDOUT: %C.23b: type = class_type @C, @C(%InClassArgs) [template]
  445. // CHECK:STDOUT: %I.type.dac: type = generic_interface_type @I [template]
  446. // CHECK:STDOUT: %I.generic: %I.type.dac = struct_value () [template]
  447. // CHECK:STDOUT: %I.type.325: type = facet_type <@I, @I(%T)> [symbolic]
  448. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic]
  449. // CHECK:STDOUT: %F.type.2ae: type = fn_type @F.1, @I(%T) [symbolic]
  450. // CHECK:STDOUT: %F.bb2: %F.type.2ae = struct_value () [symbolic]
  451. // CHECK:STDOUT: %I.assoc_type.955: type = assoc_entity_type %I.type.325 [symbolic]
  452. // CHECK:STDOUT: %assoc0.249: %I.assoc_type.955 = assoc_entity element0, imports.%Main.import_ref.479 [symbolic]
  453. // CHECK:STDOUT: %X: type = class_type @X [template]
  454. // CHECK:STDOUT: %I.type.45c: type = facet_type <@I, @I(%X)> [template]
  455. // CHECK:STDOUT: %F.type.56a: type = fn_type @F.1, @I(%X) [template]
  456. // CHECK:STDOUT: %F.a79: %F.type.56a = struct_value () [template]
  457. // CHECK:STDOUT: %I.assoc_type.a7e: type = assoc_entity_type %I.type.45c [template]
  458. // CHECK:STDOUT: %assoc0.7c6: %I.assoc_type.a7e = assoc_entity element0, imports.%Main.import_ref.479 [template]
  459. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F.decl) [template]
  460. // CHECK:STDOUT: %F.type.fab: type = fn_type @F.2 [template]
  461. // CHECK:STDOUT: %F.7ab: %F.type.fab = struct_value () [template]
  462. // CHECK:STDOUT: %I.facet: %I.type.45c = facet_value %C.23b, %impl_witness [template]
  463. // CHECK:STDOUT: }
  464. // CHECK:STDOUT:
  465. // CHECK:STDOUT: imports {
  466. // CHECK:STDOUT: %Main.I: %I.type.dac = import_ref Main//types, I, loaded [template = constants.%I.generic]
  467. // CHECK:STDOUT: %Main.C: %C.type = import_ref Main//types, C, loaded [template = constants.%C.generic]
  468. // CHECK:STDOUT: %Main.X: type = import_ref Main//types, X, loaded [template = constants.%X]
  469. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//types, loc5_9, loaded [symbolic = @C.%T (constants.%T)]
  470. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//types, loc5_20, loaded [template = constants.%complete_type]
  471. // CHECK:STDOUT: %Main.import_ref.4c0 = import_ref Main//types, inst49 [no loc], unloaded
  472. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  473. // CHECK:STDOUT: %Main.import_ref.884 = import_ref Main//types, inst26 [no loc], unloaded
  474. // CHECK:STDOUT: %Main.import_ref.cbe = import_ref Main//types, loc4_31, unloaded
  475. // CHECK:STDOUT: %Main.F: @I.%F.type (%F.type.2ae) = import_ref Main//types, F, loaded [symbolic = @I.%F (constants.%F.bb2)]
  476. // CHECK:STDOUT: %Main.import_ref.f6b058.3: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  477. // CHECK:STDOUT: %Main.import_ref.38e: @I.%I.type (%I.type.325) = import_ref Main//types, inst26 [no loc], loaded [symbolic = @I.%Self (constants.%Self)]
  478. // CHECK:STDOUT: %Main.import_ref.479 = import_ref Main//types, loc4_31, unloaded
  479. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//types, loc7_10, loaded [template = constants.%complete_type]
  480. // CHECK:STDOUT: %Main.import_ref.acf = import_ref Main//types, inst54 [no loc], unloaded
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT:
  483. // CHECK:STDOUT: file {
  484. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  485. // CHECK:STDOUT: .I = imports.%Main.I
  486. // CHECK:STDOUT: .C = imports.%Main.C
  487. // CHECK:STDOUT: .X = imports.%Main.X
  488. // CHECK:STDOUT: .InClassArgs = %InClassArgs.decl
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT: %default.import = import <none>
  491. // CHECK:STDOUT: %InClassArgs.decl: type = class_decl @InClassArgs [template = constants.%InClassArgs] {} {}
  492. // CHECK:STDOUT: impl_decl @impl [template] {} {
  493. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [template = constants.%C.generic]
  494. // CHECK:STDOUT: %InClassArgs.ref: type = name_ref InClassArgs, file.%InClassArgs.decl [template = constants.%InClassArgs]
  495. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%InClassArgs) [template = constants.%C.23b]
  496. // CHECK:STDOUT: %I.ref: %I.type.dac = name_ref I, imports.%Main.I [template = constants.%I.generic]
  497. // CHECK:STDOUT: %X.ref: type = name_ref X, imports.%Main.X [template = constants.%X]
  498. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%X)> [template = constants.%I.type.45c]
  499. // CHECK:STDOUT: }
  500. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F.decl) [template = constants.%impl_witness]
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: generic interface @I(imports.%Main.import_ref.f6b058.2: type) [from "types.carbon"] {
  504. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  505. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: !definition:
  508. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.325)]
  509. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  510. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.2ae)]
  511. // CHECK:STDOUT: %F: @I.%F.type (%F.type.2ae) = struct_value () [symbolic = %F (constants.%F.bb2)]
  512. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I.%I.type (%I.type.325) [symbolic = %I.assoc_type (constants.%I.assoc_type.955)]
  513. // CHECK:STDOUT: %assoc0: @I.%I.assoc_type (%I.assoc_type.955) = assoc_entity element0, imports.%Main.import_ref.479 [symbolic = %assoc0 (constants.%assoc0.249)]
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: interface {
  516. // CHECK:STDOUT: !members:
  517. // CHECK:STDOUT: .Self = imports.%Main.import_ref.884
  518. // CHECK:STDOUT: .F = imports.%Main.import_ref.cbe
  519. // CHECK:STDOUT: witness = (imports.%Main.F)
  520. // CHECK:STDOUT: }
  521. // CHECK:STDOUT: }
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: impl @impl: %C as %I.type {
  524. // CHECK:STDOUT: %F.decl: %F.type.fab = fn_decl @F.2 [template = constants.%F.7ab] {} {}
  525. // CHECK:STDOUT:
  526. // CHECK:STDOUT: !members:
  527. // CHECK:STDOUT: .F = %F.decl
  528. // CHECK:STDOUT: witness = file.%impl_witness
  529. // CHECK:STDOUT: }
  530. // CHECK:STDOUT:
  531. // CHECK:STDOUT: class @InClassArgs {
  532. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  533. // CHECK:STDOUT: complete_type_witness = %complete_type
  534. // CHECK:STDOUT:
  535. // CHECK:STDOUT: !members:
  536. // CHECK:STDOUT: .Self = constants.%InClassArgs
  537. // CHECK:STDOUT: }
  538. // CHECK:STDOUT:
  539. // CHECK:STDOUT: generic class @C(imports.%Main.import_ref.f6b058.1: type) [from "types.carbon"] {
  540. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  541. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: !definition:
  544. // CHECK:STDOUT:
  545. // CHECK:STDOUT: class {
  546. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  547. // CHECK:STDOUT:
  548. // CHECK:STDOUT: !members:
  549. // CHECK:STDOUT: .Self = imports.%Main.import_ref.4c0
  550. // CHECK:STDOUT: }
  551. // CHECK:STDOUT: }
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: class @X [from "types.carbon"] {
  554. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  555. // CHECK:STDOUT:
  556. // CHECK:STDOUT: !members:
  557. // CHECK:STDOUT: .Self = imports.%Main.import_ref.acf
  558. // CHECK:STDOUT: }
  559. // CHECK:STDOUT:
  560. // CHECK:STDOUT: generic fn @F.1(imports.%Main.import_ref.f6b058.3: type, imports.%Main.import_ref.38e: @I.%I.type (%I.type.325)) [from "types.carbon"] {
  561. // CHECK:STDOUT: fn();
  562. // CHECK:STDOUT: }
  563. // CHECK:STDOUT:
  564. // CHECK:STDOUT: fn @F.2() {
  565. // CHECK:STDOUT: !entry:
  566. // CHECK:STDOUT: return
  567. // CHECK:STDOUT: }
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: specific @C(constants.%T) {
  570. // CHECK:STDOUT: %T => constants.%T
  571. // CHECK:STDOUT: %T.patt => constants.%T
  572. // CHECK:STDOUT: }
  573. // CHECK:STDOUT:
  574. // CHECK:STDOUT: specific @C(constants.%InClassArgs) {
  575. // CHECK:STDOUT: %T => constants.%InClassArgs
  576. // CHECK:STDOUT: %T.patt => constants.%InClassArgs
  577. // CHECK:STDOUT: }
  578. // CHECK:STDOUT:
  579. // CHECK:STDOUT: specific @I(constants.%T) {
  580. // CHECK:STDOUT: %T => constants.%T
  581. // CHECK:STDOUT: %T.patt => constants.%T
  582. // CHECK:STDOUT: }
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: specific @I(%T) {}
  585. // CHECK:STDOUT:
  586. // CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self) {}
  587. // CHECK:STDOUT:
  588. // CHECK:STDOUT: specific @I(constants.%X) {
  589. // CHECK:STDOUT: %T => constants.%X
  590. // CHECK:STDOUT: %T.patt => constants.%X
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: !definition:
  593. // CHECK:STDOUT: %I.type => constants.%I.type.45c
  594. // CHECK:STDOUT: %Self => constants.%Self
  595. // CHECK:STDOUT: %F.type => constants.%F.type.56a
  596. // CHECK:STDOUT: %F => constants.%F.a79
  597. // CHECK:STDOUT: %I.assoc_type => constants.%I.assoc_type.a7e
  598. // CHECK:STDOUT: %assoc0 => constants.%assoc0.7c6
  599. // CHECK:STDOUT: }
  600. // CHECK:STDOUT:
  601. // CHECK:STDOUT: specific @F.1(constants.%X, constants.%I.facet) {}
  602. // CHECK:STDOUT:
  603. // CHECK:STDOUT: --- use_impl_in_class_args.carbon
  604. // CHECK:STDOUT:
  605. // CHECK:STDOUT: constants {
  606. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  607. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  608. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  609. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  610. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  611. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  612. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  613. // CHECK:STDOUT: %InClassArgs: type = class_type @InClassArgs [template]
  614. // CHECK:STDOUT: %C.23b: type = class_type @C, @C(%InClassArgs) [template]
  615. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  616. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  617. // CHECK:STDOUT: %I.type.dac: type = generic_interface_type @I [template]
  618. // CHECK:STDOUT: %I.generic: %I.type.dac = struct_value () [template]
  619. // CHECK:STDOUT: %I.type.325: type = facet_type <@I, @I(%T)> [symbolic]
  620. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic]
  621. // CHECK:STDOUT: %F.type.2ae: type = fn_type @F.1, @I(%T) [symbolic]
  622. // CHECK:STDOUT: %F.bb2: %F.type.2ae = struct_value () [symbolic]
  623. // CHECK:STDOUT: %I.assoc_type.955: type = assoc_entity_type %I.type.325 [symbolic]
  624. // CHECK:STDOUT: %assoc0.62c: %I.assoc_type.955 = assoc_entity element0, imports.%Main.import_ref.e54 [symbolic]
  625. // CHECK:STDOUT: %X: type = class_type @X [template]
  626. // CHECK:STDOUT: %I.type.45c: type = facet_type <@I, @I(%X)> [template]
  627. // CHECK:STDOUT: %F.type.56a: type = fn_type @F.1, @I(%X) [template]
  628. // CHECK:STDOUT: %F.a79: %F.type.56a = struct_value () [template]
  629. // CHECK:STDOUT: %I.assoc_type.a7e: type = assoc_entity_type %I.type.45c [template]
  630. // CHECK:STDOUT: %assoc0.ba0: %I.assoc_type.a7e = assoc_entity element0, imports.%Main.import_ref.e54 [template]
  631. // CHECK:STDOUT: %assoc0.249: %I.assoc_type.955 = assoc_entity element0, imports.%Main.import_ref.479 [symbolic]
  632. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (imports.%Main.import_ref.ae4) [template]
  633. // CHECK:STDOUT: %I.facet: %I.type.45c = facet_value %C.23b, %impl_witness [template]
  634. // CHECK:STDOUT: %.c87: type = fn_type_with_self_type %F.type.56a, %I.facet [template]
  635. // CHECK:STDOUT: %F.type.fab: type = fn_type @F.2 [template]
  636. // CHECK:STDOUT: %F.7ab: %F.type.fab = struct_value () [template]
  637. // CHECK:STDOUT: }
  638. // CHECK:STDOUT:
  639. // CHECK:STDOUT: imports {
  640. // CHECK:STDOUT: %Main.I: %I.type.dac = import_ref Main//types, I, loaded [template = constants.%I.generic]
  641. // CHECK:STDOUT: %Main.C: %C.type = import_ref Main//types, C, loaded [template = constants.%C.generic]
  642. // CHECK:STDOUT: %Main.X: type = import_ref Main//types, X, loaded [template = constants.%X]
  643. // CHECK:STDOUT: %Main.InClassArgs: type = import_ref Main//impl_in_class_args, InClassArgs, loaded [template = constants.%InClassArgs]
  644. // CHECK:STDOUT: %Main.import_ref.f6b058.1: type = import_ref Main//types, loc5_9, loaded [symbolic = @C.%T (constants.%T)]
  645. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//types, loc5_20, loaded [template = constants.%complete_type]
  646. // CHECK:STDOUT: %Main.import_ref.4c0 = import_ref Main//types, inst49 [no loc], unloaded
  647. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//impl_in_class_args, loc5_20, loaded [template = constants.%complete_type]
  648. // CHECK:STDOUT: %Main.import_ref.683 = import_ref Main//impl_in_class_args, inst18 [no loc], unloaded
  649. // CHECK:STDOUT: %Main.import_ref.f6b058.2: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  650. // CHECK:STDOUT: %Main.import_ref.884 = import_ref Main//types, inst26 [no loc], unloaded
  651. // CHECK:STDOUT: %Main.import_ref.cd3: @I.%I.assoc_type (%I.assoc_type.955) = import_ref Main//types, loc4_31, loaded [symbolic = @I.%assoc0 (constants.%assoc0.249)]
  652. // CHECK:STDOUT: %Main.F = import_ref Main//types, F, unloaded
  653. // CHECK:STDOUT: %Main.import_ref.f6b058.3: type = import_ref Main//types, loc4_13, loaded [symbolic = @I.%T (constants.%T)]
  654. // CHECK:STDOUT: %Main.import_ref.38e: @I.%I.type (%I.type.325) = import_ref Main//types, inst26 [no loc], loaded [symbolic = @I.%Self (constants.%Self)]
  655. // CHECK:STDOUT: %Main.import_ref.e54: @I.%F.type (%F.type.2ae) = import_ref Main//types, loc4_31, loaded [symbolic = @I.%F (constants.%F.bb2)]
  656. // CHECK:STDOUT: %Main.import_ref.8f24d3.3: <witness> = import_ref Main//types, loc7_10, loaded [template = constants.%complete_type]
  657. // CHECK:STDOUT: %Main.import_ref.acf = import_ref Main//types, inst54 [no loc], unloaded
  658. // CHECK:STDOUT: %Main.import_ref.6de: <witness> = import_ref Main//impl_in_class_args, loc7_29, loaded [template = constants.%impl_witness]
  659. // CHECK:STDOUT: %Main.import_ref.d6e: type = import_ref Main//impl_in_class_args, loc7_19, loaded [template = constants.%C.23b]
  660. // CHECK:STDOUT: %Main.import_ref.208: type = import_ref Main//impl_in_class_args, loc7_27, loaded [template = constants.%I.type.45c]
  661. // CHECK:STDOUT: }
  662. // CHECK:STDOUT:
  663. // CHECK:STDOUT: file {
  664. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  665. // CHECK:STDOUT: .I = imports.%Main.I
  666. // CHECK:STDOUT: .C = imports.%Main.C
  667. // CHECK:STDOUT: .X = imports.%Main.X
  668. // CHECK:STDOUT: .InClassArgs = imports.%Main.InClassArgs
  669. // CHECK:STDOUT: .H = %H.decl
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT: %default.import = import <none>
  672. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {
  673. // CHECK:STDOUT: %c.patt: %C.23b = binding_pattern c
  674. // CHECK:STDOUT: %c.param_patt: %C.23b = value_param_pattern %c.patt, runtime_param0
  675. // CHECK:STDOUT: } {
  676. // CHECK:STDOUT: %c.param: %C.23b = value_param runtime_param0
  677. // CHECK:STDOUT: %.loc6_22: type = splice_block %C [template = constants.%C.23b] {
  678. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [template = constants.%C.generic]
  679. // CHECK:STDOUT: %InClassArgs.ref: type = name_ref InClassArgs, imports.%Main.InClassArgs [template = constants.%InClassArgs]
  680. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%InClassArgs) [template = constants.%C.23b]
  681. // CHECK:STDOUT: }
  682. // CHECK:STDOUT: %c: %C.23b = bind_name c, %c.param
  683. // CHECK:STDOUT: }
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT:
  686. // CHECK:STDOUT: generic interface @I(imports.%Main.import_ref.f6b058.2: type) [from "types.carbon"] {
  687. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  688. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  689. // CHECK:STDOUT:
  690. // CHECK:STDOUT: !definition:
  691. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.325)]
  692. // CHECK:STDOUT: %Self: %I.type.325 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  693. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.2ae)]
  694. // CHECK:STDOUT: %F: @I.%F.type (%F.type.2ae) = struct_value () [symbolic = %F (constants.%F.bb2)]
  695. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I.%I.type (%I.type.325) [symbolic = %I.assoc_type (constants.%I.assoc_type.955)]
  696. // CHECK:STDOUT: %assoc0: @I.%I.assoc_type (%I.assoc_type.955) = assoc_entity element0, imports.%Main.import_ref.e54 [symbolic = %assoc0 (constants.%assoc0.62c)]
  697. // CHECK:STDOUT:
  698. // CHECK:STDOUT: interface {
  699. // CHECK:STDOUT: !members:
  700. // CHECK:STDOUT: .Self = imports.%Main.import_ref.884
  701. // CHECK:STDOUT: .F = imports.%Main.import_ref.cd3
  702. // CHECK:STDOUT: witness = (imports.%Main.F)
  703. // CHECK:STDOUT: }
  704. // CHECK:STDOUT: }
  705. // CHECK:STDOUT:
  706. // CHECK:STDOUT: impl @impl: imports.%Main.import_ref.d6e as imports.%Main.import_ref.208 [from "impl_in_class_args.carbon"] {
  707. // CHECK:STDOUT: !members:
  708. // CHECK:STDOUT: witness = imports.%Main.import_ref.6de
  709. // CHECK:STDOUT: }
  710. // CHECK:STDOUT:
  711. // CHECK:STDOUT: generic class @C(imports.%Main.import_ref.f6b058.1: type) [from "types.carbon"] {
  712. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  713. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  714. // CHECK:STDOUT:
  715. // CHECK:STDOUT: !definition:
  716. // CHECK:STDOUT:
  717. // CHECK:STDOUT: class {
  718. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  719. // CHECK:STDOUT:
  720. // CHECK:STDOUT: !members:
  721. // CHECK:STDOUT: .Self = imports.%Main.import_ref.4c0
  722. // CHECK:STDOUT: }
  723. // CHECK:STDOUT: }
  724. // CHECK:STDOUT:
  725. // CHECK:STDOUT: class @InClassArgs [from "impl_in_class_args.carbon"] {
  726. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  727. // CHECK:STDOUT:
  728. // CHECK:STDOUT: !members:
  729. // CHECK:STDOUT: .Self = imports.%Main.import_ref.683
  730. // CHECK:STDOUT: }
  731. // CHECK:STDOUT:
  732. // CHECK:STDOUT: class @X [from "types.carbon"] {
  733. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.3
  734. // CHECK:STDOUT:
  735. // CHECK:STDOUT: !members:
  736. // CHECK:STDOUT: .Self = imports.%Main.import_ref.acf
  737. // CHECK:STDOUT: }
  738. // CHECK:STDOUT:
  739. // CHECK:STDOUT: fn @H(%c.param_patt: %C.23b) {
  740. // CHECK:STDOUT: !entry:
  741. // CHECK:STDOUT: %c.ref: %C.23b = name_ref c, %c
  742. // CHECK:STDOUT: %I.ref: %I.type.dac = name_ref I, imports.%Main.I [template = constants.%I.generic]
  743. // CHECK:STDOUT: %X.ref: type = name_ref X, imports.%Main.X [template = constants.%X]
  744. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%X)> [template = constants.%I.type.45c]
  745. // CHECK:STDOUT: %.loc6_34: %I.assoc_type.a7e = specific_constant imports.%Main.import_ref.cd3, @I(constants.%X) [template = constants.%assoc0.ba0]
  746. // CHECK:STDOUT: %F.ref: %I.assoc_type.a7e = name_ref F, %.loc6_34 [template = constants.%assoc0.ba0]
  747. // CHECK:STDOUT: %impl.elem0: %.c87 = impl_witness_access constants.%impl_witness, element0 [template = constants.%F.7ab]
  748. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %impl.elem0()
  749. // CHECK:STDOUT: return
  750. // CHECK:STDOUT: }
  751. // CHECK:STDOUT:
  752. // CHECK:STDOUT: generic fn @F.1(imports.%Main.import_ref.f6b058.3: type, imports.%Main.import_ref.38e: @I.%I.type (%I.type.325)) [from "types.carbon"] {
  753. // CHECK:STDOUT: fn();
  754. // CHECK:STDOUT: }
  755. // CHECK:STDOUT:
  756. // CHECK:STDOUT: fn @F.2() [from "impl_in_class_args.carbon"];
  757. // CHECK:STDOUT:
  758. // CHECK:STDOUT: specific @C(constants.%T) {
  759. // CHECK:STDOUT: %T => constants.%T
  760. // CHECK:STDOUT: %T.patt => constants.%T
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT:
  763. // CHECK:STDOUT: specific @C(constants.%InClassArgs) {
  764. // CHECK:STDOUT: %T => constants.%InClassArgs
  765. // CHECK:STDOUT: %T.patt => constants.%InClassArgs
  766. // CHECK:STDOUT:
  767. // CHECK:STDOUT: !definition:
  768. // CHECK:STDOUT: }
  769. // CHECK:STDOUT:
  770. // CHECK:STDOUT: specific @I(constants.%T) {
  771. // CHECK:STDOUT: %T => constants.%T
  772. // CHECK:STDOUT: %T.patt => constants.%T
  773. // CHECK:STDOUT: }
  774. // CHECK:STDOUT:
  775. // CHECK:STDOUT: specific @I(%T) {}
  776. // CHECK:STDOUT:
  777. // CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self) {}
  778. // CHECK:STDOUT:
  779. // CHECK:STDOUT: specific @I(constants.%X) {
  780. // CHECK:STDOUT: %T => constants.%X
  781. // CHECK:STDOUT: %T.patt => constants.%X
  782. // CHECK:STDOUT:
  783. // CHECK:STDOUT: !definition:
  784. // CHECK:STDOUT: %I.type => constants.%I.type.45c
  785. // CHECK:STDOUT: %Self => constants.%Self
  786. // CHECK:STDOUT: %F.type => constants.%F.type.56a
  787. // CHECK:STDOUT: %F => constants.%F.a79
  788. // CHECK:STDOUT: %I.assoc_type => constants.%I.assoc_type.a7e
  789. // CHECK:STDOUT: %assoc0 => constants.%assoc0.ba0
  790. // CHECK:STDOUT: }
  791. // CHECK:STDOUT: