indirect_import_member.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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/class/no_prelude/indirect_import_member.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon
  10. // ============================================================================
  11. // Setup files
  12. // ============================================================================
  13. // --- a.carbon
  14. library "[[@TEST_NAME]]";
  15. class C {
  16. fn F() {}
  17. }
  18. // --- b.carbon
  19. library "[[@TEST_NAME]]";
  20. export import library "a";
  21. // --- c.carbon
  22. library "[[@TEST_NAME]]";
  23. import library "b";
  24. export C;
  25. // --- d.carbon
  26. library "[[@TEST_NAME]]";
  27. export import library "c";
  28. // --- e.carbon
  29. library "[[@TEST_NAME]]";
  30. import library "c";
  31. class D {
  32. alias C = package.C;
  33. }
  34. // --- f.carbon
  35. library "[[@TEST_NAME]]";
  36. export import library "e";
  37. // ============================================================================
  38. // Test files
  39. // ============================================================================
  40. // --- use_b.carbon
  41. library "[[@TEST_NAME]]";
  42. import library "b";
  43. var x: () = C.F();
  44. // --- use_c.carbon
  45. library "[[@TEST_NAME]]";
  46. import library "c";
  47. var x: () = C.F();
  48. // --- use_d.carbon
  49. library "[[@TEST_NAME]]";
  50. import library "d";
  51. var x: () = C.F();
  52. // --- use_e.carbon
  53. library "[[@TEST_NAME]]";
  54. import library "e";
  55. var x: () = D.C.F();
  56. // --- use_f.carbon
  57. library "[[@TEST_NAME]]";
  58. import library "f";
  59. var x: () = D.C.F();
  60. // CHECK:STDOUT: --- a.carbon
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: constants {
  63. // CHECK:STDOUT: %C: type = class_type @C [template]
  64. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  65. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  66. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  67. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: file {
  71. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  72. // CHECK:STDOUT: .C = %C.decl
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: class @C {
  78. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  79. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  80. // CHECK:STDOUT: complete_type_witness = %complete_type
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: !members:
  83. // CHECK:STDOUT: .Self = constants.%C
  84. // CHECK:STDOUT: .F = %F.decl
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: fn @F() {
  88. // CHECK:STDOUT: !entry:
  89. // CHECK:STDOUT: return
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: --- b.carbon
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: imports {
  95. // CHECK:STDOUT: %Main.C = import_ref Main//a, C, unloaded
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: file {
  99. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  100. // CHECK:STDOUT: .C = imports.%Main.C
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: %default.import = import <none>
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: --- c.carbon
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: constants {
  108. // CHECK:STDOUT: %C: type = class_type @C [template]
  109. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  110. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: imports {
  114. // CHECK:STDOUT: %Main.C: type = import_ref Main//a, C, loaded [template = constants.%C]
  115. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//a, loc6_1, loaded [template = constants.%complete_type]
  116. // CHECK:STDOUT: %Main.import_ref.2c4 = import_ref Main//a, inst14 [no loc], unloaded
  117. // CHECK:STDOUT: %Main.import_ref.2cf = import_ref Main//a, loc5_10, unloaded
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: file {
  121. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  122. // CHECK:STDOUT: .C = %C
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %default.import = import <none>
  125. // CHECK:STDOUT: %C: type = export C, imports.%Main.C [template = constants.%C]
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: class @C [from "a.carbon"] {
  129. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: !members:
  132. // CHECK:STDOUT: .Self = imports.%Main.import_ref.2c4
  133. // CHECK:STDOUT: .F = imports.%Main.import_ref.2cf
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: --- d.carbon
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: imports {
  139. // CHECK:STDOUT: %Main.C = import_ref Main//c, C, unloaded
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: file {
  143. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  144. // CHECK:STDOUT: .C = imports.%Main.C
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: %default.import = import <none>
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: --- e.carbon
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: constants {
  152. // CHECK:STDOUT: %D: type = class_type @D [template]
  153. // CHECK:STDOUT: %C: type = class_type @C [template]
  154. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  155. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: imports {
  159. // CHECK:STDOUT: %Main.C: type = import_ref Main//c, C, loaded [template = constants.%C]
  160. // CHECK:STDOUT: %Main.import_ref.8db: <witness> = import_ref Main//c, inst19 [indirect], loaded [template = constants.%complete_type]
  161. // CHECK:STDOUT: %Main.import_ref.6a9 = import_ref Main//c, inst20 [indirect], unloaded
  162. // CHECK:STDOUT: %Main.import_ref.230 = import_ref Main//c, inst21 [indirect], unloaded
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: file {
  166. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  167. // CHECK:STDOUT: .C = imports.%Main.C
  168. // CHECK:STDOUT: .D = %D.decl
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT: %default.import = import <none>
  171. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: class @D {
  175. // CHECK:STDOUT: %package.ref: <namespace> = name_ref package, package [template = package]
  176. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [template = constants.%C]
  177. // CHECK:STDOUT: %C: type = bind_alias C, imports.%Main.C [template = constants.%C]
  178. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  179. // CHECK:STDOUT: complete_type_witness = %complete_type
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: !members:
  182. // CHECK:STDOUT: .Self = constants.%D
  183. // CHECK:STDOUT: .C = %C
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: class @C [from "c.carbon"] {
  187. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8db
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: !members:
  190. // CHECK:STDOUT: .Self = imports.%Main.import_ref.6a9
  191. // CHECK:STDOUT: .F = imports.%Main.import_ref.230
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: --- f.carbon
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: imports {
  197. // CHECK:STDOUT: %Main.D = import_ref Main//e, D, unloaded
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: file {
  201. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  202. // CHECK:STDOUT: .D = imports.%Main.D
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT: %default.import = import <none>
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: --- use_b.carbon
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: constants {
  210. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  211. // CHECK:STDOUT: %C: type = class_type @C [template]
  212. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  213. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  214. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  215. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: imports {
  219. // CHECK:STDOUT: %Main.C: type = import_ref Main//a, C, loaded [template = constants.%C]
  220. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//a, loc6_1, loaded [template = constants.%complete_type]
  221. // CHECK:STDOUT: %Main.import_ref.2c4 = import_ref Main//a, inst14 [no loc], unloaded
  222. // CHECK:STDOUT: %Main.import_ref.943: %F.type = import_ref Main//a, loc5_10, loaded [template = constants.%F]
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: file {
  226. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  227. // CHECK:STDOUT: .C = imports.%Main.C
  228. // CHECK:STDOUT: .x = %x
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %default.import = import <none>
  231. // CHECK:STDOUT: name_binding_decl {
  232. // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
  233. // CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  236. // CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] {
  237. // CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal ()
  238. // CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: class @C [from "a.carbon"] {
  244. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: !members:
  247. // CHECK:STDOUT: .Self = imports.%Main.import_ref.2c4
  248. // CHECK:STDOUT: .F = imports.%Main.import_ref.943
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: fn @F() [from "a.carbon"];
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: fn @__global_init() {
  254. // CHECK:STDOUT: !entry:
  255. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [template = constants.%C]
  256. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.import_ref.943 [template = constants.%F]
  257. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  258. // CHECK:STDOUT: assign file.%x.var, %F.call
  259. // CHECK:STDOUT: return
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: --- use_c.carbon
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: constants {
  265. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  266. // CHECK:STDOUT: %C: type = class_type @C [template]
  267. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  268. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  269. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  270. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: imports {
  274. // CHECK:STDOUT: %Main.C: type = import_ref Main//c, C, loaded [template = constants.%C]
  275. // CHECK:STDOUT: %Main.import_ref.8db: <witness> = import_ref Main//c, inst19 [indirect], loaded [template = constants.%complete_type]
  276. // CHECK:STDOUT: %Main.import_ref.6a9 = import_ref Main//c, inst20 [indirect], unloaded
  277. // CHECK:STDOUT: %Main.import_ref.5d3: %F.type = import_ref Main//c, inst21 [indirect], loaded [template = constants.%F]
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: file {
  281. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  282. // CHECK:STDOUT: .C = imports.%Main.C
  283. // CHECK:STDOUT: .x = %x
  284. // CHECK:STDOUT: }
  285. // CHECK:STDOUT: %default.import = import <none>
  286. // CHECK:STDOUT: name_binding_decl {
  287. // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
  288. // CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  291. // CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] {
  292. // CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal ()
  293. // CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: class @C [from "c.carbon"] {
  299. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8db
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: !members:
  302. // CHECK:STDOUT: .Self = imports.%Main.import_ref.6a9
  303. // CHECK:STDOUT: .F = imports.%Main.import_ref.5d3
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: fn @F() [from "a.carbon"];
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: fn @__global_init() {
  309. // CHECK:STDOUT: !entry:
  310. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [template = constants.%C]
  311. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.import_ref.5d3 [template = constants.%F]
  312. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  313. // CHECK:STDOUT: assign file.%x.var, %F.call
  314. // CHECK:STDOUT: return
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: --- use_d.carbon
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: constants {
  320. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  321. // CHECK:STDOUT: %C: type = class_type @C [template]
  322. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  323. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  324. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  325. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: imports {
  329. // CHECK:STDOUT: %Main.C: type = import_ref Main//c, C, loaded [template = constants.%C]
  330. // CHECK:STDOUT: %Main.import_ref.8db: <witness> = import_ref Main//c, inst19 [indirect], loaded [template = constants.%complete_type]
  331. // CHECK:STDOUT: %Main.import_ref.6a9 = import_ref Main//c, inst20 [indirect], unloaded
  332. // CHECK:STDOUT: %Main.import_ref.5d3: %F.type = import_ref Main//c, inst21 [indirect], loaded [template = constants.%F]
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: file {
  336. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  337. // CHECK:STDOUT: .C = imports.%Main.C
  338. // CHECK:STDOUT: .x = %x
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT: %default.import = import <none>
  341. // CHECK:STDOUT: name_binding_decl {
  342. // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
  343. // CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  346. // CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] {
  347. // CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal ()
  348. // CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: class @C [from "c.carbon"] {
  354. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8db
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: !members:
  357. // CHECK:STDOUT: .Self = imports.%Main.import_ref.6a9
  358. // CHECK:STDOUT: .F = imports.%Main.import_ref.5d3
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: fn @F() [from "a.carbon"];
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: fn @__global_init() {
  364. // CHECK:STDOUT: !entry:
  365. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [template = constants.%C]
  366. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.import_ref.5d3 [template = constants.%F]
  367. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  368. // CHECK:STDOUT: assign file.%x.var, %F.call
  369. // CHECK:STDOUT: return
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: --- use_e.carbon
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: constants {
  375. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  376. // CHECK:STDOUT: %D: type = class_type @D [template]
  377. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  378. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  379. // CHECK:STDOUT: %C: type = class_type @C [template]
  380. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  381. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: imports {
  385. // CHECK:STDOUT: %Main.D: type = import_ref Main//e, D, loaded [template = constants.%D]
  386. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//e, loc8_1, loaded [template = constants.%complete_type]
  387. // CHECK:STDOUT: %Main.import_ref.cab = import_ref Main//e, inst16 [no loc], unloaded
  388. // CHECK:STDOUT: %Main.import_ref.bf1: type = import_ref Main//e, loc7_9, loaded [template = constants.%C]
  389. // CHECK:STDOUT: %Main.import_ref.8f3: <witness> = import_ref Main//e, inst22 [indirect], loaded [template = constants.%complete_type]
  390. // CHECK:STDOUT: %Main.import_ref.db8 = import_ref Main//e, inst23 [indirect], unloaded
  391. // CHECK:STDOUT: %Main.import_ref.c85: %F.type = import_ref Main//e, inst24 [indirect], loaded [template = constants.%F]
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: file {
  395. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  396. // CHECK:STDOUT: .D = imports.%Main.D
  397. // CHECK:STDOUT: .x = %x
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT: %default.import = import <none>
  400. // CHECK:STDOUT: name_binding_decl {
  401. // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
  402. // CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  405. // CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] {
  406. // CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal ()
  407. // CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  410. // CHECK:STDOUT: }
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: class @D [from "e.carbon"] {
  413. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: !members:
  416. // CHECK:STDOUT: .Self = imports.%Main.import_ref.cab
  417. // CHECK:STDOUT: .C = imports.%Main.import_ref.bf1
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: class @C [from "e.carbon"] {
  421. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f3
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: !members:
  424. // CHECK:STDOUT: .Self = imports.%Main.import_ref.db8
  425. // CHECK:STDOUT: .F = imports.%Main.import_ref.c85
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT:
  428. // CHECK:STDOUT: fn @F() [from "a.carbon"];
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: fn @__global_init() {
  431. // CHECK:STDOUT: !entry:
  432. // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%Main.D [template = constants.%D]
  433. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.import_ref.bf1 [template = constants.%C]
  434. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.import_ref.c85 [template = constants.%F]
  435. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  436. // CHECK:STDOUT: assign file.%x.var, %F.call
  437. // CHECK:STDOUT: return
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: --- use_f.carbon
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: constants {
  443. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  444. // CHECK:STDOUT: %D: type = class_type @D [template]
  445. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  446. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  447. // CHECK:STDOUT: %C: type = class_type @C [template]
  448. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  449. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  450. // CHECK:STDOUT: }
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: imports {
  453. // CHECK:STDOUT: %Main.D: type = import_ref Main//e, D, loaded [template = constants.%D]
  454. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//e, loc8_1, loaded [template = constants.%complete_type]
  455. // CHECK:STDOUT: %Main.import_ref.cab = import_ref Main//e, inst16 [no loc], unloaded
  456. // CHECK:STDOUT: %Main.import_ref.bf1: type = import_ref Main//e, loc7_9, loaded [template = constants.%C]
  457. // CHECK:STDOUT: %Main.import_ref.8f3: <witness> = import_ref Main//e, inst22 [indirect], loaded [template = constants.%complete_type]
  458. // CHECK:STDOUT: %Main.import_ref.db8 = import_ref Main//e, inst23 [indirect], unloaded
  459. // CHECK:STDOUT: %Main.import_ref.c85: %F.type = import_ref Main//e, inst24 [indirect], loaded [template = constants.%F]
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: file {
  463. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  464. // CHECK:STDOUT: .D = imports.%Main.D
  465. // CHECK:STDOUT: .x = %x
  466. // CHECK:STDOUT: }
  467. // CHECK:STDOUT: %default.import = import <none>
  468. // CHECK:STDOUT: name_binding_decl {
  469. // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
  470. // CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt
  471. // CHECK:STDOUT: }
  472. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  473. // CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] {
  474. // CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal ()
  475. // CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  478. // CHECK:STDOUT: }
  479. // CHECK:STDOUT:
  480. // CHECK:STDOUT: class @D [from "e.carbon"] {
  481. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  482. // CHECK:STDOUT:
  483. // CHECK:STDOUT: !members:
  484. // CHECK:STDOUT: .Self = imports.%Main.import_ref.cab
  485. // CHECK:STDOUT: .C = imports.%Main.import_ref.bf1
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT:
  488. // CHECK:STDOUT: class @C [from "e.carbon"] {
  489. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f3
  490. // CHECK:STDOUT:
  491. // CHECK:STDOUT: !members:
  492. // CHECK:STDOUT: .Self = imports.%Main.import_ref.db8
  493. // CHECK:STDOUT: .F = imports.%Main.import_ref.c85
  494. // CHECK:STDOUT: }
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: fn @F() [from "a.carbon"];
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: fn @__global_init() {
  499. // CHECK:STDOUT: !entry:
  500. // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%Main.D [template = constants.%D]
  501. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.import_ref.bf1 [template = constants.%C]
  502. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.import_ref.c85 [template = constants.%F]
  503. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  504. // CHECK:STDOUT: assign file.%x.var, %F.call
  505. // CHECK:STDOUT: return
  506. // CHECK:STDOUT: }
  507. // CHECK:STDOUT: