base_method_qualified.carbon 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/base_method_qualified.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/base_method_qualified.carbon
  13. class Derived;
  14. base class Base {
  15. fn F[self: Self]() -> i32;
  16. fn G[self: Derived]() -> i32;
  17. }
  18. class Derived {
  19. extend base: Base;
  20. fn F[self: Self]();
  21. fn G[self: Self]();
  22. }
  23. fn Call(a: Derived) -> i32 {
  24. return a.(Base.F)();
  25. }
  26. fn CallIndirect(p: Derived*) -> i32 {
  27. return p->(Base.F)();
  28. }
  29. fn PassDerivedToBase(a: Derived) -> i32 {
  30. return a.(Base.G)();
  31. }
  32. fn PassDerivedToBaseIndirect(p: Derived*) -> i32 {
  33. return p->(Base.G)();
  34. }
  35. // CHECK:STDOUT: --- base_method_qualified.carbon
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: constants {
  38. // CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
  39. // CHECK:STDOUT: %Base: type = class_type @Base [concrete]
  40. // CHECK:STDOUT: %pattern_type.bcc: type = pattern_type %Base [concrete]
  41. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  42. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  43. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  44. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  45. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  46. // CHECK:STDOUT: %F.type.7c6: type = fn_type @F.1 [concrete]
  47. // CHECK:STDOUT: %F.d17: %F.type.7c6 = struct_value () [concrete]
  48. // CHECK:STDOUT: %pattern_type.fb9: type = pattern_type %Derived [concrete]
  49. // CHECK:STDOUT: %G.type.6ee: type = fn_type @G.1 [concrete]
  50. // CHECK:STDOUT: %G.663: %G.type.6ee = struct_value () [concrete]
  51. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  52. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  53. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [concrete]
  54. // CHECK:STDOUT: %F.type.5da: type = fn_type @F.2 [concrete]
  55. // CHECK:STDOUT: %F.fa3: %F.type.5da = struct_value () [concrete]
  56. // CHECK:STDOUT: %G.type.04c: type = fn_type @G.2 [concrete]
  57. // CHECK:STDOUT: %G.07e: %G.type.04c = struct_value () [concrete]
  58. // CHECK:STDOUT: %struct_type.base.b1e: type = struct_type {.base: %Base} [concrete]
  59. // CHECK:STDOUT: %complete_type.15c: <witness> = complete_type_witness %struct_type.base.b1e [concrete]
  60. // CHECK:STDOUT: %Call.type: type = fn_type @Call [concrete]
  61. // CHECK:STDOUT: %Call: %Call.type = struct_value () [concrete]
  62. // CHECK:STDOUT: %ptr.404: type = ptr_type %Derived [concrete]
  63. // CHECK:STDOUT: %pattern_type.605: type = pattern_type %ptr.404 [concrete]
  64. // CHECK:STDOUT: %CallIndirect.type: type = fn_type @CallIndirect [concrete]
  65. // CHECK:STDOUT: %CallIndirect: %CallIndirect.type = struct_value () [concrete]
  66. // CHECK:STDOUT: %PassDerivedToBase.type: type = fn_type @PassDerivedToBase [concrete]
  67. // CHECK:STDOUT: %PassDerivedToBase: %PassDerivedToBase.type = struct_value () [concrete]
  68. // CHECK:STDOUT: %PassDerivedToBaseIndirect.type: type = fn_type @PassDerivedToBaseIndirect [concrete]
  69. // CHECK:STDOUT: %PassDerivedToBaseIndirect: %PassDerivedToBaseIndirect.type = struct_value () [concrete]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: imports {
  73. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  74. // CHECK:STDOUT: .Int = %Core.Int
  75. // CHECK:STDOUT: import Core//prelude
  76. // CHECK:STDOUT: import Core//prelude/...
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: file {
  82. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  83. // CHECK:STDOUT: .Core = imports.%Core
  84. // CHECK:STDOUT: .Derived = %Derived.decl.loc14
  85. // CHECK:STDOUT: .Base = %Base.decl
  86. // CHECK:STDOUT: .Call = %Call.decl
  87. // CHECK:STDOUT: .CallIndirect = %CallIndirect.decl
  88. // CHECK:STDOUT: .PassDerivedToBase = %PassDerivedToBase.decl
  89. // CHECK:STDOUT: .PassDerivedToBaseIndirect = %PassDerivedToBaseIndirect.decl
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: %Core.import = import Core
  92. // CHECK:STDOUT: %Derived.decl.loc14: type = class_decl @Derived [concrete = constants.%Derived] {} {}
  93. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
  94. // CHECK:STDOUT: %Derived.decl.loc21: type = class_decl @Derived [concrete = constants.%Derived] {} {}
  95. // CHECK:STDOUT: %Call.decl: %Call.type = fn_decl @Call [concrete = constants.%Call] {
  96. // CHECK:STDOUT: %a.patt: %pattern_type.fb9 = binding_pattern a [concrete]
  97. // CHECK:STDOUT: %a.param_patt: %pattern_type.fb9 = value_param_pattern %a.patt, call_param0 [concrete]
  98. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  99. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  100. // CHECK:STDOUT: } {
  101. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  102. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  103. // CHECK:STDOUT: %a.param: %Derived = value_param call_param0
  104. // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl.loc14 [concrete = constants.%Derived]
  105. // CHECK:STDOUT: %a: %Derived = bind_name a, %a.param
  106. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  107. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT: %CallIndirect.decl: %CallIndirect.type = fn_decl @CallIndirect [concrete = constants.%CallIndirect] {
  110. // CHECK:STDOUT: %p.patt: %pattern_type.605 = binding_pattern p [concrete]
  111. // CHECK:STDOUT: %p.param_patt: %pattern_type.605 = value_param_pattern %p.patt, call_param0 [concrete]
  112. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  113. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  114. // CHECK:STDOUT: } {
  115. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  116. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  117. // CHECK:STDOUT: %p.param: %ptr.404 = value_param call_param0
  118. // CHECK:STDOUT: %.loc32: type = splice_block %ptr [concrete = constants.%ptr.404] {
  119. // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl.loc14 [concrete = constants.%Derived]
  120. // CHECK:STDOUT: %ptr: type = ptr_type %Derived.ref [concrete = constants.%ptr.404]
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT: %p: %ptr.404 = bind_name p, %p.param
  123. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  124. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: %PassDerivedToBase.decl: %PassDerivedToBase.type = fn_decl @PassDerivedToBase [concrete = constants.%PassDerivedToBase] {
  127. // CHECK:STDOUT: %a.patt: %pattern_type.fb9 = binding_pattern a [concrete]
  128. // CHECK:STDOUT: %a.param_patt: %pattern_type.fb9 = value_param_pattern %a.patt, call_param0 [concrete]
  129. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  130. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  131. // CHECK:STDOUT: } {
  132. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  133. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  134. // CHECK:STDOUT: %a.param: %Derived = value_param call_param0
  135. // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl.loc14 [concrete = constants.%Derived]
  136. // CHECK:STDOUT: %a: %Derived = bind_name a, %a.param
  137. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  138. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT: %PassDerivedToBaseIndirect.decl: %PassDerivedToBaseIndirect.type = fn_decl @PassDerivedToBaseIndirect [concrete = constants.%PassDerivedToBaseIndirect] {
  141. // CHECK:STDOUT: %p.patt: %pattern_type.605 = binding_pattern p [concrete]
  142. // CHECK:STDOUT: %p.param_patt: %pattern_type.605 = value_param_pattern %p.patt, call_param0 [concrete]
  143. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  144. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  145. // CHECK:STDOUT: } {
  146. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  147. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  148. // CHECK:STDOUT: %p.param: %ptr.404 = value_param call_param0
  149. // CHECK:STDOUT: %.loc40: type = splice_block %ptr [concrete = constants.%ptr.404] {
  150. // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl.loc14 [concrete = constants.%Derived]
  151. // CHECK:STDOUT: %ptr: type = ptr_type %Derived.ref [concrete = constants.%ptr.404]
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: %p: %ptr.404 = bind_name p, %p.param
  154. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  155. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: class @Derived {
  160. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  161. // CHECK:STDOUT: %.loc22: %Derived.elem = base_decl %Base.ref, element0 [concrete]
  162. // CHECK:STDOUT: %F.decl: %F.type.5da = fn_decl @F.2 [concrete = constants.%F.fa3] {
  163. // CHECK:STDOUT: %self.patt: %pattern_type.fb9 = binding_pattern self [concrete]
  164. // CHECK:STDOUT: %self.param_patt: %pattern_type.fb9 = value_param_pattern %self.patt, call_param0 [concrete]
  165. // CHECK:STDOUT: } {
  166. // CHECK:STDOUT: %self.param: %Derived = value_param call_param0
  167. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Derived [concrete = constants.%Derived]
  168. // CHECK:STDOUT: %self: %Derived = bind_name self, %self.param
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT: %G.decl: %G.type.04c = fn_decl @G.2 [concrete = constants.%G.07e] {
  171. // CHECK:STDOUT: %self.patt: %pattern_type.fb9 = binding_pattern self [concrete]
  172. // CHECK:STDOUT: %self.param_patt: %pattern_type.fb9 = value_param_pattern %self.patt, call_param0 [concrete]
  173. // CHECK:STDOUT: } {
  174. // CHECK:STDOUT: %self.param: %Derived = value_param call_param0
  175. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Derived [concrete = constants.%Derived]
  176. // CHECK:STDOUT: %self: %Derived = bind_name self, %self.param
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [concrete = constants.%struct_type.base.b1e]
  179. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.15c]
  180. // CHECK:STDOUT: complete_type_witness = %complete_type
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: !members:
  183. // CHECK:STDOUT: .Self = constants.%Derived
  184. // CHECK:STDOUT: .Base = <poisoned>
  185. // CHECK:STDOUT: .base = %.loc22
  186. // CHECK:STDOUT: .F = %F.decl
  187. // CHECK:STDOUT: .G = %G.decl
  188. // CHECK:STDOUT: extend %Base.ref
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: class @Base {
  192. // CHECK:STDOUT: %F.decl: %F.type.7c6 = fn_decl @F.1 [concrete = constants.%F.d17] {
  193. // CHECK:STDOUT: %self.patt: %pattern_type.bcc = binding_pattern self [concrete]
  194. // CHECK:STDOUT: %self.param_patt: %pattern_type.bcc = value_param_pattern %self.patt, call_param0 [concrete]
  195. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  196. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  197. // CHECK:STDOUT: } {
  198. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  199. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  200. // CHECK:STDOUT: %self.param: %Base = value_param call_param0
  201. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [concrete = constants.%Base]
  202. // CHECK:STDOUT: %self: %Base = bind_name self, %self.param
  203. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  204. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT: %G.decl: %G.type.6ee = fn_decl @G.1 [concrete = constants.%G.663] {
  207. // CHECK:STDOUT: %self.patt: %pattern_type.fb9 = binding_pattern self [concrete]
  208. // CHECK:STDOUT: %self.param_patt: %pattern_type.fb9 = value_param_pattern %self.patt, call_param0 [concrete]
  209. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  210. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  211. // CHECK:STDOUT: } {
  212. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  213. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  214. // CHECK:STDOUT: %self.param: %Derived = value_param call_param0
  215. // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl.loc14 [concrete = constants.%Derived]
  216. // CHECK:STDOUT: %self: %Derived = bind_name self, %self.param
  217. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  218. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  221. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  222. // CHECK:STDOUT: complete_type_witness = %complete_type
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: !members:
  225. // CHECK:STDOUT: .Self = constants.%Base
  226. // CHECK:STDOUT: .F = %F.decl
  227. // CHECK:STDOUT: .Derived = <poisoned>
  228. // CHECK:STDOUT: .G = %G.decl
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: fn @F.1(%self.param: %Base) -> %i32;
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: fn @G.1(%self.param: %Derived) -> %i32;
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: fn @F.2(%self.param: %Derived);
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: fn @G.2(%self.param: %Derived);
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: fn @Call(%a.param: %Derived) -> %i32 {
  240. // CHECK:STDOUT: !entry:
  241. // CHECK:STDOUT: %a.ref: %Derived = name_ref a, %a
  242. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  243. // CHECK:STDOUT: %F.ref: %F.type.7c6 = name_ref F, @Base.%F.decl [concrete = constants.%F.d17]
  244. // CHECK:STDOUT: %F.bound: <bound method> = bound_method %a.ref, %F.ref
  245. // CHECK:STDOUT: %.loc29_10.1: ref %Base = class_element_access %a.ref, element0
  246. // CHECK:STDOUT: %.loc29_10.2: ref %Base = converted %a.ref, %.loc29_10.1
  247. // CHECK:STDOUT: %.loc29_10.3: %Base = bind_value %.loc29_10.2
  248. // CHECK:STDOUT: %F.call: init %i32 = call %F.bound(%.loc29_10.3)
  249. // CHECK:STDOUT: %.loc29_22.1: %i32 = value_of_initializer %F.call
  250. // CHECK:STDOUT: %.loc29_22.2: %i32 = converted %F.call, %.loc29_22.1
  251. // CHECK:STDOUT: return %.loc29_22.2
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: fn @CallIndirect(%p.param: %ptr.404) -> %i32 {
  255. // CHECK:STDOUT: !entry:
  256. // CHECK:STDOUT: %p.ref: %ptr.404 = name_ref p, %p
  257. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  258. // CHECK:STDOUT: %F.ref: %F.type.7c6 = name_ref F, @Base.%F.decl [concrete = constants.%F.d17]
  259. // CHECK:STDOUT: %.loc33_11.1: ref %Derived = deref %p.ref
  260. // CHECK:STDOUT: %F.bound: <bound method> = bound_method %.loc33_11.1, %F.ref
  261. // CHECK:STDOUT: %.loc33_11.2: ref %Base = class_element_access %.loc33_11.1, element0
  262. // CHECK:STDOUT: %.loc33_11.3: ref %Base = converted %.loc33_11.1, %.loc33_11.2
  263. // CHECK:STDOUT: %.loc33_11.4: %Base = bind_value %.loc33_11.3
  264. // CHECK:STDOUT: %F.call: init %i32 = call %F.bound(%.loc33_11.4)
  265. // CHECK:STDOUT: %.loc33_23.1: %i32 = value_of_initializer %F.call
  266. // CHECK:STDOUT: %.loc33_23.2: %i32 = converted %F.call, %.loc33_23.1
  267. // CHECK:STDOUT: return %.loc33_23.2
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: fn @PassDerivedToBase(%a.param: %Derived) -> %i32 {
  271. // CHECK:STDOUT: !entry:
  272. // CHECK:STDOUT: %a.ref: %Derived = name_ref a, %a
  273. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  274. // CHECK:STDOUT: %G.ref: %G.type.6ee = name_ref G, @Base.%G.decl [concrete = constants.%G.663]
  275. // CHECK:STDOUT: %G.bound: <bound method> = bound_method %a.ref, %G.ref
  276. // CHECK:STDOUT: %G.call: init %i32 = call %G.bound(%a.ref)
  277. // CHECK:STDOUT: %.loc37_22.1: %i32 = value_of_initializer %G.call
  278. // CHECK:STDOUT: %.loc37_22.2: %i32 = converted %G.call, %.loc37_22.1
  279. // CHECK:STDOUT: return %.loc37_22.2
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: fn @PassDerivedToBaseIndirect(%p.param: %ptr.404) -> %i32 {
  283. // CHECK:STDOUT: !entry:
  284. // CHECK:STDOUT: %p.ref: %ptr.404 = name_ref p, %p
  285. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  286. // CHECK:STDOUT: %G.ref: %G.type.6ee = name_ref G, @Base.%G.decl [concrete = constants.%G.663]
  287. // CHECK:STDOUT: %.loc41_11.1: ref %Derived = deref %p.ref
  288. // CHECK:STDOUT: %G.bound: <bound method> = bound_method %.loc41_11.1, %G.ref
  289. // CHECK:STDOUT: %.loc41_11.2: %Derived = bind_value %.loc41_11.1
  290. // CHECK:STDOUT: %G.call: init %i32 = call %G.bound(%.loc41_11.2)
  291. // CHECK:STDOUT: %.loc41_23.1: %i32 = value_of_initializer %G.call
  292. // CHECK:STDOUT: %.loc41_23.2: %i32 = converted %G.call, %.loc41_23.1
  293. // CHECK:STDOUT: return %.loc41_23.2
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: