import.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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/class/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/import.carbon
  10. // --- a.carbon
  11. library "[[@TEST_NAME]]";
  12. class Empty {
  13. }
  14. class Field {
  15. var x: i32;
  16. }
  17. class ForwardDeclared;
  18. class ForwardDeclared {
  19. fn F[self: Self]();
  20. fn G[addr self: Self*]();
  21. }
  22. class Incomplete;
  23. // --- b.carbon
  24. library "[[@TEST_NAME]]";
  25. import library "a";
  26. fn Run() {
  27. var a: Empty = {};
  28. var b: Field = {.x = 1};
  29. b.x = 2;
  30. var c: ForwardDeclared = {};
  31. c.F();
  32. c.G();
  33. var d: ForwardDeclared* = &c;
  34. var e: Incomplete*;
  35. }
  36. // CHECK:STDOUT: --- a.carbon
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: constants {
  39. // CHECK:STDOUT: %Empty: type = class_type @Empty [template]
  40. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  41. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  42. // CHECK:STDOUT: %Field: type = class_type @Field [template]
  43. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  44. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  45. // CHECK:STDOUT: %Field.elem: type = unbound_element_type %Field, %i32 [template]
  46. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %i32} [template]
  47. // CHECK:STDOUT: %complete_type.1ec: <witness> = complete_type_witness %struct_type.x [template]
  48. // CHECK:STDOUT: %ForwardDeclared: type = class_type @ForwardDeclared [template]
  49. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  50. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  51. // CHECK:STDOUT: %ptr: type = ptr_type %ForwardDeclared [template]
  52. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  53. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  54. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: imports {
  58. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  59. // CHECK:STDOUT: .Int = %Core.Int
  60. // CHECK:STDOUT: import Core//prelude
  61. // CHECK:STDOUT: import Core//prelude/...
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: file {
  66. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  67. // CHECK:STDOUT: .Core = imports.%Core
  68. // CHECK:STDOUT: .Empty = %Empty.decl
  69. // CHECK:STDOUT: .Field = %Field.decl
  70. // CHECK:STDOUT: .ForwardDeclared = %ForwardDeclared.decl.loc11
  71. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %Core.import = import Core
  74. // CHECK:STDOUT: %Empty.decl: type = class_decl @Empty [template = constants.%Empty] {} {}
  75. // CHECK:STDOUT: %Field.decl: type = class_decl @Field [template = constants.%Field] {} {}
  76. // CHECK:STDOUT: %ForwardDeclared.decl.loc11: type = class_decl @ForwardDeclared [template = constants.%ForwardDeclared] {} {}
  77. // CHECK:STDOUT: %ForwardDeclared.decl.loc13: type = class_decl @ForwardDeclared [template = constants.%ForwardDeclared] {} {}
  78. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} {}
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: class @Empty {
  82. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  83. // CHECK:STDOUT: complete_type_witness = %complete_type
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: !members:
  86. // CHECK:STDOUT: .Self = constants.%Empty
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: class @Field {
  90. // CHECK:STDOUT: %.loc8_8: %Field.elem = field_decl x, element0 [template]
  91. // CHECK:STDOUT: name_binding_decl {
  92. // CHECK:STDOUT: %.loc8_3: %Field.elem = var_pattern %.loc8_8
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %.var: ref %Field.elem = var <none>
  95. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [template = constants.%complete_type.1ec]
  96. // CHECK:STDOUT: complete_type_witness = %complete_type
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: !members:
  99. // CHECK:STDOUT: .Self = constants.%Field
  100. // CHECK:STDOUT: .x = %.loc8_8
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: class @ForwardDeclared {
  104. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  105. // CHECK:STDOUT: %self.patt: %ForwardDeclared = binding_pattern self
  106. // CHECK:STDOUT: %self.param_patt: %ForwardDeclared = value_param_pattern %self.patt, runtime_param0
  107. // CHECK:STDOUT: } {
  108. // CHECK:STDOUT: %self.param: %ForwardDeclared = value_param runtime_param0
  109. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%ForwardDeclared [template = constants.%ForwardDeclared]
  110. // CHECK:STDOUT: %self: %ForwardDeclared = bind_name self, %self.param
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  113. // CHECK:STDOUT: %self.patt: %ptr = binding_pattern self
  114. // CHECK:STDOUT: %self.param_patt: %ptr = value_param_pattern %self.patt, runtime_param0
  115. // CHECK:STDOUT: %.loc15_8: auto = addr_pattern %self.param_patt
  116. // CHECK:STDOUT: } {
  117. // CHECK:STDOUT: %self.param: %ptr = value_param runtime_param0
  118. // CHECK:STDOUT: %.loc15_23: type = splice_block %ptr [template = constants.%ptr] {
  119. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%ForwardDeclared [template = constants.%ForwardDeclared]
  120. // CHECK:STDOUT: %ptr: type = ptr_type %ForwardDeclared [template = constants.%ptr]
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT: %self: %ptr = bind_name self, %self.param
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  125. // CHECK:STDOUT: complete_type_witness = %complete_type
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: !members:
  128. // CHECK:STDOUT: .Self = constants.%ForwardDeclared
  129. // CHECK:STDOUT: .F = %F.decl
  130. // CHECK:STDOUT: .G = %G.decl
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: class @Incomplete;
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: fn @F[%self.param_patt: %ForwardDeclared]();
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: fn @G[addr %self.param_patt: %ptr]();
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: --- b.carbon
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: constants {
  142. // CHECK:STDOUT: %Run.type: type = fn_type @Run [template]
  143. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  144. // CHECK:STDOUT: %Run: %Run.type = struct_value () [template]
  145. // CHECK:STDOUT: %Empty: type = class_type @Empty [template]
  146. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  147. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  148. // CHECK:STDOUT: %Empty.val: %Empty = struct_value () [template]
  149. // CHECK:STDOUT: %Field: type = class_type @Field [template]
  150. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  151. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  152. // CHECK:STDOUT: %struct_type.x.767: type = struct_type {.x: %i32} [template]
  153. // CHECK:STDOUT: %complete_type.c07: <witness> = complete_type_witness %struct_type.x.767 [template]
  154. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  155. // CHECK:STDOUT: %struct_type.x.c96: type = struct_type {.x: Core.IntLiteral} [template]
  156. // CHECK:STDOUT: %ImplicitAs.type.9ba: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  157. // CHECK:STDOUT: %Convert.type.6da: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  158. // CHECK:STDOUT: %impl_witness.b97: <witness> = impl_witness (imports.%Core.import_ref.a86), @impl.1(%int_32) [template]
  159. // CHECK:STDOUT: %Convert.type.ed5: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  160. // CHECK:STDOUT: %Convert.16d: %Convert.type.ed5 = struct_value () [template]
  161. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.9ba = facet_value Core.IntLiteral, %impl_witness.b97 [template]
  162. // CHECK:STDOUT: %.39b: type = fn_type_with_self_type %Convert.type.6da, %ImplicitAs.facet [template]
  163. // CHECK:STDOUT: %Convert.bound.43e: <bound method> = bound_method %int_1.5b8, %Convert.16d [template]
  164. // CHECK:STDOUT: %Convert.specific_fn.c37: <specific function> = specific_function %Convert.bound.43e, @Convert.2(%int_32) [template]
  165. // CHECK:STDOUT: %int_1.47b: %i32 = int_value 1 [template]
  166. // CHECK:STDOUT: %Field.val: %Field = struct_value (%int_1.47b) [template]
  167. // CHECK:STDOUT: %Field.elem: type = unbound_element_type %Field, %i32 [template]
  168. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template]
  169. // CHECK:STDOUT: %Convert.bound.918: <bound method> = bound_method %int_2.ecc, %Convert.16d [template]
  170. // CHECK:STDOUT: %Convert.specific_fn.5a4: <specific function> = specific_function %Convert.bound.918, @Convert.2(%int_32) [template]
  171. // CHECK:STDOUT: %int_2.d0d: %i32 = int_value 2 [template]
  172. // CHECK:STDOUT: %ForwardDeclared.7b34f2.1: type = class_type @ForwardDeclared.1 [template]
  173. // CHECK:STDOUT: %ForwardDeclared.val: %ForwardDeclared.7b34f2.1 = struct_value () [template]
  174. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  175. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  176. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  177. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  178. // CHECK:STDOUT: %ptr.6cf: type = ptr_type %ForwardDeclared.7b34f2.1 [template]
  179. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  180. // CHECK:STDOUT: %ptr.c62: type = ptr_type %Incomplete [template]
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: imports {
  184. // CHECK:STDOUT: %Main.Empty: type = import_ref Main//a, Empty, loaded [template = constants.%Empty]
  185. // CHECK:STDOUT: %Main.Field: type = import_ref Main//a, Field, loaded [template = constants.%Field]
  186. // CHECK:STDOUT: %Main.ForwardDeclared: type = import_ref Main//a, ForwardDeclared, loaded [template = constants.%ForwardDeclared.7b34f2.1]
  187. // CHECK:STDOUT: %Main.Incomplete: type = import_ref Main//a, Incomplete, loaded [template = constants.%Incomplete]
  188. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  189. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  190. // CHECK:STDOUT: import Core//prelude
  191. // CHECK:STDOUT: import Core//prelude/...
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT: %Main.import_ref.8f24d3.1: <witness> = import_ref Main//a, loc5_1, loaded [template = constants.%complete_type.357]
  194. // CHECK:STDOUT: %Main.import_ref.fd7 = import_ref Main//a, inst16 [no loc], unloaded
  195. // CHECK:STDOUT: %Main.import_ref.709: <witness> = import_ref Main//a, loc9_1, loaded [template = constants.%complete_type.c07]
  196. // CHECK:STDOUT: %Main.import_ref.845 = import_ref Main//a, inst21 [no loc], unloaded
  197. // CHECK:STDOUT: %Main.import_ref.4d2: %Field.elem = import_ref Main//a, loc8_8, loaded [template = %.d33]
  198. // CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//a, loc16_1, loaded [template = constants.%complete_type.357]
  199. // CHECK:STDOUT: %Main.import_ref.39e731.1 = import_ref Main//a, inst60 [no loc], unloaded
  200. // CHECK:STDOUT: %Main.import_ref.760: %F.type = import_ref Main//a, loc14_21, loaded [template = constants.%F]
  201. // CHECK:STDOUT: %Main.import_ref.26e: %G.type = import_ref Main//a, loc15_27, loaded [template = constants.%G]
  202. // CHECK:STDOUT: %Main.import_ref.8f24d3.3: <witness> = import_ref Main//a, loc16_1, loaded [template = constants.%complete_type.357]
  203. // CHECK:STDOUT: %Main.import_ref.39e731.2 = import_ref Main//a, inst60 [no loc], unloaded
  204. // CHECK:STDOUT: %Main.import_ref.42a = import_ref Main//a, loc14_21, unloaded
  205. // CHECK:STDOUT: %Main.import_ref.67a = import_ref Main//a, loc15_27, unloaded
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: file {
  209. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  210. // CHECK:STDOUT: .Empty = imports.%Main.Empty
  211. // CHECK:STDOUT: .Field = imports.%Main.Field
  212. // CHECK:STDOUT: .ForwardDeclared = imports.%Main.ForwardDeclared
  213. // CHECK:STDOUT: .Incomplete = imports.%Main.Incomplete
  214. // CHECK:STDOUT: .Core = imports.%Core
  215. // CHECK:STDOUT: .Run = %Run.decl
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT: %Core.import = import Core
  218. // CHECK:STDOUT: %default.import = import <none>
  219. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} {}
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: class @Empty [from "a.carbon"] {
  223. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.1
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: !members:
  226. // CHECK:STDOUT: .Self = imports.%Main.import_ref.fd7
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: class @Field [from "a.carbon"] {
  230. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.709
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: !members:
  233. // CHECK:STDOUT: .Self = imports.%Main.import_ref.845
  234. // CHECK:STDOUT: .x = imports.%Main.import_ref.4d2
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: class @ForwardDeclared.1 [from "a.carbon"] {
  238. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.2
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: !members:
  241. // CHECK:STDOUT: .Self = imports.%Main.import_ref.39e731.1
  242. // CHECK:STDOUT: .F = imports.%Main.import_ref.760
  243. // CHECK:STDOUT: .G = imports.%Main.import_ref.26e
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: class @ForwardDeclared.2 [from "a.carbon"] {
  247. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f24d3.3
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: !members:
  250. // CHECK:STDOUT: .Self = imports.%Main.import_ref.39e731.2
  251. // CHECK:STDOUT: .F = imports.%Main.import_ref.42a
  252. // CHECK:STDOUT: .G = imports.%Main.import_ref.67a
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: class @Incomplete [from "a.carbon"];
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: fn @Run() {
  258. // CHECK:STDOUT: !entry:
  259. // CHECK:STDOUT: name_binding_decl {
  260. // CHECK:STDOUT: %a.patt: %Empty = binding_pattern a
  261. // CHECK:STDOUT: %.loc7_3.1: %Empty = var_pattern %a.patt
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT: %a.var: ref %Empty = var a
  264. // CHECK:STDOUT: %.loc7_19.1: %empty_struct_type = struct_literal ()
  265. // CHECK:STDOUT: %.loc7_19.2: init %Empty = class_init (), %a.var [template = constants.%Empty.val]
  266. // CHECK:STDOUT: %.loc7_3.2: init %Empty = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%Empty.val]
  267. // CHECK:STDOUT: assign %a.var, %.loc7_3.2
  268. // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, imports.%Main.Empty [template = constants.%Empty]
  269. // CHECK:STDOUT: %a: ref %Empty = bind_name a, %a.var
  270. // CHECK:STDOUT: name_binding_decl {
  271. // CHECK:STDOUT: %b.patt: %Field = binding_pattern b
  272. // CHECK:STDOUT: %.loc9_3.1: %Field = var_pattern %b.patt
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT: %b.var: ref %Field = var b
  275. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  276. // CHECK:STDOUT: %.loc9_25.1: %struct_type.x.c96 = struct_literal (%int_1)
  277. // CHECK:STDOUT: %impl.elem0.loc9: %.39b = impl_witness_access constants.%impl_witness.b97, element0 [template = constants.%Convert.16d]
  278. // CHECK:STDOUT: %bound_method.loc9: <bound method> = bound_method %int_1, %impl.elem0.loc9 [template = constants.%Convert.bound.43e]
  279. // CHECK:STDOUT: %specific_fn.loc9: <specific function> = specific_function %bound_method.loc9, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.c37]
  280. // CHECK:STDOUT: %int.convert_checked.loc9: init %i32 = call %specific_fn.loc9(%int_1) [template = constants.%int_1.47b]
  281. // CHECK:STDOUT: %.loc9_25.2: init %i32 = converted %int_1, %int.convert_checked.loc9 [template = constants.%int_1.47b]
  282. // CHECK:STDOUT: %.loc9_25.3: ref %i32 = class_element_access %b.var, element0
  283. // CHECK:STDOUT: %.loc9_25.4: init %i32 = initialize_from %.loc9_25.2 to %.loc9_25.3 [template = constants.%int_1.47b]
  284. // CHECK:STDOUT: %.loc9_25.5: init %Field = class_init (%.loc9_25.4), %b.var [template = constants.%Field.val]
  285. // CHECK:STDOUT: %.loc9_3.2: init %Field = converted %.loc9_25.1, %.loc9_25.5 [template = constants.%Field.val]
  286. // CHECK:STDOUT: assign %b.var, %.loc9_3.2
  287. // CHECK:STDOUT: %Field.ref: type = name_ref Field, imports.%Main.Field [template = constants.%Field]
  288. // CHECK:STDOUT: %b: ref %Field = bind_name b, %b.var
  289. // CHECK:STDOUT: %b.ref: ref %Field = name_ref b, %b
  290. // CHECK:STDOUT: %x.ref: %Field.elem = name_ref x, imports.%Main.import_ref.4d2 [template = imports.%.d33]
  291. // CHECK:STDOUT: %.loc10_4: ref %i32 = class_element_access %b.ref, element0
  292. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  293. // CHECK:STDOUT: %impl.elem0.loc10: %.39b = impl_witness_access constants.%impl_witness.b97, element0 [template = constants.%Convert.16d]
  294. // CHECK:STDOUT: %bound_method.loc10: <bound method> = bound_method %int_2, %impl.elem0.loc10 [template = constants.%Convert.bound.918]
  295. // CHECK:STDOUT: %specific_fn.loc10: <specific function> = specific_function %bound_method.loc10, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.5a4]
  296. // CHECK:STDOUT: %int.convert_checked.loc10: init %i32 = call %specific_fn.loc10(%int_2) [template = constants.%int_2.d0d]
  297. // CHECK:STDOUT: %.loc10_7: init %i32 = converted %int_2, %int.convert_checked.loc10 [template = constants.%int_2.d0d]
  298. // CHECK:STDOUT: assign %.loc10_4, %.loc10_7
  299. // CHECK:STDOUT: name_binding_decl {
  300. // CHECK:STDOUT: %c.patt: %ForwardDeclared.7b34f2.1 = binding_pattern c
  301. // CHECK:STDOUT: %.loc12_3.1: %ForwardDeclared.7b34f2.1 = var_pattern %c.patt
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %c.var: ref %ForwardDeclared.7b34f2.1 = var c
  304. // CHECK:STDOUT: %.loc12_29.1: %empty_struct_type = struct_literal ()
  305. // CHECK:STDOUT: %.loc12_29.2: init %ForwardDeclared.7b34f2.1 = class_init (), %c.var [template = constants.%ForwardDeclared.val]
  306. // CHECK:STDOUT: %.loc12_3.2: init %ForwardDeclared.7b34f2.1 = converted %.loc12_29.1, %.loc12_29.2 [template = constants.%ForwardDeclared.val]
  307. // CHECK:STDOUT: assign %c.var, %.loc12_3.2
  308. // CHECK:STDOUT: %ForwardDeclared.ref.loc12: type = name_ref ForwardDeclared, imports.%Main.ForwardDeclared [template = constants.%ForwardDeclared.7b34f2.1]
  309. // CHECK:STDOUT: %c: ref %ForwardDeclared.7b34f2.1 = bind_name c, %c.var
  310. // CHECK:STDOUT: %c.ref.loc13: ref %ForwardDeclared.7b34f2.1 = name_ref c, %c
  311. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.import_ref.760 [template = constants.%F]
  312. // CHECK:STDOUT: %F.bound: <bound method> = bound_method %c.ref.loc13, %F.ref
  313. // CHECK:STDOUT: %.loc13: %ForwardDeclared.7b34f2.1 = bind_value %c.ref.loc13
  314. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.bound(%.loc13)
  315. // CHECK:STDOUT: %c.ref.loc14: ref %ForwardDeclared.7b34f2.1 = name_ref c, %c
  316. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, imports.%Main.import_ref.26e [template = constants.%G]
  317. // CHECK:STDOUT: %G.bound: <bound method> = bound_method %c.ref.loc14, %G.ref
  318. // CHECK:STDOUT: %addr.loc14: %ptr.6cf = addr_of %c.ref.loc14
  319. // CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.bound(%addr.loc14)
  320. // CHECK:STDOUT: name_binding_decl {
  321. // CHECK:STDOUT: %d.patt: %ptr.6cf = binding_pattern d
  322. // CHECK:STDOUT: %.loc16_3: %ptr.6cf = var_pattern %d.patt
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT: %d.var: ref %ptr.6cf = var d
  325. // CHECK:STDOUT: %c.ref.loc16: ref %ForwardDeclared.7b34f2.1 = name_ref c, %c
  326. // CHECK:STDOUT: %addr.loc16: %ptr.6cf = addr_of %c.ref.loc16
  327. // CHECK:STDOUT: assign %d.var, %addr.loc16
  328. // CHECK:STDOUT: %.loc16_25: type = splice_block %ptr.loc16 [template = constants.%ptr.6cf] {
  329. // CHECK:STDOUT: %ForwardDeclared.ref.loc16: type = name_ref ForwardDeclared, imports.%Main.ForwardDeclared [template = constants.%ForwardDeclared.7b34f2.1]
  330. // CHECK:STDOUT: %ptr.loc16: type = ptr_type %ForwardDeclared.7b34f2.1 [template = constants.%ptr.6cf]
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT: %d: ref %ptr.6cf = bind_name d, %d.var
  333. // CHECK:STDOUT: name_binding_decl {
  334. // CHECK:STDOUT: %e.patt: %ptr.c62 = binding_pattern e
  335. // CHECK:STDOUT: %.loc18_3: %ptr.c62 = var_pattern %e.patt
  336. // CHECK:STDOUT: }
  337. // CHECK:STDOUT: %e.var: ref %ptr.c62 = var e
  338. // CHECK:STDOUT: %.loc18_20: type = splice_block %ptr.loc18 [template = constants.%ptr.c62] {
  339. // CHECK:STDOUT: %Incomplete.ref: type = name_ref Incomplete, imports.%Main.Incomplete [template = constants.%Incomplete]
  340. // CHECK:STDOUT: %ptr.loc18: type = ptr_type %Incomplete [template = constants.%ptr.c62]
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT: %e: ref %ptr.c62 = bind_name e, %e.var
  343. // CHECK:STDOUT: return
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: fn @F[%self.param_patt: %ForwardDeclared.7b34f2.1]() [from "a.carbon"];
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: fn @G[addr <unexpected>.inst1129: %ptr.6cf]() [from "a.carbon"];
  349. // CHECK:STDOUT: