import_symbolic.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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/full.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/primitives/import_symbolic.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/primitives/import_symbolic.carbon
  12. // --- bool.carbon
  13. library "[[@TEST_NAME]]";
  14. interface I {
  15. let val:! bool;
  16. }
  17. class C {
  18. impl as I where .val = false {}
  19. }
  20. // --- import_bool.carbon
  21. library "[[@TEST_NAME]]";
  22. import library "bool";
  23. fn F() -> bool {
  24. //@dump-sem-ir-begin
  25. return (C as I).val;
  26. //@dump-sem-ir-end
  27. }
  28. // --- char.carbon
  29. library "[[@TEST_NAME]]";
  30. interface I {
  31. let val:! Core.Char;
  32. }
  33. class C {}
  34. impl C as I where .val = 'a' {}
  35. // --- import_char.carbon
  36. library "[[@TEST_NAME]]";
  37. import library "char";
  38. fn F() -> Core.Char {
  39. //@dump-sem-ir-begin
  40. return (C as I).val;
  41. //@dump-sem-ir-end
  42. }
  43. // --- char_literal.carbon
  44. library "[[@TEST_NAME]]";
  45. interface I {
  46. let val:! Core.CharLiteral();
  47. }
  48. class C {}
  49. impl C as I where .val = 'a' {}
  50. // --- import_char_literal.carbon
  51. library "[[@TEST_NAME]]";
  52. import library "char_literal";
  53. fn F() -> Core.CharLiteral() {
  54. //@dump-sem-ir-begin
  55. return (C as I).val;
  56. //@dump-sem-ir-end
  57. }
  58. // --- float.carbon
  59. library "[[@TEST_NAME]]";
  60. interface I {
  61. let val:! f64;
  62. }
  63. class C {}
  64. impl C as I where .val = 0.1 {}
  65. // --- import_float.carbon
  66. library "[[@TEST_NAME]]";
  67. import library "float";
  68. fn F() -> f64 {
  69. //@dump-sem-ir-begin
  70. return (C as I).val;
  71. //@dump-sem-ir-end
  72. }
  73. // --- float_literal.carbon
  74. library "[[@TEST_NAME]]";
  75. interface I {
  76. let val:! Core.FloatLiteral();
  77. }
  78. class C {}
  79. impl C as I where .val = 0.1 {}
  80. // --- import_float_literal.carbon
  81. library "[[@TEST_NAME]]";
  82. import library "float_literal";
  83. fn F() -> Core.FloatLiteral() {
  84. //@dump-sem-ir-begin
  85. return (C as I).val;
  86. //@dump-sem-ir-end
  87. }
  88. // --- int.carbon
  89. library "[[@TEST_NAME]]";
  90. interface I {
  91. let val:! i32;
  92. }
  93. class C {}
  94. impl C as I where .val = 8 {}
  95. // --- import_int.carbon
  96. library "[[@TEST_NAME]]";
  97. import library "int";
  98. fn F() -> i32 {
  99. //@dump-sem-ir-begin
  100. return (C as I).val;
  101. //@dump-sem-ir-end
  102. }
  103. // --- int_literal.carbon
  104. library "[[@TEST_NAME]]";
  105. interface I {
  106. let val:! Core.IntLiteral();
  107. }
  108. class C {}
  109. impl C as I where .val = 7 {}
  110. // --- import_int_literal.carbon
  111. library "[[@TEST_NAME]]";
  112. import library "int_literal";
  113. fn F() -> Core.IntLiteral() {
  114. //@dump-sem-ir-begin
  115. return (C as I).val;
  116. //@dump-sem-ir-end
  117. }
  118. // --- uint.carbon
  119. library "[[@TEST_NAME]]";
  120. interface I {
  121. let val:! u32;
  122. }
  123. class C {}
  124. impl C as I where .val = 8 {}
  125. // --- unsigned_uint.carbon
  126. library "[[@TEST_NAME]]";
  127. import library "uint";
  128. fn F() -> u32 {
  129. //@dump-sem-ir-begin
  130. return (C as I).val;
  131. //@dump-sem-ir-end
  132. }
  133. // CHECK:STDOUT: --- import_bool.carbon
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: constants {
  136. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  137. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  138. // CHECK:STDOUT: %false: bool = bool_literal false [concrete]
  139. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  140. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  141. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  142. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.030 [concrete]
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: imports {
  146. // CHECK:STDOUT: %Main.I: type = import_ref Main//bool, I, loaded [concrete = constants.%I.type]
  147. // CHECK:STDOUT: %Main.C: type = import_ref Main//bool, C, loaded [concrete = constants.%C]
  148. // CHECK:STDOUT: %Main.import_ref.8be: %I.assoc_type = import_ref Main//bool, loc5_10, loaded [concrete = constants.%assoc0]
  149. // CHECK:STDOUT: %Main.import_ref.d18: bool = import_ref Main//bool, loc9_32, loaded [concrete = constants.%false]
  150. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.d18), @C.as.I.impl [concrete]
  151. // CHECK:STDOUT: %Main.import_ref.030: bool = import_ref Main//bool, loc5_10, loaded [concrete = %val]
  152. // CHECK:STDOUT: %val: bool = assoc_const_decl @val [concrete] {}
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: fn @F() -> bool {
  156. // CHECK:STDOUT: !entry:
  157. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  158. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  159. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  160. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  161. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.8be [concrete = constants.%assoc0]
  162. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  163. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  164. // CHECK:STDOUT: %impl.elem0: bool = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%false]
  165. // CHECK:STDOUT: return %impl.elem0
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: --- import_char.carbon
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: constants {
  171. // CHECK:STDOUT: %Char: type = class_type @Char [concrete]
  172. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  173. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  174. // CHECK:STDOUT: %int_97: %Char = int_value 97 [concrete]
  175. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  176. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  177. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  178. // CHECK:STDOUT: %assoc0.941: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.8e8 [concrete]
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: imports {
  182. // CHECK:STDOUT: %Main.I: type = import_ref Main//char, I, loaded [concrete = constants.%I.type]
  183. // CHECK:STDOUT: %Main.C: type = import_ref Main//char, C, loaded [concrete = constants.%C]
  184. // CHECK:STDOUT: %Main.import_ref.da1: %I.assoc_type = import_ref Main//char, loc5_10, loaded [concrete = constants.%assoc0.941]
  185. // CHECK:STDOUT: %Main.import_ref.d0c: %Char = import_ref Main//char, loc10_30, loaded [concrete = constants.%int_97]
  186. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.d0c), @C.as.I.impl [concrete]
  187. // CHECK:STDOUT: %Main.import_ref.8e8: %Char = import_ref Main//char, loc5_10, loaded [concrete = %val]
  188. // CHECK:STDOUT: %val: %Char = assoc_const_decl @val [concrete] {}
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: fn @F() -> %Char {
  192. // CHECK:STDOUT: !entry:
  193. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  194. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  195. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  196. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  197. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.da1 [concrete = constants.%assoc0.941]
  198. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  199. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  200. // CHECK:STDOUT: %impl.elem0: %Char = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%int_97]
  201. // CHECK:STDOUT: return %impl.elem0
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: --- import_char_literal.carbon
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: constants {
  207. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  208. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  209. // CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete]
  210. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  211. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  212. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  213. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.dcc [concrete]
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: imports {
  217. // CHECK:STDOUT: %Main.I: type = import_ref Main//char_literal, I, loaded [concrete = constants.%I.type]
  218. // CHECK:STDOUT: %Main.C: type = import_ref Main//char_literal, C, loaded [concrete = constants.%C]
  219. // CHECK:STDOUT: %Main.import_ref.696: %I.assoc_type = import_ref Main//char_literal, loc5_10, loaded [concrete = constants.%assoc0]
  220. // CHECK:STDOUT: %Main.import_ref.43e: Core.CharLiteral = import_ref Main//char_literal, loc10_30, loaded [concrete = constants.%.54f]
  221. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.43e), @C.as.I.impl [concrete]
  222. // CHECK:STDOUT: %Main.import_ref.dcc: Core.CharLiteral = import_ref Main//char_literal, loc5_10, loaded [concrete = %val]
  223. // CHECK:STDOUT: %val: Core.CharLiteral = assoc_const_decl @val [concrete] {}
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: fn @F() -> Core.CharLiteral {
  227. // CHECK:STDOUT: !entry:
  228. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  229. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  230. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  231. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  232. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.696 [concrete = constants.%assoc0]
  233. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  234. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  235. // CHECK:STDOUT: %impl.elem0: Core.CharLiteral = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%.54f]
  236. // CHECK:STDOUT: return %impl.elem0
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: --- import_float.carbon
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: constants {
  242. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
  243. // CHECK:STDOUT: %f64.d77: type = class_type @Float, @Float(%int_64) [concrete]
  244. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  245. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  246. // CHECK:STDOUT: %float: %f64.d77 = float_value 0.10000000000000001 [concrete]
  247. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  248. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  249. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  250. // CHECK:STDOUT: %assoc0.ece: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.267 [concrete]
  251. // CHECK:STDOUT: }
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: imports {
  254. // CHECK:STDOUT: %Main.I: type = import_ref Main//float, I, loaded [concrete = constants.%I.type]
  255. // CHECK:STDOUT: %Main.C: type = import_ref Main//float, C, loaded [concrete = constants.%C]
  256. // CHECK:STDOUT: %Main.import_ref.de3: %I.assoc_type = import_ref Main//float, loc5_10, loaded [concrete = constants.%assoc0.ece]
  257. // CHECK:STDOUT: %Main.import_ref.0d9: %f64.d77 = import_ref Main//float, loc10_30, loaded [concrete = constants.%float]
  258. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.0d9), @C.as.I.impl [concrete]
  259. // CHECK:STDOUT: %Main.import_ref.267: %f64.d77 = import_ref Main//float, loc5_10, loaded [concrete = %val]
  260. // CHECK:STDOUT: %val: %f64.d77 = assoc_const_decl @val [concrete] {}
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: fn @F() -> %f64.d77 {
  264. // CHECK:STDOUT: !entry:
  265. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  266. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  267. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  268. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  269. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.de3 [concrete = constants.%assoc0.ece]
  270. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  271. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  272. // CHECK:STDOUT: %impl.elem0: %f64.d77 = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%float]
  273. // CHECK:STDOUT: return %impl.elem0
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: --- import_float_literal.carbon
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: constants {
  279. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  280. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  281. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  282. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  283. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  284. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.e01 [concrete]
  285. // CHECK:STDOUT: %float.3fedf4.2: Core.FloatLiteral = float_literal_value 1e-1 [concrete]
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: imports {
  289. // CHECK:STDOUT: %Main.I: type = import_ref Main//float_literal, I, loaded [concrete = constants.%I.type]
  290. // CHECK:STDOUT: %Main.C: type = import_ref Main//float_literal, C, loaded [concrete = constants.%C]
  291. // CHECK:STDOUT: %Main.import_ref.730: %I.assoc_type = import_ref Main//float_literal, loc5_10, loaded [concrete = constants.%assoc0]
  292. // CHECK:STDOUT: %Main.import_ref.dec: Core.FloatLiteral = import_ref Main//float_literal, loc10_30, loaded [concrete = constants.%float.3fedf4.2]
  293. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.dec), @C.as.I.impl [concrete]
  294. // CHECK:STDOUT: %Main.import_ref.e01: Core.FloatLiteral = import_ref Main//float_literal, loc5_10, loaded [concrete = %val]
  295. // CHECK:STDOUT: %val: Core.FloatLiteral = assoc_const_decl @val [concrete] {}
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: fn @F() -> Core.FloatLiteral {
  299. // CHECK:STDOUT: !entry:
  300. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  301. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  302. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  303. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  304. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.730 [concrete = constants.%assoc0]
  305. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  306. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  307. // CHECK:STDOUT: %impl.elem0: Core.FloatLiteral = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%float.3fedf4.2]
  308. // CHECK:STDOUT: return %impl.elem0
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: --- import_int.carbon
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: constants {
  314. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  315. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  316. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  317. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  318. // CHECK:STDOUT: %int_8: %i32 = int_value 8 [concrete]
  319. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  320. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  321. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  322. // CHECK:STDOUT: %assoc0.aac: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.05e [concrete]
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: imports {
  326. // CHECK:STDOUT: %Main.I: type = import_ref Main//int, I, loaded [concrete = constants.%I.type]
  327. // CHECK:STDOUT: %Main.C: type = import_ref Main//int, C, loaded [concrete = constants.%C]
  328. // CHECK:STDOUT: %Main.import_ref.ba4: %I.assoc_type = import_ref Main//int, loc5_10, loaded [concrete = constants.%assoc0.aac]
  329. // CHECK:STDOUT: %Main.import_ref.330: %i32 = import_ref Main//int, loc10_28, loaded [concrete = constants.%int_8]
  330. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.330), @C.as.I.impl [concrete]
  331. // CHECK:STDOUT: %Main.import_ref.05e: %i32 = import_ref Main//int, loc5_10, loaded [concrete = %val]
  332. // CHECK:STDOUT: %val: %i32 = assoc_const_decl @val [concrete] {}
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: fn @F() -> %i32 {
  336. // CHECK:STDOUT: !entry:
  337. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  338. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  339. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  340. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  341. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.ba4 [concrete = constants.%assoc0.aac]
  342. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  343. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  344. // CHECK:STDOUT: %impl.elem0: %i32 = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%int_8]
  345. // CHECK:STDOUT: return %impl.elem0
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: --- import_int_literal.carbon
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: constants {
  351. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  352. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  353. // CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete]
  354. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  355. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  356. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  357. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.d59 [concrete]
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: imports {
  361. // CHECK:STDOUT: %Main.I: type = import_ref Main//int_literal, I, loaded [concrete = constants.%I.type]
  362. // CHECK:STDOUT: %Main.C: type = import_ref Main//int_literal, C, loaded [concrete = constants.%C]
  363. // CHECK:STDOUT: %Main.import_ref.bc2: %I.assoc_type = import_ref Main//int_literal, loc5_10, loaded [concrete = constants.%assoc0]
  364. // CHECK:STDOUT: %Main.import_ref.bc3: Core.IntLiteral = import_ref Main//int_literal, loc10_28, loaded [concrete = constants.%int_7]
  365. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.bc3), @C.as.I.impl [concrete]
  366. // CHECK:STDOUT: %Main.import_ref.d59: Core.IntLiteral = import_ref Main//int_literal, loc5_10, loaded [concrete = %val]
  367. // CHECK:STDOUT: %val: Core.IntLiteral = assoc_const_decl @val [concrete] {}
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: fn @F() -> Core.IntLiteral {
  371. // CHECK:STDOUT: !entry:
  372. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  373. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  374. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  375. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  376. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.bc2 [concrete = constants.%assoc0]
  377. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  378. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  379. // CHECK:STDOUT: %impl.elem0: Core.IntLiteral = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%int_7]
  380. // CHECK:STDOUT: return %impl.elem0
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: --- unsigned_uint.carbon
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: constants {
  386. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  387. // CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete]
  388. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  389. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  390. // CHECK:STDOUT: %int_8: %u32 = int_value 8 [concrete]
  391. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  392. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  393. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  394. // CHECK:STDOUT: %assoc0.633: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.830 [concrete]
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: imports {
  398. // CHECK:STDOUT: %Main.I: type = import_ref Main//uint, I, loaded [concrete = constants.%I.type]
  399. // CHECK:STDOUT: %Main.C: type = import_ref Main//uint, C, loaded [concrete = constants.%C]
  400. // CHECK:STDOUT: %Main.import_ref.d18: %I.assoc_type = import_ref Main//uint, loc5_10, loaded [concrete = constants.%assoc0.633]
  401. // CHECK:STDOUT: %Main.import_ref.647: %u32 = import_ref Main//uint, loc10_28, loaded [concrete = constants.%int_8]
  402. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.647), @C.as.I.impl [concrete]
  403. // CHECK:STDOUT: %Main.import_ref.830: %u32 = import_ref Main//uint, loc5_10, loaded [concrete = %val]
  404. // CHECK:STDOUT: %val: %u32 = assoc_const_decl @val [concrete] {}
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT:
  407. // CHECK:STDOUT: fn @F() -> %u32 {
  408. // CHECK:STDOUT: !entry:
  409. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  410. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  411. // CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  412. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  413. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.d18 [concrete = constants.%assoc0.633]
  414. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  415. // CHECK:STDOUT: %.loc7_18: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  416. // CHECK:STDOUT: %impl.elem0: %u32 = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%int_8]
  417. // CHECK:STDOUT: return %impl.elem0
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT: