transitive.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/transitive.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/transitive.carbon
  14. // --- i.carbon
  15. library "[[@TEST_NAME]]";
  16. interface I { fn F[self: Self](); }
  17. // --- c.carbon
  18. library "[[@TEST_NAME]]";
  19. import library "i";
  20. class C {}
  21. impl C as I { fn F[self: Self]() {} }
  22. // --- get.carbon
  23. library "[[@TEST_NAME]]";
  24. import library "c";
  25. fn Get() -> C;
  26. // --- call.carbon
  27. library "[[@TEST_NAME]]";
  28. import library "get";
  29. import library "i";
  30. fn Call() {
  31. // We find C in "get", but should look in "c" instead.
  32. Get().(I.F)();
  33. }
  34. // CHECK:STDOUT: --- i.carbon
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: constants {
  37. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  38. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  39. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  40. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type [symbolic]
  41. // CHECK:STDOUT: %I.F.type: type = fn_type @I.F [concrete]
  42. // CHECK:STDOUT: %I.F: %I.F.type = struct_value () [concrete]
  43. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  44. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.F.decl [concrete]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: imports {
  48. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  49. // CHECK:STDOUT: import Core//prelude
  50. // CHECK:STDOUT: import Core//prelude/...
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: file {
  55. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  56. // CHECK:STDOUT: .Core = imports.%Core
  57. // CHECK:STDOUT: .I = %I.decl
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %Core.import = import Core
  60. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: interface @I {
  64. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  65. // CHECK:STDOUT: %I.F.decl: %I.F.type = fn_decl @I.F [concrete = constants.%I.F] {
  66. // CHECK:STDOUT: %self.patt: @I.F.%pattern_type (%pattern_type) = binding_pattern self [concrete]
  67. // CHECK:STDOUT: %self.param_patt: @I.F.%pattern_type (%pattern_type) = value_param_pattern %self.patt, call_param0 [concrete]
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %self.param: @I.F.%Self.as_type.loc4_26.1 (%Self.as_type) = value_param call_param0
  70. // CHECK:STDOUT: %.loc4_26.1: type = splice_block %.loc4_26.2 [symbolic = %Self.as_type.loc4_26.1 (constants.%Self.as_type)] {
  71. // CHECK:STDOUT: %Self.ref: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self)]
  72. // CHECK:STDOUT: %Self.as_type.loc4_26.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc4_26.1 (constants.%Self.as_type)]
  73. // CHECK:STDOUT: %.loc4_26.2: type = converted %Self.ref, %Self.as_type.loc4_26.2 [symbolic = %Self.as_type.loc4_26.1 (constants.%Self.as_type)]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %self: @I.F.%Self.as_type.loc4_26.1 (%Self.as_type) = bind_name self, %self.param
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.F.decl [concrete = constants.%assoc0]
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !members:
  80. // CHECK:STDOUT: .Self = %Self
  81. // CHECK:STDOUT: .F = %assoc0
  82. // CHECK:STDOUT: witness = (%I.F.decl)
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: generic fn @I.F(@I.%Self: %I.type) {
  86. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  87. // CHECK:STDOUT: %Self.as_type.loc4_26.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc4_26.1 (constants.%Self.as_type)]
  88. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type.loc4_26.1 [symbolic = %pattern_type (constants.%pattern_type)]
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn(%self.param: @I.F.%Self.as_type.loc4_26.1 (%Self.as_type));
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: specific @I.F(constants.%Self) {
  94. // CHECK:STDOUT: %Self => constants.%Self
  95. // CHECK:STDOUT: %Self.as_type.loc4_26.1 => constants.%Self.as_type
  96. // CHECK:STDOUT: %pattern_type => constants.%pattern_type
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: --- c.carbon
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: constants {
  102. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  103. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  104. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  105. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness @C.%Destroy.impl_witness_table [concrete]
  106. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  107. // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete]
  108. // CHECK:STDOUT: %C.as.Destroy.impl.Op.type: type = fn_type @C.as.Destroy.impl.Op [concrete]
  109. // CHECK:STDOUT: %C.as.Destroy.impl.Op: %C.as.Destroy.impl.Op.type = struct_value () [concrete]
  110. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  111. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  112. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  113. // CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic]
  114. // CHECK:STDOUT: %I.F.type: type = fn_type @I.F [concrete]
  115. // CHECK:STDOUT: %I.F: %I.F.type = struct_value () [concrete]
  116. // CHECK:STDOUT: %Self.as_type.b70: type = facet_access_type %Self.826 [symbolic]
  117. // CHECK:STDOUT: %pattern_type.6de: type = pattern_type %Self.as_type.b70 [symbolic]
  118. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness file.%I.impl_witness_table [concrete]
  119. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  120. // CHECK:STDOUT: %C.as.I.impl.F.type: type = fn_type @C.as.I.impl.F [concrete]
  121. // CHECK:STDOUT: %C.as.I.impl.F: %C.as.I.impl.F.type = struct_value () [concrete]
  122. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: imports {
  126. // CHECK:STDOUT: %Main.I: type = import_ref Main//i, I, loaded [concrete = constants.%I.type]
  127. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  128. // CHECK:STDOUT: .Destroy = %Core.Destroy
  129. // CHECK:STDOUT: import Core//prelude
  130. // CHECK:STDOUT: import Core//prelude/...
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  133. // CHECK:STDOUT: %Main.import_ref.e5d = import_ref Main//i, inst19 [no loc], unloaded
  134. // CHECK:STDOUT: %Main.import_ref.507 = import_ref Main//i, loc4_33, unloaded
  135. // CHECK:STDOUT: %Main.F: %I.F.type = import_ref Main//i, F, loaded [concrete = constants.%I.F]
  136. // CHECK:STDOUT: %Main.import_ref.5dd: %I.type = import_ref Main//i, inst19 [no loc], loaded [symbolic = constants.%Self.826]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: file {
  140. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  141. // CHECK:STDOUT: .I = imports.%Main.I
  142. // CHECK:STDOUT: .Core = imports.%Core
  143. // CHECK:STDOUT: .C = %C.decl
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %Core.import = import Core
  146. // CHECK:STDOUT: %default.import = import <none>
  147. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  148. // CHECK:STDOUT: impl_decl @C.as.I.impl [concrete] {} {
  149. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  150. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (@C.as.I.impl.%C.as.I.impl.F.decl), @C.as.I.impl [concrete]
  153. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: interface @I [from "i.carbon"] {
  157. // CHECK:STDOUT: !members:
  158. // CHECK:STDOUT: .Self = imports.%Main.import_ref.e5d
  159. // CHECK:STDOUT: .F = imports.%Main.import_ref.507
  160. // CHECK:STDOUT: witness = (imports.%Main.F)
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: impl @C.as.Destroy.impl: @C.%Self.ref as constants.%Destroy.type {
  164. // CHECK:STDOUT: %C.as.Destroy.impl.Op.decl: %C.as.Destroy.impl.Op.type = fn_decl @C.as.Destroy.impl.Op [concrete = constants.%C.as.Destroy.impl.Op] {
  165. // CHECK:STDOUT: %self.patt: %pattern_type.44a = binding_pattern self [concrete]
  166. // CHECK:STDOUT: %self.param_patt: %pattern_type.44a = value_param_pattern %self.patt, call_param0 [concrete]
  167. // CHECK:STDOUT: %.loc6: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  168. // CHECK:STDOUT: } {
  169. // CHECK:STDOUT: %self.param: %ptr.019 = value_param call_param0
  170. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  171. // CHECK:STDOUT: %self: %ptr.019 = bind_name self, %self.param
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: !members:
  175. // CHECK:STDOUT: .Op = %C.as.Destroy.impl.Op.decl
  176. // CHECK:STDOUT: witness = @C.%Destroy.impl_witness
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: impl @C.as.I.impl: %C.ref as %I.ref {
  180. // CHECK:STDOUT: %C.as.I.impl.F.decl: %C.as.I.impl.F.type = fn_decl @C.as.I.impl.F [concrete = constants.%C.as.I.impl.F] {
  181. // CHECK:STDOUT: %self.patt: %pattern_type.c48 = binding_pattern self [concrete]
  182. // CHECK:STDOUT: %self.param_patt: %pattern_type.c48 = value_param_pattern %self.patt, call_param0 [concrete]
  183. // CHECK:STDOUT: } {
  184. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  185. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @C.as.I.impl.%C.ref [concrete = constants.%C]
  186. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: !members:
  190. // CHECK:STDOUT: .F = %C.as.I.impl.F.decl
  191. // CHECK:STDOUT: witness = file.%I.impl_witness
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: class @C {
  195. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  196. // CHECK:STDOUT: impl_decl @C.as.Destroy.impl [concrete] {} {}
  197. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@C.as.Destroy.impl.%C.as.Destroy.impl.Op.decl), @C.as.Destroy.impl [concrete]
  198. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness]
  199. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  200. // CHECK:STDOUT: complete_type_witness = %complete_type
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: !members:
  203. // CHECK:STDOUT: .Self = constants.%C
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: fn @C.as.Destroy.impl.Op(%self.param: %ptr.019) = "no_op";
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: generic fn @I.F(imports.%Main.import_ref.5dd: %I.type) [from "i.carbon"] {
  209. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.826)]
  210. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type.b70)]
  211. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type [symbolic = %pattern_type (constants.%pattern_type.6de)]
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: fn;
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: fn @C.as.I.impl.F(%self.param: %C) {
  217. // CHECK:STDOUT: !entry:
  218. // CHECK:STDOUT: return
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: specific @I.F(constants.%Self.826) {
  222. // CHECK:STDOUT: %Self => constants.%Self.826
  223. // CHECK:STDOUT: %Self.as_type => constants.%Self.as_type.b70
  224. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.6de
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: specific @I.F(constants.%I.facet) {
  228. // CHECK:STDOUT: %Self => constants.%I.facet
  229. // CHECK:STDOUT: %Self.as_type => constants.%C
  230. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.c48
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: --- get.carbon
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: constants {
  236. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  237. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  238. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  239. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  240. // CHECK:STDOUT: %Get.type: type = fn_type @Get [concrete]
  241. // CHECK:STDOUT: %Get: %Get.type = struct_value () [concrete]
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: imports {
  245. // CHECK:STDOUT: %Main.C: type = import_ref Main//c, C, loaded [concrete = constants.%C]
  246. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  247. // CHECK:STDOUT: import Core//prelude
  248. // CHECK:STDOUT: import Core//prelude/...
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//c, loc6_10, loaded [concrete = constants.%complete_type]
  251. // CHECK:STDOUT: %Main.import_ref.2c4 = import_ref Main//c, inst20 [no loc], unloaded
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: file {
  255. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  256. // CHECK:STDOUT: .C = imports.%Main.C
  257. // CHECK:STDOUT: .Core = imports.%Core
  258. // CHECK:STDOUT: .Get = %Get.decl
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT: %Core.import = import Core
  261. // CHECK:STDOUT: %default.import = import <none>
  262. // CHECK:STDOUT: %Get.decl: %Get.type = fn_decl @Get [concrete = constants.%Get] {
  263. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  264. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  265. // CHECK:STDOUT: } {
  266. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  267. // CHECK:STDOUT: %return.param: ref %C = out_param call_param0
  268. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: class @C [from "c.carbon"] {
  273. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: !members:
  276. // CHECK:STDOUT: .Self = imports.%Main.import_ref.2c4
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: fn @Get() -> %C;
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: --- call.carbon
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: constants {
  284. // CHECK:STDOUT: %Call.type: type = fn_type @Call [concrete]
  285. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  286. // CHECK:STDOUT: %Call: %Call.type = struct_value () [concrete]
  287. // CHECK:STDOUT: %Get.type: type = fn_type @Get [concrete]
  288. // CHECK:STDOUT: %Get: %Get.type = struct_value () [concrete]
  289. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  290. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  291. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  292. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  293. // CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic]
  294. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  295. // CHECK:STDOUT: %assoc0.3f3: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.e03 [concrete]
  296. // CHECK:STDOUT: %I.F.type: type = fn_type @I.F [concrete]
  297. // CHECK:STDOUT: %I.F: %I.F.type = struct_value () [concrete]
  298. // CHECK:STDOUT: %Self.as_type.b70: type = facet_access_type %Self.826 [symbolic]
  299. // CHECK:STDOUT: %pattern_type.6de: type = pattern_type %Self.as_type.b70 [symbolic]
  300. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  301. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  302. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  303. // CHECK:STDOUT: %.1b3: type = fn_type_with_self_type %I.F.type, %I.facet [concrete]
  304. // CHECK:STDOUT: %C.as.I.impl.F.type: type = fn_type @C.as.I.impl.F [concrete]
  305. // CHECK:STDOUT: %C.as.I.impl.F: %C.as.I.impl.F.type = struct_value () [concrete]
  306. // CHECK:STDOUT: %Destroy.impl_witness.0cc: <witness> = impl_witness imports.%Destroy.impl_witness_table.170 [concrete]
  307. // CHECK:STDOUT: %C.as.Destroy.impl.Op.type: type = fn_type @C.as.Destroy.impl.Op [concrete]
  308. // CHECK:STDOUT: %C.as.Destroy.impl.Op: %C.as.Destroy.impl.Op.type = struct_value () [concrete]
  309. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: imports {
  313. // CHECK:STDOUT: %Main.Get: %Get.type = import_ref Main//get, Get, loaded [concrete = constants.%Get]
  314. // CHECK:STDOUT: %Main.I: type = import_ref Main//i, I, loaded [concrete = constants.%I.type]
  315. // CHECK:STDOUT: %Core.ece: <namespace> = namespace file.%Core.import, [concrete] {
  316. // CHECK:STDOUT: .Destroy = %Core.Destroy
  317. // CHECK:STDOUT: import Core//prelude
  318. // CHECK:STDOUT: import Core//prelude/...
  319. // CHECK:STDOUT: }
  320. // CHECK:STDOUT: %Main.import_ref.8db: <witness> = import_ref Main//get, inst23 [indirect], loaded [concrete = constants.%complete_type]
  321. // CHECK:STDOUT: %Main.import_ref.6a9 = import_ref Main//get, inst24 [indirect], unloaded
  322. // CHECK:STDOUT: %Main.import_ref.e5d = import_ref Main//i, inst19 [no loc], unloaded
  323. // CHECK:STDOUT: %Main.import_ref.c44: %I.assoc_type = import_ref Main//i, loc4_33, loaded [concrete = constants.%assoc0.3f3]
  324. // CHECK:STDOUT: %Main.F = import_ref Main//i, F, unloaded
  325. // CHECK:STDOUT: %Main.import_ref.e03: %I.F.type = import_ref Main//i, loc4_33, loaded [concrete = constants.%I.F]
  326. // CHECK:STDOUT: %Main.import_ref.5dd: %I.type = import_ref Main//i, inst19 [no loc], loaded [symbolic = constants.%Self.826]
  327. // CHECK:STDOUT: %Main.import_ref.4c7: <witness> = import_ref Main//c, loc6_9, loaded [concrete = constants.%Destroy.impl_witness.0cc]
  328. // CHECK:STDOUT: %Main.import_ref.0ed: type = import_ref Main//c, loc6_9, loaded [concrete = constants.%C]
  329. // CHECK:STDOUT: %Main.import_ref.cb9: type = import_ref Main//c, inst23 [no loc], loaded [concrete = constants.%Destroy.type]
  330. // CHECK:STDOUT: %Main.import_ref.f0d: <witness> = import_ref Main//c, loc7_13, loaded [concrete = constants.%I.impl_witness]
  331. // CHECK:STDOUT: %Main.import_ref.29a: type = import_ref Main//c, loc7_6, loaded [concrete = constants.%C]
  332. // CHECK:STDOUT: %Main.import_ref.f50: type = import_ref Main//c, loc7_11, loaded [concrete = constants.%I.type]
  333. // CHECK:STDOUT: %Main.import_ref.742: %C.as.I.impl.F.type = import_ref Main//c, loc7_34, loaded [concrete = constants.%C.as.I.impl.F]
  334. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.742), @C.as.I.impl [concrete]
  335. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  336. // CHECK:STDOUT: %Main.import_ref.2e8: %C.as.Destroy.impl.Op.type = import_ref Main//c, loc6_9, loaded [concrete = constants.%C.as.Destroy.impl.Op]
  337. // CHECK:STDOUT: %Destroy.impl_witness_table.170 = impl_witness_table (%Main.import_ref.2e8), @C.as.Destroy.impl [concrete]
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: file {
  341. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  342. // CHECK:STDOUT: .Get = imports.%Main.Get
  343. // CHECK:STDOUT: .I = imports.%Main.I
  344. // CHECK:STDOUT: .Core = imports.%Core.ece
  345. // CHECK:STDOUT: .Call = %Call.decl
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: %Core.import = import Core
  348. // CHECK:STDOUT: %default.import = import <none>
  349. // CHECK:STDOUT: %Call.decl: %Call.type = fn_decl @Call [concrete = constants.%Call] {} {}
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: interface @I [from "i.carbon"] {
  353. // CHECK:STDOUT: !members:
  354. // CHECK:STDOUT: .Self = imports.%Main.import_ref.e5d
  355. // CHECK:STDOUT: .F = imports.%Main.import_ref.c44
  356. // CHECK:STDOUT: witness = (imports.%Main.F)
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: impl @C.as.Destroy.impl: imports.%Main.import_ref.0ed as imports.%Main.import_ref.cb9 [from "c.carbon"] {
  360. // CHECK:STDOUT: !members:
  361. // CHECK:STDOUT: witness = imports.%Main.import_ref.4c7
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: impl @C.as.I.impl: imports.%Main.import_ref.29a as imports.%Main.import_ref.f50 [from "c.carbon"] {
  365. // CHECK:STDOUT: !members:
  366. // CHECK:STDOUT: witness = imports.%Main.import_ref.f0d
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT:
  369. // CHECK:STDOUT: class @C [from "get.carbon"] {
  370. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8db
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: !members:
  373. // CHECK:STDOUT: .Self = imports.%Main.import_ref.6a9
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: fn @Call() {
  377. // CHECK:STDOUT: !entry:
  378. // CHECK:STDOUT: %Get.ref: %Get.type = name_ref Get, imports.%Main.Get [concrete = constants.%Get]
  379. // CHECK:STDOUT: %.loc9_7.1: ref %C = temporary_storage
  380. // CHECK:STDOUT: %Get.call: init %C = call %Get.ref() to %.loc9_7.1
  381. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  382. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, imports.%Main.import_ref.c44 [concrete = constants.%assoc0.3f3]
  383. // CHECK:STDOUT: %impl.elem0: %.1b3 = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%C.as.I.impl.F]
  384. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %Get.call, %impl.elem0
  385. // CHECK:STDOUT: %.loc9_7.2: ref %C = temporary %.loc9_7.1, %Get.call
  386. // CHECK:STDOUT: %.loc9_7.3: %C = bind_value %.loc9_7.2
  387. // CHECK:STDOUT: %C.as.I.impl.F.call: init %empty_tuple.type = call %bound_method(%.loc9_7.3)
  388. // CHECK:STDOUT: %C.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc9_7.1, constants.%C.as.Destroy.impl.Op
  389. // CHECK:STDOUT: %addr: %ptr.019 = addr_of %.loc9_7.1
  390. // CHECK:STDOUT: %C.as.Destroy.impl.Op.call: init %empty_tuple.type = call %C.as.Destroy.impl.Op.bound(%addr)
  391. // CHECK:STDOUT: return
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: fn @Get [from "get.carbon"];
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: generic fn @I.F(imports.%Main.import_ref.5dd: %I.type) [from "i.carbon"] {
  397. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.826)]
  398. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type.b70)]
  399. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type [symbolic = %pattern_type (constants.%pattern_type.6de)]
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: fn;
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: fn @C.as.I.impl.F [from "c.carbon"];
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: fn @C.as.Destroy.impl.Op = "no_op" [from "c.carbon"];
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: specific @I.F(constants.%Self.826) {
  409. // CHECK:STDOUT: %Self => constants.%Self.826
  410. // CHECK:STDOUT: %Self.as_type => constants.%Self.as_type.b70
  411. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.6de
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT: