cross_package_import.carbon 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/cross_package_import.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/cross_package_import.carbon
  14. // ============================================================================
  15. // Setup files
  16. // ============================================================================
  17. // --- other_define.carbon
  18. package Other library "[[@TEST_NAME]]";
  19. class C {}
  20. // --- other_extern.carbon
  21. package Other library "[[@TEST_NAME]]";
  22. extern class C;
  23. // --- other_conflict.carbon
  24. package Other library "[[@TEST_NAME]]";
  25. fn C() {}
  26. // ============================================================================
  27. // Test files
  28. // ============================================================================
  29. // --- define.carbon
  30. library "[[@TEST_NAME]]";
  31. import Other library "other_define";
  32. var c: Other.C = {};
  33. // --- fail_extern.carbon
  34. library "[[@TEST_NAME]]";
  35. import Other library "other_extern";
  36. // CHECK:STDERR: fail_extern.carbon:[[@LINE+8]]:8: error: binding pattern has incomplete type `C` in name binding declaration [IncompleteTypeInBindingDecl]
  37. // CHECK:STDERR: var c: Other.C = {};
  38. // CHECK:STDERR: ^~~~~~~
  39. // CHECK:STDERR: fail_extern.carbon:[[@LINE-5]]:1: in import [InImport]
  40. // CHECK:STDERR: other_extern.carbon:4:1: note: class was forward declared here [ClassForwardDeclaredHere]
  41. // CHECK:STDERR: extern class C;
  42. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  43. // CHECK:STDERR:
  44. var c: Other.C = {};
  45. // --- fail_todo_merge_define_extern.carbon
  46. library "[[@TEST_NAME]]";
  47. // CHECK:STDERR: fail_todo_merge_define_extern.carbon:[[@LINE+8]]:1: in import [InImport]
  48. // CHECK:STDERR: other_extern.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
  49. // CHECK:STDERR: extern class C;
  50. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  51. // CHECK:STDERR: fail_todo_merge_define_extern.carbon:[[@LINE+4]]:1: in import [InImport]
  52. // CHECK:STDERR: other_define.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  53. // CHECK:STDERR: class C {}
  54. // CHECK:STDERR: ^~~~~~~~~
  55. import Other library "other_define";
  56. import Other library "other_extern";
  57. // CHECK:STDERR: fail_todo_merge_define_extern.carbon:[[@LINE+4]]:8: note: in name lookup for `C` [InNameLookup]
  58. // CHECK:STDERR: var c: Other.C = {};
  59. // CHECK:STDERR: ^~~~~~~
  60. // CHECK:STDERR:
  61. var c: Other.C = {};
  62. // --- fail_conflict.carbon
  63. library "[[@TEST_NAME]]";
  64. // CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:1: in import [InImport]
  65. // CHECK:STDERR: other_conflict.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
  66. // CHECK:STDERR: fn C() {}
  67. // CHECK:STDERR: ^~~~~~~~
  68. // CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:1: in import [InImport]
  69. // CHECK:STDERR: other_define.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  70. // CHECK:STDERR: class C {}
  71. // CHECK:STDERR: ^~~~~~~~~
  72. import Other library "other_define";
  73. import Other library "other_conflict";
  74. // CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:8: note: in name lookup for `C` [InNameLookup]
  75. // CHECK:STDERR: var c: Other.C = {};
  76. // CHECK:STDERR: ^~~~~~~
  77. // CHECK:STDERR:
  78. var c: Other.C = {};
  79. // CHECK:STDOUT: --- other_define.carbon
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: constants {
  82. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  83. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  84. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  85. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness @C.%Destroy.impl_witness_table [concrete]
  86. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  87. // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete]
  88. // CHECK:STDOUT: %C.as.Destroy.impl.Op.type: type = fn_type @C.as.Destroy.impl.Op [concrete]
  89. // CHECK:STDOUT: %C.as.Destroy.impl.Op: %C.as.Destroy.impl.Op.type = struct_value () [concrete]
  90. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  91. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: imports {
  95. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  96. // CHECK:STDOUT: .Destroy = %Core.Destroy
  97. // CHECK:STDOUT: import Core//prelude
  98. // CHECK:STDOUT: import Core//prelude/...
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: file {
  104. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  105. // CHECK:STDOUT: .Core = imports.%Core
  106. // CHECK:STDOUT: .C = %C.decl
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: %Core.import = import Core
  109. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: impl @C.as.Destroy.impl: @C.%Self.ref as constants.%Destroy.type {
  113. // CHECK:STDOUT: %C.as.Destroy.impl.Op.decl: %C.as.Destroy.impl.Op.type = fn_decl @C.as.Destroy.impl.Op [concrete = constants.%C.as.Destroy.impl.Op] {
  114. // CHECK:STDOUT: %self.patt: %pattern_type.44a = binding_pattern self [concrete]
  115. // CHECK:STDOUT: %self.param_patt: %pattern_type.44a = value_param_pattern %self.patt, call_param0 [concrete]
  116. // CHECK:STDOUT: %.loc4: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  117. // CHECK:STDOUT: } {
  118. // CHECK:STDOUT: %self.param: %ptr.019 = value_param call_param0
  119. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  120. // CHECK:STDOUT: %self: %ptr.019 = bind_name self, %self.param
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: !members:
  124. // CHECK:STDOUT: .Op = %C.as.Destroy.impl.Op.decl
  125. // CHECK:STDOUT: witness = @C.%Destroy.impl_witness
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: class @C {
  129. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  130. // CHECK:STDOUT: impl_decl @C.as.Destroy.impl [concrete] {} {}
  131. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@C.as.Destroy.impl.%C.as.Destroy.impl.Op.decl), @C.as.Destroy.impl [concrete]
  132. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness]
  133. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  134. // CHECK:STDOUT: complete_type_witness = %complete_type
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: !members:
  137. // CHECK:STDOUT: .Self = constants.%C
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: fn @C.as.Destroy.impl.Op(%self.param: %ptr.019) = "no_op";
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: --- other_extern.carbon
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: constants {
  145. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: imports {
  149. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  150. // CHECK:STDOUT: import Core//prelude
  151. // CHECK:STDOUT: import Core//prelude/...
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: file {
  156. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  157. // CHECK:STDOUT: .Core = imports.%Core
  158. // CHECK:STDOUT: .C = %C.decl
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT: %Core.import = import Core
  161. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: class @C;
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: --- other_conflict.carbon
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: constants {
  169. // CHECK:STDOUT: %C.type: type = fn_type @C [concrete]
  170. // CHECK:STDOUT: %C: %C.type = struct_value () [concrete]
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: imports {
  174. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  175. // CHECK:STDOUT: import Core//prelude
  176. // CHECK:STDOUT: import Core//prelude/...
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: file {
  181. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  182. // CHECK:STDOUT: .Core = imports.%Core
  183. // CHECK:STDOUT: .C = %C.decl
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT: %Core.import = import Core
  186. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [concrete = constants.%C] {} {}
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: fn @C() {
  190. // CHECK:STDOUT: !entry:
  191. // CHECK:STDOUT: return
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: --- define.carbon
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: constants {
  197. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  198. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  199. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  200. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  201. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: imports {
  205. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  206. // CHECK:STDOUT: import Core//prelude
  207. // CHECK:STDOUT: import Core//prelude/...
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  210. // CHECK:STDOUT: .C = %Other.C
  211. // CHECK:STDOUT: import Other//other_define
  212. // CHECK:STDOUT: }
  213. // CHECK:STDOUT: %Other.C: type = import_ref Other//other_define, C, loaded [concrete = constants.%C]
  214. // CHECK:STDOUT: %Other.import_ref.8f2: <witness> = import_ref Other//other_define, loc4_10, loaded [concrete = constants.%complete_type]
  215. // CHECK:STDOUT: %Other.import_ref.2c4 = import_ref Other//other_define, inst18 [no loc], unloaded
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: file {
  219. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  220. // CHECK:STDOUT: .Core = imports.%Core
  221. // CHECK:STDOUT: .Other = imports.%Other
  222. // CHECK:STDOUT: .c = %c
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT: %Core.import = import Core
  225. // CHECK:STDOUT: %Other.import = import Other
  226. // CHECK:STDOUT: name_binding_decl {
  227. // CHECK:STDOUT: %c.patt: %pattern_type = binding_pattern c [concrete]
  228. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  231. // CHECK:STDOUT: %.loc6: type = splice_block %C.ref [concrete = constants.%C] {
  232. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  233. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var [concrete = %c.var]
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: class @C [from "other_define.carbon"] {
  239. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.8f2
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: !members:
  242. // CHECK:STDOUT: .Self = imports.%Other.import_ref.2c4
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: fn @__global_init() {
  246. // CHECK:STDOUT: !entry:
  247. // CHECK:STDOUT: %.loc6_19.1: %empty_struct_type = struct_literal ()
  248. // CHECK:STDOUT: %.loc6_19.2: init %C = class_init (), file.%c.var [concrete = constants.%C.val]
  249. // CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_19.1, %.loc6_19.2 [concrete = constants.%C.val]
  250. // CHECK:STDOUT: assign file.%c.var, %.loc6_1
  251. // CHECK:STDOUT: return
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: --- fail_extern.carbon
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: constants {
  257. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  258. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: imports {
  262. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  263. // CHECK:STDOUT: import Core//prelude
  264. // CHECK:STDOUT: import Core//prelude/...
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  267. // CHECK:STDOUT: .C = %Other.C
  268. // CHECK:STDOUT: import Other//other_extern
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT: %Other.C: type = import_ref Other//other_extern, C, loaded [concrete = constants.%C]
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: file {
  274. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  275. // CHECK:STDOUT: .Core = imports.%Core
  276. // CHECK:STDOUT: .Other = imports.%Other
  277. // CHECK:STDOUT: .c = %c
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %Core.import = import Core
  280. // CHECK:STDOUT: %Other.import = import Other
  281. // CHECK:STDOUT: name_binding_decl {
  282. // CHECK:STDOUT: %c.patt: <error> = binding_pattern c [concrete]
  283. // CHECK:STDOUT: %c.var_patt: <error> = var_pattern %c.patt [concrete]
  284. // CHECK:STDOUT: }
  285. // CHECK:STDOUT: %c.var: ref <error> = var %c.var_patt [concrete = <error>]
  286. // CHECK:STDOUT: %.loc14: type = splice_block %C.ref [concrete = constants.%C] {
  287. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  288. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT: %c: <error> = bind_name c, <error> [concrete = <error>]
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: class @C [from "other_extern.carbon"];
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: fn @__global_init() {
  296. // CHECK:STDOUT: !entry:
  297. // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal ()
  298. // CHECK:STDOUT: assign file.%c.var, <error>
  299. // CHECK:STDOUT: return
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: --- fail_todo_merge_define_extern.carbon
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: constants {
  305. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  306. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  307. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  308. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  309. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: imports {
  313. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  314. // CHECK:STDOUT: import Core//prelude
  315. // CHECK:STDOUT: import Core//prelude/...
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  318. // CHECK:STDOUT: .C = %Other.C
  319. // CHECK:STDOUT: import Other//other_define
  320. // CHECK:STDOUT: import Other//other_extern
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: %Other.C: type = import_ref Other//other_define, C, loaded [concrete = constants.%C]
  323. // CHECK:STDOUT: %Other.import_ref.8f2: <witness> = import_ref Other//other_define, loc4_10, loaded [concrete = constants.%complete_type]
  324. // CHECK:STDOUT: %Other.import_ref.2c4 = import_ref Other//other_define, inst18 [no loc], unloaded
  325. // CHECK:STDOUT: }
  326. // CHECK:STDOUT:
  327. // CHECK:STDOUT: file {
  328. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  329. // CHECK:STDOUT: .Core = imports.%Core
  330. // CHECK:STDOUT: .Other = imports.%Other
  331. // CHECK:STDOUT: .c = %c
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT: %Core.import = import Core
  334. // CHECK:STDOUT: %Other.import = import Other
  335. // CHECK:STDOUT: name_binding_decl {
  336. // CHECK:STDOUT: %c.patt: %pattern_type = binding_pattern c [concrete]
  337. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  340. // CHECK:STDOUT: %.loc19: type = splice_block %C.ref [concrete = constants.%C] {
  341. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  342. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var [concrete = %c.var]
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: class @C [from "other_define.carbon"] {
  348. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.8f2
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: !members:
  351. // CHECK:STDOUT: .Self = imports.%Other.import_ref.2c4
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: fn @__global_init() {
  355. // CHECK:STDOUT: !entry:
  356. // CHECK:STDOUT: %.loc19_19.1: %empty_struct_type = struct_literal ()
  357. // CHECK:STDOUT: %.loc19_19.2: init %C = class_init (), file.%c.var [concrete = constants.%C.val]
  358. // CHECK:STDOUT: %.loc19_1: init %C = converted %.loc19_19.1, %.loc19_19.2 [concrete = constants.%C.val]
  359. // CHECK:STDOUT: assign file.%c.var, %.loc19_1
  360. // CHECK:STDOUT: return
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: --- fail_conflict.carbon
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: constants {
  366. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  367. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  368. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  369. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  370. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT:
  373. // CHECK:STDOUT: imports {
  374. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  375. // CHECK:STDOUT: import Core//prelude
  376. // CHECK:STDOUT: import Core//prelude/...
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  379. // CHECK:STDOUT: .C = %Other.C
  380. // CHECK:STDOUT: import Other//other_define
  381. // CHECK:STDOUT: import Other//other_conflict
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT: %Other.C: type = import_ref Other//other_define, C, loaded [concrete = constants.%C]
  384. // CHECK:STDOUT: %Other.import_ref.8f2: <witness> = import_ref Other//other_define, loc4_10, loaded [concrete = constants.%complete_type]
  385. // CHECK:STDOUT: %Other.import_ref.2c4 = import_ref Other//other_define, inst18 [no loc], unloaded
  386. // CHECK:STDOUT: }
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: file {
  389. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  390. // CHECK:STDOUT: .Core = imports.%Core
  391. // CHECK:STDOUT: .Other = imports.%Other
  392. // CHECK:STDOUT: .c = %c
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT: %Core.import = import Core
  395. // CHECK:STDOUT: %Other.import = import Other
  396. // CHECK:STDOUT: name_binding_decl {
  397. // CHECK:STDOUT: %c.patt: %pattern_type = binding_pattern c [concrete]
  398. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  401. // CHECK:STDOUT: %.loc19: type = splice_block %C.ref [concrete = constants.%C] {
  402. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  403. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var [concrete = %c.var]
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: class @C [from "other_define.carbon"] {
  409. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.8f2
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: !members:
  412. // CHECK:STDOUT: .Self = imports.%Other.import_ref.2c4
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: fn @__global_init() {
  416. // CHECK:STDOUT: !entry:
  417. // CHECK:STDOUT: %.loc19_19.1: %empty_struct_type = struct_literal ()
  418. // CHECK:STDOUT: %.loc19_19.2: init %C = class_init (), file.%c.var [concrete = constants.%C.val]
  419. // CHECK:STDOUT: %.loc19_1: init %C = converted %.loc19_19.1, %.loc19_19.2 [concrete = constants.%C.val]
  420. // CHECK:STDOUT: assign file.%c.var, %.loc19_1
  421. // CHECK:STDOUT: return
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT: