implicit_imports_entities.carbon 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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/packages/no_prelude/implicit_imports_entities.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon
  10. // ============================================================================
  11. // Setup files
  12. // ============================================================================
  13. // --- c1.carbon
  14. library "[[@TEST_NAME]]";
  15. class C1 {}
  16. // --- c2.carbon
  17. library "[[@TEST_NAME]]";
  18. class C2 {}
  19. // --- ns.carbon
  20. library "[[@TEST_NAME]]";
  21. namespace NS;
  22. class NS.C {}
  23. // --- o1.carbon
  24. package Other library "[[@TEST_NAME]]";
  25. class O1 {}
  26. // --- o2.carbon
  27. package Other library "[[@TEST_NAME]]";
  28. class O2 {}
  29. // --- local_other.carbon
  30. library "[[@TEST_NAME]]";
  31. class Other {}
  32. // ============================================================================
  33. // Test files
  34. // ============================================================================
  35. // --- mix_current_package.carbon
  36. library "[[@TEST_NAME]]";
  37. import library "c1";
  38. // --- mix_current_package.impl.carbon
  39. impl library "[[@TEST_NAME]]";
  40. import library "c2";
  41. var c1: C1 = {};
  42. var c2: C2 = {};
  43. // --- dup_c1.carbon
  44. library "[[@TEST_NAME]]";
  45. import library "c1";
  46. // --- dup_c1.impl.carbon
  47. impl library "[[@TEST_NAME]]";
  48. import library "c1";
  49. var c1: C1 = {};
  50. // --- use_ns.carbon
  51. library "[[@TEST_NAME]]";
  52. import library "ns";
  53. // --- use_ns.impl.carbon
  54. impl library "[[@TEST_NAME]]";
  55. var c: NS.C = {};
  56. // --- mix_other.carbon
  57. library "[[@TEST_NAME]]";
  58. import Other library "o1";
  59. // --- mix_other.impl.carbon
  60. impl library "[[@TEST_NAME]]";
  61. import Other library "o2";
  62. var o1: Other.O1 = {};
  63. var o2: Other.O2 = {};
  64. // --- dup_o1.carbon
  65. library "[[@TEST_NAME]]";
  66. import Other library "o1";
  67. // --- dup_o1.impl.carbon
  68. impl library "[[@TEST_NAME]]";
  69. import Other library "o1";
  70. var o1: Other.O1 = {};
  71. // --- import_conflict.carbon
  72. library "[[@TEST_NAME]]";
  73. import Other library "o1";
  74. // --- fail_import_conflict.impl.carbon
  75. // CHECK:STDERR: fail_import_conflict.impl.carbon:[[@LINE+9]]:6: in import [InImport]
  76. // CHECK:STDERR: import_conflict.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  77. // CHECK:STDERR: import Other library "o1";
  78. // CHECK:STDERR: ^~~~~~
  79. // CHECK:STDERR: fail_import_conflict.impl.carbon:[[@LINE+5]]:6: in import [InImport]
  80. // CHECK:STDERR: local_other.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  81. // CHECK:STDERR: class Other {}
  82. // CHECK:STDERR: ^~~~~~~~~~~~~
  83. // CHECK:STDERR:
  84. impl library "[[@TEST_NAME]]";
  85. import library "local_other";
  86. // --- import_conflict_reverse.carbon
  87. library "[[@TEST_NAME]]";
  88. import library "local_other";
  89. // --- fail_import_conflict_reverse.impl.carbon
  90. impl library "[[@TEST_NAME]]";
  91. // CHECK:STDERR: fail_import_conflict_reverse.impl.carbon:[[@LINE+8]]:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  92. // CHECK:STDERR: import Other library "o1";
  93. // CHECK:STDERR: ^~~~~~
  94. // CHECK:STDERR: fail_import_conflict_reverse.impl.carbon:[[@LINE-5]]:6: in import [InImport]
  95. // CHECK:STDERR: import_conflict_reverse.carbon:4:1: in import [InImport]
  96. // CHECK:STDERR: local_other.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  97. // CHECK:STDERR: class Other {}
  98. // CHECK:STDERR: ^~~~~~~~~~~~~
  99. import Other library "o1";
  100. // CHECK:STDOUT: --- c1.carbon
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: constants {
  103. // CHECK:STDOUT: %C1: type = class_type @C1 [template]
  104. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  105. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: file {
  109. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  110. // CHECK:STDOUT: .C1 = %C1.decl
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %C1.decl: type = class_decl @C1 [template = constants.%C1] {} {}
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: class @C1 {
  116. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: !members:
  119. // CHECK:STDOUT: .Self = constants.%C1
  120. // CHECK:STDOUT: complete_type_witness = %complete_type
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: --- c2.carbon
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: constants {
  126. // CHECK:STDOUT: %C2: type = class_type @C2 [template]
  127. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  128. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: file {
  132. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  133. // CHECK:STDOUT: .C2 = %C2.decl
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %C2.decl: type = class_decl @C2 [template = constants.%C2] {} {}
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: class @C2 {
  139. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: !members:
  142. // CHECK:STDOUT: .Self = constants.%C2
  143. // CHECK:STDOUT: complete_type_witness = %complete_type
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: --- ns.carbon
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: constants {
  149. // CHECK:STDOUT: %C: type = class_type @C [template]
  150. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  151. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: file {
  155. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  156. // CHECK:STDOUT: .NS = %NS
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  159. // CHECK:STDOUT: .C = %C.decl
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: class @C {
  165. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: !members:
  168. // CHECK:STDOUT: .Self = constants.%C
  169. // CHECK:STDOUT: complete_type_witness = %complete_type
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: --- o1.carbon
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: constants {
  175. // CHECK:STDOUT: %O1: type = class_type @O1 [template]
  176. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  177. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: file {
  181. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  182. // CHECK:STDOUT: .O1 = %O1.decl
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT: %O1.decl: type = class_decl @O1 [template = constants.%O1] {} {}
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: class @O1 {
  188. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: !members:
  191. // CHECK:STDOUT: .Self = constants.%O1
  192. // CHECK:STDOUT: complete_type_witness = %complete_type
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: --- o2.carbon
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: constants {
  198. // CHECK:STDOUT: %O2: type = class_type @O2 [template]
  199. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  200. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: file {
  204. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  205. // CHECK:STDOUT: .O2 = %O2.decl
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT: %O2.decl: type = class_decl @O2 [template = constants.%O2] {} {}
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: class @O2 {
  211. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: !members:
  214. // CHECK:STDOUT: .Self = constants.%O2
  215. // CHECK:STDOUT: complete_type_witness = %complete_type
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: --- local_other.carbon
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: constants {
  221. // CHECK:STDOUT: %Other: type = class_type @Other [template]
  222. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  223. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: file {
  227. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  228. // CHECK:STDOUT: .Other = %Other.decl
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %Other.decl: type = class_decl @Other [template = constants.%Other] {} {}
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: class @Other {
  234. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: !members:
  237. // CHECK:STDOUT: .Self = constants.%Other
  238. // CHECK:STDOUT: complete_type_witness = %complete_type
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: --- mix_current_package.carbon
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: imports {
  244. // CHECK:STDOUT: %import_ref = import_ref Main//c1, C1, unloaded
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: file {
  248. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  249. // CHECK:STDOUT: .C1 = imports.%import_ref
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT: %default.import = import <invalid>
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: --- mix_current_package.impl.carbon
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: constants {
  257. // CHECK:STDOUT: %C1: type = class_type @C1 [template]
  258. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  259. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  260. // CHECK:STDOUT: %C1.val: %C1 = struct_value () [template]
  261. // CHECK:STDOUT: %C2: type = class_type @C2 [template]
  262. // CHECK:STDOUT: %C2.val: %C2 = struct_value () [template]
  263. // CHECK:STDOUT: }
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: imports {
  266. // CHECK:STDOUT: %import_ref.2f0: type = import_ref Main//mix_current_package, C1, loaded [template = constants.%C1]
  267. // CHECK:STDOUT: %import_ref.dcf: type = import_ref Main//c2, C2, loaded [template = constants.%C2]
  268. // CHECK:STDOUT: %import_ref.8f24d3.1: <witness> = import_ref Main//c1, loc4_11, loaded [template = constants.%complete_type]
  269. // CHECK:STDOUT: %import_ref.eb7 = import_ref Main//c1, inst14 [no loc], unloaded
  270. // CHECK:STDOUT: %import_ref.8f24d3.2: <witness> = import_ref Main//c2, loc4_11, loaded [template = constants.%complete_type]
  271. // CHECK:STDOUT: %import_ref.5b0 = import_ref Main//c2, inst14 [no loc], unloaded
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: file {
  275. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  276. // CHECK:STDOUT: .C1 = imports.%import_ref.2f0
  277. // CHECK:STDOUT: .C2 = imports.%import_ref.dcf
  278. // CHECK:STDOUT: .c1 = %c1
  279. // CHECK:STDOUT: .c2 = %c2
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  282. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  283. // CHECK:STDOUT: %c1.var: ref %C1 = var c1
  284. // CHECK:STDOUT: %c1: ref %C1 = bind_name c1, %c1.var
  285. // CHECK:STDOUT: %c2.var: ref %C2 = var c2
  286. // CHECK:STDOUT: %c2: ref %C2 = bind_name c2, %c2.var
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: class @C1 [from "c1.carbon"] {
  290. // CHECK:STDOUT: !members:
  291. // CHECK:STDOUT: .Self = imports.%import_ref.eb7
  292. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f24d3.1
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: class @C2 [from "c2.carbon"] {
  296. // CHECK:STDOUT: !members:
  297. // CHECK:STDOUT: .Self = imports.%import_ref.5b0
  298. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f24d3.2
  299. // CHECK:STDOUT: }
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: fn @__global_init() {
  302. // CHECK:STDOUT: !entry:
  303. // CHECK:STDOUT: %.loc6_15.1: %empty_struct_type = struct_literal ()
  304. // CHECK:STDOUT: %.loc6_15.2: init %C1 = class_init (), file.%c1.var [template = constants.%C1.val]
  305. // CHECK:STDOUT: %.loc6_16: init %C1 = converted %.loc6_15.1, %.loc6_15.2 [template = constants.%C1.val]
  306. // CHECK:STDOUT: assign file.%c1.var, %.loc6_16
  307. // CHECK:STDOUT: %.loc7_15.1: %empty_struct_type = struct_literal ()
  308. // CHECK:STDOUT: %.loc7_15.2: init %C2 = class_init (), file.%c2.var [template = constants.%C2.val]
  309. // CHECK:STDOUT: %.loc7_16: init %C2 = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C2.val]
  310. // CHECK:STDOUT: assign file.%c2.var, %.loc7_16
  311. // CHECK:STDOUT: return
  312. // CHECK:STDOUT: }
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: --- dup_c1.carbon
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: imports {
  317. // CHECK:STDOUT: %import_ref = import_ref Main//c1, C1, unloaded
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: file {
  321. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  322. // CHECK:STDOUT: .C1 = imports.%import_ref
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT: %default.import = import <invalid>
  325. // CHECK:STDOUT: }
  326. // CHECK:STDOUT:
  327. // CHECK:STDOUT: --- dup_c1.impl.carbon
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: constants {
  330. // CHECK:STDOUT: %C1: type = class_type @C1 [template]
  331. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  332. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  333. // CHECK:STDOUT: %C1.val: %C1 = struct_value () [template]
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: imports {
  337. // CHECK:STDOUT: %import_ref.2f0: type = import_ref Main//dup_c1, C1, loaded [template = constants.%C1]
  338. // CHECK:STDOUT: %import_ref.8f2: <witness> = import_ref Main//c1, loc4_11, loaded [template = constants.%complete_type]
  339. // CHECK:STDOUT: %import_ref.eb7 = import_ref Main//c1, inst14 [no loc], unloaded
  340. // CHECK:STDOUT: }
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: file {
  343. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  344. // CHECK:STDOUT: .C1 = imports.%import_ref.2f0
  345. // CHECK:STDOUT: .c1 = %c1
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  348. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  349. // CHECK:STDOUT: %c1.var: ref %C1 = var c1
  350. // CHECK:STDOUT: %c1: ref %C1 = bind_name c1, %c1.var
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: class @C1 [from "c1.carbon"] {
  354. // CHECK:STDOUT: !members:
  355. // CHECK:STDOUT: .Self = imports.%import_ref.eb7
  356. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f2
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: fn @__global_init() {
  360. // CHECK:STDOUT: !entry:
  361. // CHECK:STDOUT: %.loc6_15.1: %empty_struct_type = struct_literal ()
  362. // CHECK:STDOUT: %.loc6_15.2: init %C1 = class_init (), file.%c1.var [template = constants.%C1.val]
  363. // CHECK:STDOUT: %.loc6_16: init %C1 = converted %.loc6_15.1, %.loc6_15.2 [template = constants.%C1.val]
  364. // CHECK:STDOUT: assign file.%c1.var, %.loc6_16
  365. // CHECK:STDOUT: return
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: --- use_ns.carbon
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: imports {
  371. // CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Main//ns, NS, loaded
  372. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
  373. // CHECK:STDOUT: .C = %import_ref.3c0
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: file {
  378. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  379. // CHECK:STDOUT: .NS = imports.%NS
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT: %default.import = import <invalid>
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: --- use_ns.impl.carbon
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: constants {
  387. // CHECK:STDOUT: %C: type = class_type @C [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: %C.val: %C = struct_value () [template]
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: imports {
  394. // CHECK:STDOUT: %import_ref.0f6: <namespace> = import_ref Main//use_ns, NS, loaded
  395. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.0f6, [template] {
  396. // CHECK:STDOUT: .C = %import_ref.a76
  397. // CHECK:STDOUT: }
  398. // CHECK:STDOUT: %import_ref.8f2: <witness> = import_ref Main//ns, loc5_13, loaded [template = constants.%complete_type]
  399. // CHECK:STDOUT: %import_ref.2dd = import_ref Main//ns, inst15 [no loc], unloaded
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: file {
  403. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  404. // CHECK:STDOUT: .NS = imports.%NS
  405. // CHECK:STDOUT: .c = %c
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  408. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  409. // CHECK:STDOUT: %c.var: ref %C = var c
  410. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: class @C [from "ns.carbon"] {
  414. // CHECK:STDOUT: !members:
  415. // CHECK:STDOUT: .Self = imports.%import_ref.2dd
  416. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f2
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: fn @__global_init() {
  420. // CHECK:STDOUT: !entry:
  421. // CHECK:STDOUT: %.loc4_16.1: %empty_struct_type = struct_literal ()
  422. // CHECK:STDOUT: %.loc4_16.2: init %C = class_init (), file.%c.var [template = constants.%C.val]
  423. // CHECK:STDOUT: %.loc4_17: init %C = converted %.loc4_16.1, %.loc4_16.2 [template = constants.%C.val]
  424. // CHECK:STDOUT: assign file.%c.var, %.loc4_17
  425. // CHECK:STDOUT: return
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT:
  428. // CHECK:STDOUT: --- mix_other.carbon
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: imports {
  431. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  432. // CHECK:STDOUT: import Other//o1
  433. // CHECK:STDOUT: }
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: file {
  437. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  438. // CHECK:STDOUT: .Other = imports.%Other
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT: %Other.import = import Other
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: --- mix_other.impl.carbon
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: constants {
  446. // CHECK:STDOUT: %O1: type = class_type @O1 [template]
  447. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  448. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  449. // CHECK:STDOUT: %O1.val: %O1 = struct_value () [template]
  450. // CHECK:STDOUT: %O2: type = class_type @O2 [template]
  451. // CHECK:STDOUT: %O2.val: %O2 = struct_value () [template]
  452. // CHECK:STDOUT: }
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: imports {
  455. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  456. // CHECK:STDOUT: .O1 = %import_ref.136
  457. // CHECK:STDOUT: .O2 = %import_ref.f3b
  458. // CHECK:STDOUT: import Other//o2
  459. // CHECK:STDOUT: import Other//o1
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT: %import_ref.8f24d3.1: <witness> = import_ref Other//o1, loc4_11, loaded [template = constants.%complete_type]
  462. // CHECK:STDOUT: %import_ref.481 = import_ref Other//o1, inst14 [no loc], unloaded
  463. // CHECK:STDOUT: %import_ref.8f24d3.2: <witness> = import_ref Other//o2, loc4_11, loaded [template = constants.%complete_type]
  464. // CHECK:STDOUT: %import_ref.2eb = import_ref Other//o2, inst14 [no loc], unloaded
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: file {
  468. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  469. // CHECK:STDOUT: .Other = imports.%Other
  470. // CHECK:STDOUT: .o1 = %o1
  471. // CHECK:STDOUT: .o2 = %o2
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  474. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  475. // CHECK:STDOUT: %Other.import = import Other
  476. // CHECK:STDOUT: %o1.var: ref %O1 = var o1
  477. // CHECK:STDOUT: %o1: ref %O1 = bind_name o1, %o1.var
  478. // CHECK:STDOUT: %o2.var: ref %O2 = var o2
  479. // CHECK:STDOUT: %o2: ref %O2 = bind_name o2, %o2.var
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT:
  482. // CHECK:STDOUT: class @O1 [from "o1.carbon"] {
  483. // CHECK:STDOUT: !members:
  484. // CHECK:STDOUT: .Self = imports.%import_ref.481
  485. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f24d3.1
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT:
  488. // CHECK:STDOUT: class @O2 [from "o2.carbon"] {
  489. // CHECK:STDOUT: !members:
  490. // CHECK:STDOUT: .Self = imports.%import_ref.2eb
  491. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f24d3.2
  492. // CHECK:STDOUT: }
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: fn @__global_init() {
  495. // CHECK:STDOUT: !entry:
  496. // CHECK:STDOUT: %.loc6_21.1: %empty_struct_type = struct_literal ()
  497. // CHECK:STDOUT: %.loc6_21.2: init %O1 = class_init (), file.%o1.var [template = constants.%O1.val]
  498. // CHECK:STDOUT: %.loc6_22: init %O1 = converted %.loc6_21.1, %.loc6_21.2 [template = constants.%O1.val]
  499. // CHECK:STDOUT: assign file.%o1.var, %.loc6_22
  500. // CHECK:STDOUT: %.loc7_21.1: %empty_struct_type = struct_literal ()
  501. // CHECK:STDOUT: %.loc7_21.2: init %O2 = class_init (), file.%o2.var [template = constants.%O2.val]
  502. // CHECK:STDOUT: %.loc7_22: init %O2 = converted %.loc7_21.1, %.loc7_21.2 [template = constants.%O2.val]
  503. // CHECK:STDOUT: assign file.%o2.var, %.loc7_22
  504. // CHECK:STDOUT: return
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: --- dup_o1.carbon
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: imports {
  510. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  511. // CHECK:STDOUT: import Other//o1
  512. // CHECK:STDOUT: }
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: file {
  516. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  517. // CHECK:STDOUT: .Other = imports.%Other
  518. // CHECK:STDOUT: }
  519. // CHECK:STDOUT: %Other.import = import Other
  520. // CHECK:STDOUT: }
  521. // CHECK:STDOUT:
  522. // CHECK:STDOUT: --- dup_o1.impl.carbon
  523. // CHECK:STDOUT:
  524. // CHECK:STDOUT: constants {
  525. // CHECK:STDOUT: %O1: type = class_type @O1 [template]
  526. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  527. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  528. // CHECK:STDOUT: %O1.val: %O1 = struct_value () [template]
  529. // CHECK:STDOUT: }
  530. // CHECK:STDOUT:
  531. // CHECK:STDOUT: imports {
  532. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  533. // CHECK:STDOUT: .O1 = %import_ref.136
  534. // CHECK:STDOUT: import Other//o1
  535. // CHECK:STDOUT: }
  536. // CHECK:STDOUT: %import_ref.8f2: <witness> = import_ref Other//o1, loc4_11, loaded [template = constants.%complete_type]
  537. // CHECK:STDOUT: %import_ref.481 = import_ref Other//o1, inst14 [no loc], unloaded
  538. // CHECK:STDOUT: }
  539. // CHECK:STDOUT:
  540. // CHECK:STDOUT: file {
  541. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  542. // CHECK:STDOUT: .Other = imports.%Other
  543. // CHECK:STDOUT: .o1 = %o1
  544. // CHECK:STDOUT: }
  545. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  546. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  547. // CHECK:STDOUT: %Other.import = import Other
  548. // CHECK:STDOUT: %o1.var: ref %O1 = var o1
  549. // CHECK:STDOUT: %o1: ref %O1 = bind_name o1, %o1.var
  550. // CHECK:STDOUT: }
  551. // CHECK:STDOUT:
  552. // CHECK:STDOUT: class @O1 [from "o1.carbon"] {
  553. // CHECK:STDOUT: !members:
  554. // CHECK:STDOUT: .Self = imports.%import_ref.481
  555. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f2
  556. // CHECK:STDOUT: }
  557. // CHECK:STDOUT:
  558. // CHECK:STDOUT: fn @__global_init() {
  559. // CHECK:STDOUT: !entry:
  560. // CHECK:STDOUT: %.loc6_21.1: %empty_struct_type = struct_literal ()
  561. // CHECK:STDOUT: %.loc6_21.2: init %O1 = class_init (), file.%o1.var [template = constants.%O1.val]
  562. // CHECK:STDOUT: %.loc6_22: init %O1 = converted %.loc6_21.1, %.loc6_21.2 [template = constants.%O1.val]
  563. // CHECK:STDOUT: assign file.%o1.var, %.loc6_22
  564. // CHECK:STDOUT: return
  565. // CHECK:STDOUT: }
  566. // CHECK:STDOUT:
  567. // CHECK:STDOUT: --- import_conflict.carbon
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: imports {
  570. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  571. // CHECK:STDOUT: import Other//o1
  572. // CHECK:STDOUT: }
  573. // CHECK:STDOUT: }
  574. // CHECK:STDOUT:
  575. // CHECK:STDOUT: file {
  576. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  577. // CHECK:STDOUT: .Other = imports.%Other
  578. // CHECK:STDOUT: }
  579. // CHECK:STDOUT: %Other.import = import Other
  580. // CHECK:STDOUT: }
  581. // CHECK:STDOUT:
  582. // CHECK:STDOUT: --- fail_import_conflict.impl.carbon
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: imports {
  585. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  586. // CHECK:STDOUT: import Other//o1
  587. // CHECK:STDOUT: }
  588. // CHECK:STDOUT: }
  589. // CHECK:STDOUT:
  590. // CHECK:STDOUT: file {
  591. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  592. // CHECK:STDOUT: .Other = imports.%Other
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT: %default.import.loc11_6.1 = import <invalid>
  595. // CHECK:STDOUT: %default.import.loc11_6.2 = import <invalid>
  596. // CHECK:STDOUT: %Other.import = import Other
  597. // CHECK:STDOUT: }
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: --- import_conflict_reverse.carbon
  600. // CHECK:STDOUT:
  601. // CHECK:STDOUT: imports {
  602. // CHECK:STDOUT: %import_ref = import_ref Main//local_other, Other, unloaded
  603. // CHECK:STDOUT: }
  604. // CHECK:STDOUT:
  605. // CHECK:STDOUT: file {
  606. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  607. // CHECK:STDOUT: .Other = imports.%import_ref
  608. // CHECK:STDOUT: }
  609. // CHECK:STDOUT: %default.import = import <invalid>
  610. // CHECK:STDOUT: }
  611. // CHECK:STDOUT:
  612. // CHECK:STDOUT: --- fail_import_conflict_reverse.impl.carbon
  613. // CHECK:STDOUT:
  614. // CHECK:STDOUT: imports {
  615. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  616. // CHECK:STDOUT: import Other//o1
  617. // CHECK:STDOUT: }
  618. // CHECK:STDOUT: }
  619. // CHECK:STDOUT:
  620. // CHECK:STDOUT: file {
  621. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  622. // CHECK:STDOUT: .Other = imports.%Other
  623. // CHECK:STDOUT: }
  624. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  625. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  626. // CHECK:STDOUT: %Other.import = import Other
  627. // CHECK:STDOUT: }
  628. // CHECK:STDOUT: