import_access.carbon 24 KB

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