import_access.carbon 24 KB

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