import.carbon 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/no_prelude/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/no_prelude/import.carbon
  10. // --- package_a.carbon
  11. package PackageA;
  12. interface HasF {
  13. fn F();
  14. }
  15. class C {}
  16. // Same library as the class and interface.
  17. impl C as HasF {
  18. fn F() {}
  19. }
  20. // --- package_b.carbon
  21. package PackageB;
  22. import PackageA;
  23. interface HasG {
  24. fn G();
  25. }
  26. class D {}
  27. // Same library as the interface.
  28. impl PackageA.C as HasG {
  29. fn G() {}
  30. }
  31. // Same library as the class.
  32. impl D as PackageA.HasF {
  33. fn F() {}
  34. }
  35. // Same library as the class and interface.
  36. impl D as HasG {
  37. fn G() {}
  38. }
  39. // --- use.carbon
  40. import PackageA;
  41. import PackageB;
  42. fn TestCF(c: PackageA.C) {
  43. c.(PackageA.HasF.F)();
  44. }
  45. fn TestDF(d: PackageB.D) {
  46. d.(PackageA.HasF.F)();
  47. }
  48. fn TestCG(c: PackageA.C) {
  49. c.(PackageB.HasG.G)();
  50. }
  51. fn TestDG(d: PackageB.D) {
  52. d.(PackageB.HasG.G)();
  53. }
  54. // CHECK:STDOUT: --- package_a.carbon
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: constants {
  57. // CHECK:STDOUT: %HasF.type: type = interface_type @HasF [template]
  58. // CHECK:STDOUT: %Self: %HasF.type = bind_symbolic_name Self, 0 [symbolic]
  59. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  60. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  61. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  62. // CHECK:STDOUT: %.2: type = assoc_entity_type %HasF.type, %F.type.1 [template]
  63. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @HasF.%F.decl [template]
  64. // CHECK:STDOUT: %C: type = class_type @C [template]
  65. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  66. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  67. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  68. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  69. // CHECK:STDOUT: %.6: <witness> = interface_witness (%F.2) [template]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: file {
  73. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  74. // CHECK:STDOUT: .HasF = %HasF.decl
  75. // CHECK:STDOUT: .C = %C.decl
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%HasF.type] {} {}
  78. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  79. // CHECK:STDOUT: impl_decl @impl [template] {} {
  80. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  81. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%HasF.decl [template = constants.%HasF.type]
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: interface @HasF {
  86. // CHECK:STDOUT: %Self: %HasF.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  87. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  88. // CHECK:STDOUT: %.loc5: %.2 = assoc_entity element0, %F.decl [template = constants.%.3]
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: !members:
  91. // CHECK:STDOUT: .Self = %Self
  92. // CHECK:STDOUT: .F = %.loc5
  93. // CHECK:STDOUT: witness = (%F.decl)
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: impl @impl: %C.ref as %HasF.ref {
  97. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
  98. // CHECK:STDOUT: %.loc11: <witness> = interface_witness (%F.decl) [template = constants.%.6]
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: !members:
  101. // CHECK:STDOUT: .F = %F.decl
  102. // CHECK:STDOUT: witness = %.loc11
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: class @C {
  106. // CHECK:STDOUT: %.loc8: <witness> = complete_type_witness %.4 [template = constants.%.5]
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: !members:
  109. // CHECK:STDOUT: .Self = constants.%C
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: generic fn @F.1(@HasF.%Self: %HasF.type) {
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: fn();
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: fn @F.2() {
  118. // CHECK:STDOUT: !entry:
  119. // CHECK:STDOUT: return
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: specific @F.1(constants.%C) {}
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: --- package_b.carbon
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: constants {
  129. // CHECK:STDOUT: %HasG.type: type = interface_type @HasG [template]
  130. // CHECK:STDOUT: %Self.1: %HasG.type = bind_symbolic_name Self, 0 [symbolic]
  131. // CHECK:STDOUT: %G.type.1: type = fn_type @G.1 [template]
  132. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  133. // CHECK:STDOUT: %G.1: %G.type.1 = struct_value () [template]
  134. // CHECK:STDOUT: %.2: type = assoc_entity_type %HasG.type, %G.type.1 [template]
  135. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @HasG.%G.decl [template]
  136. // CHECK:STDOUT: %D: type = class_type @D [template]
  137. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  138. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  139. // CHECK:STDOUT: %C: type = class_type @C [template]
  140. // CHECK:STDOUT: %G.type.2: type = fn_type @G.2 [template]
  141. // CHECK:STDOUT: %G.2: %G.type.2 = struct_value () [template]
  142. // CHECK:STDOUT: %.6: <witness> = interface_witness (%G.2) [template]
  143. // CHECK:STDOUT: %HasF.type: type = interface_type @HasF [template]
  144. // CHECK:STDOUT: %Self.2: %HasF.type = bind_symbolic_name Self, 0 [symbolic]
  145. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  146. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  147. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  148. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  149. // CHECK:STDOUT: %.7: <witness> = interface_witness (%F.1) [template]
  150. // CHECK:STDOUT: %G.type.3: type = fn_type @G.3 [template]
  151. // CHECK:STDOUT: %G.3: %G.type.3 = struct_value () [template]
  152. // CHECK:STDOUT: %.8: <witness> = interface_witness (%G.3) [template]
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: imports {
  156. // CHECK:STDOUT: %PackageA: <namespace> = namespace file.%PackageA.import, [template] {
  157. // CHECK:STDOUT: .C = %import_ref.1
  158. // CHECK:STDOUT: .HasF = %import_ref.3
  159. // CHECK:STDOUT: import PackageA//default
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: %import_ref.1: type = import_ref PackageA//default, inst+12, loaded [template = constants.%C]
  162. // CHECK:STDOUT: %import_ref.2 = import_ref PackageA//default, inst+13, unloaded
  163. // CHECK:STDOUT: %import_ref.3: type = import_ref PackageA//default, inst+1, loaded [template = constants.%HasF.type]
  164. // CHECK:STDOUT: %import_ref.4 = import_ref PackageA//default, inst+3, unloaded
  165. // CHECK:STDOUT: %import_ref.5 = import_ref PackageA//default, inst+10, unloaded
  166. // CHECK:STDOUT: %import_ref.6: %F.type.2 = import_ref PackageA//default, inst+5, loaded [template = constants.%F.2]
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: file {
  170. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  171. // CHECK:STDOUT: .PackageA = imports.%PackageA
  172. // CHECK:STDOUT: .HasG = %HasG.decl
  173. // CHECK:STDOUT: .D = %D.decl
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT: %PackageA.import = import PackageA
  176. // CHECK:STDOUT: %HasG.decl: type = interface_decl @HasG [template = constants.%HasG.type] {} {}
  177. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  178. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  179. // CHECK:STDOUT: %PackageA.ref: <namespace> = name_ref PackageA, imports.%PackageA [template = imports.%PackageA]
  180. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C]
  181. // CHECK:STDOUT: %HasG.ref: type = name_ref HasG, file.%HasG.decl [template = constants.%HasG.type]
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  184. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  185. // CHECK:STDOUT: %PackageA.ref: <namespace> = name_ref PackageA, imports.%PackageA [template = imports.%PackageA]
  186. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.3 [template = constants.%HasF.type]
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT: impl_decl @impl.3 [template] {} {
  189. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  190. // CHECK:STDOUT: %HasG.ref: type = name_ref HasG, file.%HasG.decl [template = constants.%HasG.type]
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: interface @HasG {
  195. // CHECK:STDOUT: %Self: %HasG.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  196. // CHECK:STDOUT: %G.decl: %G.type.1 = fn_decl @G.1 [template = constants.%G.1] {} {}
  197. // CHECK:STDOUT: %.loc7: %.2 = assoc_entity element0, %G.decl [template = constants.%.3]
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: !members:
  200. // CHECK:STDOUT: .Self = %Self
  201. // CHECK:STDOUT: .G = %.loc7
  202. // CHECK:STDOUT: witness = (%G.decl)
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: interface @HasF {
  206. // CHECK:STDOUT: !members:
  207. // CHECK:STDOUT: .Self = imports.%import_ref.4
  208. // CHECK:STDOUT: .F = imports.%import_ref.5
  209. // CHECK:STDOUT: witness = (imports.%import_ref.6)
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: impl @impl.1: %C.ref as %HasG.ref {
  213. // CHECK:STDOUT: %G.decl: %G.type.2 = fn_decl @G.2 [template = constants.%G.2] {} {}
  214. // CHECK:STDOUT: %.loc13: <witness> = interface_witness (%G.decl) [template = constants.%.6]
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: !members:
  217. // CHECK:STDOUT: .G = %G.decl
  218. // CHECK:STDOUT: witness = %.loc13
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: impl @impl.2: %D.ref as %HasF.ref {
  222. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  223. // CHECK:STDOUT: %.loc18: <witness> = interface_witness (%F.decl) [template = constants.%.7]
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: !members:
  226. // CHECK:STDOUT: .F = %F.decl
  227. // CHECK:STDOUT: witness = %.loc18
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: impl @impl.3: %D.ref as %HasG.ref {
  231. // CHECK:STDOUT: %G.decl: %G.type.3 = fn_decl @G.3 [template = constants.%G.3] {} {}
  232. // CHECK:STDOUT: %.loc23: <witness> = interface_witness (%G.decl) [template = constants.%.8]
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: !members:
  235. // CHECK:STDOUT: .G = %G.decl
  236. // CHECK:STDOUT: witness = %.loc23
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: class @D {
  240. // CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %.4 [template = constants.%.5]
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: !members:
  243. // CHECK:STDOUT: .Self = constants.%D
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: class @C {
  247. // CHECK:STDOUT: !members:
  248. // CHECK:STDOUT: .Self = imports.%import_ref.2
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: generic fn @G.1(@HasG.%Self: %HasG.type) {
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: fn();
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: fn @G.2() {
  257. // CHECK:STDOUT: !entry:
  258. // CHECK:STDOUT: return
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: fn @F.1() {
  262. // CHECK:STDOUT: !entry:
  263. // CHECK:STDOUT: return
  264. // CHECK:STDOUT: }
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: generic fn @F.2(constants.%Self.2: %HasF.type) {
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: fn();
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: fn @G.3() {
  272. // CHECK:STDOUT: !entry:
  273. // CHECK:STDOUT: return
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: specific @G.1(constants.%Self.1) {}
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: specific @G.1(constants.%C) {}
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: specific @F.2(constants.%Self.2) {}
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: specific @F.2(constants.%D) {}
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: specific @G.1(constants.%D) {}
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: --- use.carbon
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: constants {
  289. // CHECK:STDOUT: %C: type = class_type @C [template]
  290. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  291. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  292. // CHECK:STDOUT: %TestCF.type: type = fn_type @TestCF [template]
  293. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  294. // CHECK:STDOUT: %TestCF: %TestCF.type = struct_value () [template]
  295. // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
  296. // CHECK:STDOUT: %HasF.type: type = interface_type @HasF [template]
  297. // CHECK:STDOUT: %Self.1: %HasF.type = bind_symbolic_name Self, 0 [symbolic]
  298. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  299. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  300. // CHECK:STDOUT: %.5: type = assoc_entity_type %HasF.type, %F.type.1 [template]
  301. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.7 [template]
  302. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  303. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  304. // CHECK:STDOUT: %.7: <witness> = interface_witness (%F.2) [template]
  305. // CHECK:STDOUT: %D: type = class_type @D [template]
  306. // CHECK:STDOUT: %TestDF.type: type = fn_type @TestDF [template]
  307. // CHECK:STDOUT: %TestDF: %TestDF.type = struct_value () [template]
  308. // CHECK:STDOUT: %HasG.type: type = interface_type @HasG [template]
  309. // CHECK:STDOUT: %Self.2: %HasG.type = bind_symbolic_name Self, 0 [symbolic]
  310. // CHECK:STDOUT: %F.type.3: type = fn_type @F.3 [template]
  311. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  312. // CHECK:STDOUT: %.8: <witness> = interface_witness (%F.3) [template]
  313. // CHECK:STDOUT: %TestCG.type: type = fn_type @TestCG [template]
  314. // CHECK:STDOUT: %TestCG: %TestCG.type = struct_value () [template]
  315. // CHECK:STDOUT: %G.type.1: type = fn_type @G.1 [template]
  316. // CHECK:STDOUT: %G.1: %G.type.1 = struct_value () [template]
  317. // CHECK:STDOUT: %.9: type = assoc_entity_type %HasG.type, %G.type.1 [template]
  318. // CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.26 [template]
  319. // CHECK:STDOUT: %G.type.2: type = fn_type @G.2 [template]
  320. // CHECK:STDOUT: %G.2: %G.type.2 = struct_value () [template]
  321. // CHECK:STDOUT: %.11: <witness> = interface_witness (%G.2) [template]
  322. // CHECK:STDOUT: %TestDG.type: type = fn_type @TestDG [template]
  323. // CHECK:STDOUT: %TestDG: %TestDG.type = struct_value () [template]
  324. // CHECK:STDOUT: %G.type.3: type = fn_type @G.3 [template]
  325. // CHECK:STDOUT: %G.3: %G.type.3 = struct_value () [template]
  326. // CHECK:STDOUT: %.12: <witness> = interface_witness (%G.3) [template]
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: imports {
  330. // CHECK:STDOUT: %PackageA: <namespace> = namespace file.%PackageA.import, [template] {
  331. // CHECK:STDOUT: .C = %import_ref.1
  332. // CHECK:STDOUT: .HasF = %import_ref.3
  333. // CHECK:STDOUT: import PackageA//default
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT: %PackageB: <namespace> = namespace file.%PackageB.import, [template] {
  336. // CHECK:STDOUT: .D = %import_ref.11
  337. // CHECK:STDOUT: .HasG = %import_ref.25
  338. // CHECK:STDOUT: import PackageB//default
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT: %import_ref.1: type = import_ref PackageA//default, inst+12, loaded [template = constants.%C]
  341. // CHECK:STDOUT: %import_ref.2 = import_ref PackageA//default, inst+13, unloaded
  342. // CHECK:STDOUT: %import_ref.3: type = import_ref PackageA//default, inst+1, loaded [template = constants.%HasF.type]
  343. // CHECK:STDOUT: %import_ref.4 = import_ref PackageA//default, inst+3, unloaded
  344. // CHECK:STDOUT: %import_ref.5: %.5 = import_ref PackageA//default, inst+10, loaded [template = constants.%.6]
  345. // CHECK:STDOUT: %import_ref.6 = import_ref PackageA//default, inst+5, unloaded
  346. // CHECK:STDOUT: %import_ref.7 = import_ref PackageA//default, inst+5, unloaded
  347. // CHECK:STDOUT: %import_ref.8: type = import_ref PackageA//default, inst+17, loaded [template = constants.%C]
  348. // CHECK:STDOUT: %import_ref.9: type = import_ref PackageA//default, inst+18, loaded [template = constants.%HasF.type]
  349. // CHECK:STDOUT: %import_ref.10: <witness> = import_ref PackageA//default, inst+23, loaded [template = constants.%.7]
  350. // CHECK:STDOUT: %import_ref.11: type = import_ref PackageB//default, inst+14, loaded [template = constants.%D]
  351. // CHECK:STDOUT: %import_ref.12 = import_ref PackageB//default, inst+15, unloaded
  352. // CHECK:STDOUT: %import_ref.13 = import_ref PackageB//default, inst+5, unloaded
  353. // CHECK:STDOUT: %import_ref.14: %.9 = import_ref PackageB//default, inst+12, loaded [template = constants.%.10]
  354. // CHECK:STDOUT: %import_ref.15 = import_ref PackageB//default, inst+7, unloaded
  355. // CHECK:STDOUT: %import_ref.16: type = import_ref PackageB//default, inst+24, loaded [template = constants.%C]
  356. // CHECK:STDOUT: %import_ref.17: type = import_ref PackageB//default, inst+25, loaded [template = constants.%HasG.type]
  357. // CHECK:STDOUT: %import_ref.18: <witness> = import_ref PackageB//default, inst+30, loaded [template = constants.%.11]
  358. // CHECK:STDOUT: %import_ref.19: type = import_ref PackageB//default, inst+33, loaded [template = constants.%D]
  359. // CHECK:STDOUT: %import_ref.20: type = import_ref PackageB//default, inst+42, loaded [template = constants.%HasF.type]
  360. // CHECK:STDOUT: %import_ref.21: <witness> = import_ref PackageB//default, inst+50, loaded [template = constants.%.8]
  361. // CHECK:STDOUT: %import_ref.22: type = import_ref PackageB//default, inst+53, loaded [template = constants.%D]
  362. // CHECK:STDOUT: %import_ref.23: type = import_ref PackageB//default, inst+54, loaded [template = constants.%HasG.type]
  363. // CHECK:STDOUT: %import_ref.24: <witness> = import_ref PackageB//default, inst+59, loaded [template = constants.%.12]
  364. // CHECK:STDOUT: %import_ref.25: type = import_ref PackageB//default, inst+3, loaded [template = constants.%HasG.type]
  365. // CHECK:STDOUT: %import_ref.26 = import_ref PackageB//default, inst+7, unloaded
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: file {
  369. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  370. // CHECK:STDOUT: .PackageA = imports.%PackageA
  371. // CHECK:STDOUT: .PackageB = imports.%PackageB
  372. // CHECK:STDOUT: .TestCF = %TestCF.decl
  373. // CHECK:STDOUT: .TestDF = %TestDF.decl
  374. // CHECK:STDOUT: .TestCG = %TestCG.decl
  375. // CHECK:STDOUT: .TestDG = %TestDG.decl
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT: %PackageA.import = import PackageA
  378. // CHECK:STDOUT: %PackageB.import = import PackageB
  379. // CHECK:STDOUT: %TestCF.decl: %TestCF.type = fn_decl @TestCF [template = constants.%TestCF] {
  380. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  381. // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, runtime_param0
  382. // CHECK:STDOUT: } {
  383. // CHECK:STDOUT: %PackageA.ref.loc5: <namespace> = name_ref PackageA, imports.%PackageA [template = imports.%PackageA]
  384. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C]
  385. // CHECK:STDOUT: %c.param: %C = value_param runtime_param0
  386. // CHECK:STDOUT: %c: %C = bind_name c, %c.param
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT: %TestDF.decl: %TestDF.type = fn_decl @TestDF [template = constants.%TestDF] {
  389. // CHECK:STDOUT: %d.patt: %D = binding_pattern d
  390. // CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, runtime_param0
  391. // CHECK:STDOUT: } {
  392. // CHECK:STDOUT: %PackageB.ref: <namespace> = name_ref PackageB, imports.%PackageB [template = imports.%PackageB]
  393. // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.11 [template = constants.%D]
  394. // CHECK:STDOUT: %d.param: %D = value_param runtime_param0
  395. // CHECK:STDOUT: %d: %D = bind_name d, %d.param
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT: %TestCG.decl: %TestCG.type = fn_decl @TestCG [template = constants.%TestCG] {
  398. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  399. // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, runtime_param0
  400. // CHECK:STDOUT: } {
  401. // CHECK:STDOUT: %PackageA.ref: <namespace> = name_ref PackageA, imports.%PackageA [template = imports.%PackageA]
  402. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C]
  403. // CHECK:STDOUT: %c.param: %C = value_param runtime_param0
  404. // CHECK:STDOUT: %c: %C = bind_name c, %c.param
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT: %TestDG.decl: %TestDG.type = fn_decl @TestDG [template = constants.%TestDG] {
  407. // CHECK:STDOUT: %d.patt: %D = binding_pattern d
  408. // CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, runtime_param0
  409. // CHECK:STDOUT: } {
  410. // CHECK:STDOUT: %PackageB.ref.loc17: <namespace> = name_ref PackageB, imports.%PackageB [template = imports.%PackageB]
  411. // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.11 [template = constants.%D]
  412. // CHECK:STDOUT: %d.param: %D = value_param runtime_param0
  413. // CHECK:STDOUT: %d: %D = bind_name d, %d.param
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: interface @HasF {
  418. // CHECK:STDOUT: !members:
  419. // CHECK:STDOUT: .Self = imports.%import_ref.4
  420. // CHECK:STDOUT: .F = imports.%import_ref.5
  421. // CHECK:STDOUT: witness = (imports.%import_ref.6)
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: interface @HasG {
  425. // CHECK:STDOUT: !members:
  426. // CHECK:STDOUT: .Self = imports.%import_ref.13
  427. // CHECK:STDOUT: .G = imports.%import_ref.14
  428. // CHECK:STDOUT: witness = (imports.%import_ref.15)
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: impl @impl.1: imports.%import_ref.8 as imports.%import_ref.9 {
  432. // CHECK:STDOUT: !members:
  433. // CHECK:STDOUT: witness = imports.%import_ref.10
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: impl @impl.2: imports.%import_ref.16 as imports.%import_ref.17 {
  437. // CHECK:STDOUT: !members:
  438. // CHECK:STDOUT: witness = imports.%import_ref.18
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: impl @impl.3: imports.%import_ref.19 as imports.%import_ref.20 {
  442. // CHECK:STDOUT: !members:
  443. // CHECK:STDOUT: witness = imports.%import_ref.21
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: impl @impl.4: imports.%import_ref.22 as imports.%import_ref.23 {
  447. // CHECK:STDOUT: !members:
  448. // CHECK:STDOUT: witness = imports.%import_ref.24
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: class @C {
  452. // CHECK:STDOUT: !members:
  453. // CHECK:STDOUT: .Self = imports.%import_ref.2
  454. // CHECK:STDOUT: }
  455. // CHECK:STDOUT:
  456. // CHECK:STDOUT: class @D {
  457. // CHECK:STDOUT: !members:
  458. // CHECK:STDOUT: .Self = imports.%import_ref.12
  459. // CHECK:STDOUT: }
  460. // CHECK:STDOUT:
  461. // CHECK:STDOUT: fn @TestCF(%c.param_patt: %C) {
  462. // CHECK:STDOUT: !entry:
  463. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  464. // CHECK:STDOUT: %PackageA.ref.loc6: <namespace> = name_ref PackageA, imports.%PackageA [template = imports.%PackageA]
  465. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.3 [template = constants.%HasF.type]
  466. // CHECK:STDOUT: %F.ref: %.5 = name_ref F, imports.%import_ref.5 [template = constants.%.6]
  467. // CHECK:STDOUT: %.loc6: %F.type.1 = interface_witness_access constants.%.7, element0 [template = constants.%F.2]
  468. // CHECK:STDOUT: %F.call: init %.3 = call %.loc6()
  469. // CHECK:STDOUT: return
  470. // CHECK:STDOUT: }
  471. // CHECK:STDOUT:
  472. // CHECK:STDOUT: generic fn @F.1(constants.%Self.1: %HasF.type) {
  473. // CHECK:STDOUT:
  474. // CHECK:STDOUT: fn();
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT:
  477. // CHECK:STDOUT: fn @F.2();
  478. // CHECK:STDOUT:
  479. // CHECK:STDOUT: fn @TestDF(%d.param_patt: %D) {
  480. // CHECK:STDOUT: !entry:
  481. // CHECK:STDOUT: %d.ref: %D = name_ref d, %d
  482. // CHECK:STDOUT: %PackageA.ref: <namespace> = name_ref PackageA, imports.%PackageA [template = imports.%PackageA]
  483. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.3 [template = constants.%HasF.type]
  484. // CHECK:STDOUT: %F.ref: %.5 = name_ref F, imports.%import_ref.5 [template = constants.%.6]
  485. // CHECK:STDOUT: %.loc10: %F.type.1 = interface_witness_access constants.%.8, element0 [template = constants.%F.3]
  486. // CHECK:STDOUT: %F.call: init %.3 = call %.loc10()
  487. // CHECK:STDOUT: return
  488. // CHECK:STDOUT: }
  489. // CHECK:STDOUT:
  490. // CHECK:STDOUT: fn @F.3();
  491. // CHECK:STDOUT:
  492. // CHECK:STDOUT: fn @TestCG(%c.param_patt: %C) {
  493. // CHECK:STDOUT: !entry:
  494. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  495. // CHECK:STDOUT: %PackageB.ref: <namespace> = name_ref PackageB, imports.%PackageB [template = imports.%PackageB]
  496. // CHECK:STDOUT: %HasG.ref: type = name_ref HasG, imports.%import_ref.25 [template = constants.%HasG.type]
  497. // CHECK:STDOUT: %G.ref: %.9 = name_ref G, imports.%import_ref.14 [template = constants.%.10]
  498. // CHECK:STDOUT: %.loc14: %G.type.1 = interface_witness_access constants.%.11, element0 [template = constants.%G.2]
  499. // CHECK:STDOUT: %G.call: init %.3 = call %.loc14()
  500. // CHECK:STDOUT: return
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: generic fn @G.1(constants.%Self.2: %HasG.type) {
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: fn();
  506. // CHECK:STDOUT: }
  507. // CHECK:STDOUT:
  508. // CHECK:STDOUT: fn @G.2();
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: fn @TestDG(%d.param_patt: %D) {
  511. // CHECK:STDOUT: !entry:
  512. // CHECK:STDOUT: %d.ref: %D = name_ref d, %d
  513. // CHECK:STDOUT: %PackageB.ref.loc18: <namespace> = name_ref PackageB, imports.%PackageB [template = imports.%PackageB]
  514. // CHECK:STDOUT: %HasG.ref: type = name_ref HasG, imports.%import_ref.25 [template = constants.%HasG.type]
  515. // CHECK:STDOUT: %G.ref: %.9 = name_ref G, imports.%import_ref.14 [template = constants.%.10]
  516. // CHECK:STDOUT: %.loc18: %G.type.1 = interface_witness_access constants.%.12, element0 [template = constants.%G.3]
  517. // CHECK:STDOUT: %G.call: init %.3 = call %.loc18()
  518. // CHECK:STDOUT: return
  519. // CHECK:STDOUT: }
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: fn @G.3();
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: specific @F.1(constants.%Self.1) {}
  524. // CHECK:STDOUT:
  525. // CHECK:STDOUT: specific @G.1(constants.%Self.2) {}
  526. // CHECK:STDOUT: