implicit_as.carbon 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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/operators/overloaded/implicit_as.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/implicit_as.carbon
  10. class X {
  11. var n: i32;
  12. }
  13. impl i32 as Core.ImplicitAs(X) {
  14. fn Convert[self: i32]() -> X { return {.n = self}; }
  15. }
  16. impl X as Core.ImplicitAs(i32) {
  17. fn Convert[self: X]() -> i32 { return self.n; }
  18. }
  19. // TODO: fn Sink(T:! type, x: T);
  20. // ... once we stop deducing `T` from the type of the second argument in this case.
  21. fn Sink_i32(n: i32);
  22. fn Sink_X(x: X);
  23. fn Source(T:! type) -> T { return Source(T); }
  24. fn Test() {
  25. Sink_i32(Source(X));
  26. Sink_X(Source(i32));
  27. }
  28. // CHECK:STDOUT: --- implicit_as.carbon
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: constants {
  31. // CHECK:STDOUT: %X: type = class_type @X [template]
  32. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  33. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  34. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  35. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  36. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  37. // CHECK:STDOUT: %.2: type = unbound_element_type %X, %i32 [template]
  38. // CHECK:STDOUT: %.3: type = struct_type {.n: %i32} [template]
  39. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  40. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  41. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  42. // CHECK:STDOUT: %ImplicitAs.type.3: type = facet_type <@ImplicitAs, @ImplicitAs(%X)> [template]
  43. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.2 [template]
  44. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  45. // CHECK:STDOUT: %Convert.type.3: type = fn_type @Convert.1, @ImplicitAs(%X) [template]
  46. // CHECK:STDOUT: %.9: <witness> = interface_witness (%Convert.2) [template]
  47. // CHECK:STDOUT: %ImplicitAs.type.4: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  48. // CHECK:STDOUT: %Convert.type.4: type = fn_type @Convert.3 [template]
  49. // CHECK:STDOUT: %Convert.4: %Convert.type.4 = struct_value () [template]
  50. // CHECK:STDOUT: %Convert.type.5: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  51. // CHECK:STDOUT: %.13: <witness> = interface_witness (%Convert.4) [template]
  52. // CHECK:STDOUT: %Sink_i32.type: type = fn_type @Sink_i32 [template]
  53. // CHECK:STDOUT: %Sink_i32: %Sink_i32.type = struct_value () [template]
  54. // CHECK:STDOUT: %Sink_X.type: type = fn_type @Sink_X [template]
  55. // CHECK:STDOUT: %Sink_X: %Sink_X.type = struct_value () [template]
  56. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  57. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  58. // CHECK:STDOUT: %Source.type: type = fn_type @Source [template]
  59. // CHECK:STDOUT: %Source: %Source.type = struct_value () [template]
  60. // CHECK:STDOUT: %.14: <specific function> = specific_function %Source, @Source(%T) [symbolic]
  61. // CHECK:STDOUT: %Test.type: type = fn_type @Test [template]
  62. // CHECK:STDOUT: %Test: %Test.type = struct_value () [template]
  63. // CHECK:STDOUT: %.15: <specific function> = specific_function %Source, @Source(%X) [template]
  64. // CHECK:STDOUT: %.31: <specific function> = specific_function %Source, @Source(%i32) [template]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: imports {
  68. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  69. // CHECK:STDOUT: .Int = %import_ref.1
  70. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  71. // CHECK:STDOUT: import Core//prelude
  72. // CHECK:STDOUT: import Core//prelude/...
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %import_ref.2: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+54, loaded [template = constants.%ImplicitAs]
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: file {
  78. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  79. // CHECK:STDOUT: .Core = imports.%Core
  80. // CHECK:STDOUT: .X = %X.decl
  81. // CHECK:STDOUT: .Sink_i32 = %Sink_i32.decl
  82. // CHECK:STDOUT: .Sink_X = %Sink_X.decl
  83. // CHECK:STDOUT: .Source = %Source.decl
  84. // CHECK:STDOUT: .Test = %Test.decl
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: %Core.import = import Core
  87. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {}
  88. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  89. // CHECK:STDOUT: %.loc15_6.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  90. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc15_6.1) [template = constants.%i32]
  91. // CHECK:STDOUT: %.loc15_6.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  92. // CHECK:STDOUT: %.loc15_6.3: type = converted %int.make_type_signed, %.loc15_6.2 [template = constants.%i32]
  93. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  94. // CHECK:STDOUT: %ImplicitAs.ref: %ImplicitAs.type.1 = name_ref ImplicitAs, imports.%import_ref.2 [template = constants.%ImplicitAs]
  95. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  96. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%X)> [template = constants.%ImplicitAs.type.3]
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  99. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  100. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  101. // CHECK:STDOUT: %ImplicitAs.ref: %ImplicitAs.type.1 = name_ref ImplicitAs, imports.%import_ref.2 [template = constants.%ImplicitAs]
  102. // CHECK:STDOUT: %.loc19_27: Core.IntLiteral = int_value 32 [template = constants.%.1]
  103. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc19_27) [template = constants.%i32]
  104. // CHECK:STDOUT: %.loc19_26.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  105. // CHECK:STDOUT: %.loc19_26.2: type = converted %int.make_type_signed, %.loc19_26.1 [template = constants.%i32]
  106. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%i32)> [template = constants.%ImplicitAs.type.4]
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: %Sink_i32.decl: %Sink_i32.type = fn_decl @Sink_i32 [template = constants.%Sink_i32] {
  109. // CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
  110. // CHECK:STDOUT: %n.param_patt: %i32 = value_param_pattern %n.patt, runtime_param0
  111. // CHECK:STDOUT: } {
  112. // CHECK:STDOUT: %.loc25_16.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  113. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc25_16.1) [template = constants.%i32]
  114. // CHECK:STDOUT: %.loc25_16.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  115. // CHECK:STDOUT: %.loc25_16.3: type = converted %int.make_type_signed, %.loc25_16.2 [template = constants.%i32]
  116. // CHECK:STDOUT: %n.param: %i32 = value_param runtime_param0
  117. // CHECK:STDOUT: %n: %i32 = bind_name n, %n.param
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT: %Sink_X.decl: %Sink_X.type = fn_decl @Sink_X [template = constants.%Sink_X] {
  120. // CHECK:STDOUT: %x.patt: %X = binding_pattern x
  121. // CHECK:STDOUT: %x.param_patt: %X = value_param_pattern %x.patt, runtime_param0
  122. // CHECK:STDOUT: } {
  123. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  124. // CHECK:STDOUT: %x.param: %X = value_param runtime_param0
  125. // CHECK:STDOUT: %x: %X = bind_name x, %x.param
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: %Source.decl: %Source.type = fn_decl @Source [template = constants.%Source] {
  128. // CHECK:STDOUT: %T.patt.loc27_11.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc27_11.2 (constants.%T.patt)]
  129. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc27_11.1, runtime_param<invalid> [symbolic = %T.patt.loc27_11.2 (constants.%T.patt)]
  130. // CHECK:STDOUT: %return.patt: @Source.%T.loc27_11.2 (%T) = return_slot_pattern
  131. // CHECK:STDOUT: %return.param_patt: @Source.%T.loc27_11.2 (%T) = out_param_pattern %return.patt, runtime_param0
  132. // CHECK:STDOUT: } {
  133. // CHECK:STDOUT: %T.ref.loc27_24: type = name_ref T, %T.loc27_11.1 [symbolic = %T.loc27_11.2 (constants.%T)]
  134. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  135. // CHECK:STDOUT: %T.loc27_11.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc27_11.2 (constants.%T)]
  136. // CHECK:STDOUT: %return.param: ref @Source.%T.loc27_11.2 (%T) = out_param runtime_param0
  137. // CHECK:STDOUT: %return: ref @Source.%T.loc27_11.2 (%T) = return_slot %return.param
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [template = constants.%Test] {} {}
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: impl @impl.1: %.loc15_6.3 as %ImplicitAs.type {
  143. // CHECK:STDOUT: %Convert.decl: %Convert.type.2 = fn_decl @Convert.2 [template = constants.%Convert.2] {
  144. // CHECK:STDOUT: %self.patt: %i32 = binding_pattern self
  145. // CHECK:STDOUT: %self.param_patt: %i32 = value_param_pattern %self.patt, runtime_param0
  146. // CHECK:STDOUT: %return.patt: %X = return_slot_pattern
  147. // CHECK:STDOUT: %return.param_patt: %X = out_param_pattern %return.patt, runtime_param1
  148. // CHECK:STDOUT: } {
  149. // CHECK:STDOUT: %.loc16_20.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  150. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc16_20.1) [template = constants.%i32]
  151. // CHECK:STDOUT: %.loc16_20.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  152. // CHECK:STDOUT: %.loc16_20.3: type = converted %int.make_type_signed, %.loc16_20.2 [template = constants.%i32]
  153. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  154. // CHECK:STDOUT: %self.param: %i32 = value_param runtime_param0
  155. // CHECK:STDOUT: %self: %i32 = bind_name self, %self.param
  156. // CHECK:STDOUT: %return.param: ref %X = out_param runtime_param1
  157. // CHECK:STDOUT: %return: ref %X = return_slot %return.param
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: %.loc15_32: <witness> = interface_witness (%Convert.decl) [template = constants.%.9]
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: !members:
  162. // CHECK:STDOUT: .Convert = %Convert.decl
  163. // CHECK:STDOUT: witness = %.loc15_32
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: impl @impl.2: %X.ref as %ImplicitAs.type {
  167. // CHECK:STDOUT: %Convert.decl: %Convert.type.4 = fn_decl @Convert.3 [template = constants.%Convert.4] {
  168. // CHECK:STDOUT: %self.patt: %X = binding_pattern self
  169. // CHECK:STDOUT: %self.param_patt: %X = value_param_pattern %self.patt, runtime_param0
  170. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  171. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  172. // CHECK:STDOUT: } {
  173. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  174. // CHECK:STDOUT: %.loc20_28.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  175. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc20_28.1) [template = constants.%i32]
  176. // CHECK:STDOUT: %.loc20_28.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  177. // CHECK:STDOUT: %.loc20_28.3: type = converted %int.make_type_signed, %.loc20_28.2 [template = constants.%i32]
  178. // CHECK:STDOUT: %self.param: %X = value_param runtime_param0
  179. // CHECK:STDOUT: %self: %X = bind_name self, %self.param
  180. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  181. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT: %.loc19_32: <witness> = interface_witness (%Convert.decl) [template = constants.%.13]
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: !members:
  186. // CHECK:STDOUT: .Convert = %Convert.decl
  187. // CHECK:STDOUT: witness = %.loc19_32
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: class @X {
  191. // CHECK:STDOUT: %.loc12_10.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  192. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc12_10.1) [template = constants.%i32]
  193. // CHECK:STDOUT: %.loc12_10.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  194. // CHECK:STDOUT: %.loc12_10.3: type = converted %int.make_type_signed, %.loc12_10.2 [template = constants.%i32]
  195. // CHECK:STDOUT: %.loc12_8: %.2 = field_decl n, element0 [template]
  196. // CHECK:STDOUT: %.loc13: <witness> = complete_type_witness %.3 [template = constants.%.4]
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: !members:
  199. // CHECK:STDOUT: .Self = constants.%X
  200. // CHECK:STDOUT: .n = %.loc12_8
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: fn @Convert.2[%self.param_patt: %i32]() -> %return: %X {
  204. // CHECK:STDOUT: !entry:
  205. // CHECK:STDOUT: %self.ref: %i32 = name_ref self, %self
  206. // CHECK:STDOUT: %.loc16_51.1: %.3 = struct_literal (%self.ref)
  207. // CHECK:STDOUT: %.loc16_51.2: ref %i32 = class_element_access %return, element0
  208. // CHECK:STDOUT: %.loc16_51.3: init %i32 = initialize_from %self.ref to %.loc16_51.2
  209. // CHECK:STDOUT: %.loc16_51.4: init %X = class_init (%.loc16_51.3), %return
  210. // CHECK:STDOUT: %.loc16_52: init %X = converted %.loc16_51.1, %.loc16_51.4
  211. // CHECK:STDOUT: return %.loc16_52 to %return
  212. // CHECK:STDOUT: }
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: fn @Convert.3[%self.param_patt: %X]() -> %i32 {
  215. // CHECK:STDOUT: !entry:
  216. // CHECK:STDOUT: %self.ref: %X = name_ref self, %self
  217. // CHECK:STDOUT: %n.ref: %.2 = name_ref n, @X.%.loc12_8 [template = @X.%.loc12_8]
  218. // CHECK:STDOUT: %.loc20_45.1: ref %i32 = class_element_access %self.ref, element0
  219. // CHECK:STDOUT: %.loc20_45.2: %i32 = bind_value %.loc20_45.1
  220. // CHECK:STDOUT: return %.loc20_45.2
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: fn @Sink_i32(%n.param_patt: %i32);
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: fn @Sink_X(%x.param_patt: %X);
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: generic fn @Source(%T.loc27_11.1: type) {
  228. // CHECK:STDOUT: %T.loc27_11.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc27_11.2 (constants.%T)]
  229. // CHECK:STDOUT: %T.patt.loc27_11.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc27_11.2 (constants.%T.patt)]
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: !definition:
  232. // CHECK:STDOUT: %.loc27_35.2: <specific function> = specific_function constants.%Source, @Source(%T.loc27_11.2) [symbolic = %.loc27_35.2 (constants.%.14)]
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: fn(%T.param_patt: type) -> @Source.%T.loc27_11.2 (%T) {
  235. // CHECK:STDOUT: !entry:
  236. // CHECK:STDOUT: %Source.ref: %Source.type = name_ref Source, file.%Source.decl [template = constants.%Source]
  237. // CHECK:STDOUT: %T.ref.loc27_42: type = name_ref T, %T.loc27_11.1 [symbolic = %T.loc27_11.2 (constants.%T)]
  238. // CHECK:STDOUT: %.loc27_35.1: <specific function> = specific_function %Source.ref, @Source(constants.%T) [symbolic = %.loc27_35.2 (constants.%.14)]
  239. // CHECK:STDOUT: %Source.call: init @Source.%T.loc27_11.2 (%T) = call %.loc27_35.1()
  240. // CHECK:STDOUT: %.loc27_44.1: @Source.%T.loc27_11.2 (%T) = value_of_initializer %Source.call
  241. // CHECK:STDOUT: %.loc27_44.2: @Source.%T.loc27_11.2 (%T) = converted %Source.call, %.loc27_44.1
  242. // CHECK:STDOUT: return %.loc27_44.2
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: fn @Test() {
  247. // CHECK:STDOUT: !entry:
  248. // CHECK:STDOUT: %Sink_i32.ref: %Sink_i32.type = name_ref Sink_i32, file.%Sink_i32.decl [template = constants.%Sink_i32]
  249. // CHECK:STDOUT: %Source.ref.loc30: %Source.type = name_ref Source, file.%Source.decl [template = constants.%Source]
  250. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  251. // CHECK:STDOUT: %.loc30_12: <specific function> = specific_function %Source.ref.loc30, @Source(constants.%X) [template = constants.%.15]
  252. // CHECK:STDOUT: %.loc30_18.1: ref %X = temporary_storage
  253. // CHECK:STDOUT: %Source.call.loc30: init %X = call %.loc30_12() to %.loc30_18.1
  254. // CHECK:STDOUT: %.loc30_18.2: %Convert.type.5 = interface_witness_access constants.%.13, element0 [template = constants.%Convert.4]
  255. // CHECK:STDOUT: %.loc30_18.3: <bound method> = bound_method %Source.call.loc30, %.loc30_18.2
  256. // CHECK:STDOUT: %.loc30_18.4: ref %X = temporary %.loc30_18.1, %Source.call.loc30
  257. // CHECK:STDOUT: %.loc30_18.5: %X = bind_value %.loc30_18.4
  258. // CHECK:STDOUT: %Convert.call.loc30: init %i32 = call %.loc30_18.3(%.loc30_18.5)
  259. // CHECK:STDOUT: %.loc30_18.6: %i32 = value_of_initializer %Convert.call.loc30
  260. // CHECK:STDOUT: %.loc30_18.7: %i32 = converted %Source.call.loc30, %.loc30_18.6
  261. // CHECK:STDOUT: %Sink_i32.call: init %empty_tuple.type = call %Sink_i32.ref(%.loc30_18.7)
  262. // CHECK:STDOUT: %Sink_X.ref: %Sink_X.type = name_ref Sink_X, file.%Sink_X.decl [template = constants.%Sink_X]
  263. // CHECK:STDOUT: %Source.ref.loc31: %Source.type = name_ref Source, file.%Source.decl [template = constants.%Source]
  264. // CHECK:STDOUT: %.loc31_17: Core.IntLiteral = int_value 32 [template = constants.%.1]
  265. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc31_17) [template = constants.%i32]
  266. // CHECK:STDOUT: %.loc31_16.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  267. // CHECK:STDOUT: %.loc31_16.2: type = converted %int.make_type_signed, %.loc31_16.1 [template = constants.%i32]
  268. // CHECK:STDOUT: %.loc31_10: <specific function> = specific_function %Source.ref.loc31, @Source(constants.%i32) [template = constants.%.31]
  269. // CHECK:STDOUT: %Source.call.loc31: init %i32 = call %.loc31_10()
  270. // CHECK:STDOUT: %.loc31_16.3: %Convert.type.3 = interface_witness_access constants.%.9, element0 [template = constants.%Convert.2]
  271. // CHECK:STDOUT: %.loc31_16.4: <bound method> = bound_method %Source.call.loc31, %.loc31_16.3
  272. // CHECK:STDOUT: %.loc31_16.5: ref %X = temporary_storage
  273. // CHECK:STDOUT: %.loc31_16.6: %i32 = value_of_initializer %Source.call.loc31
  274. // CHECK:STDOUT: %.loc31_16.7: %i32 = converted %Source.call.loc31, %.loc31_16.6
  275. // CHECK:STDOUT: %Convert.call.loc31: init %X = call %.loc31_16.4(%.loc31_16.7) to %.loc31_16.5
  276. // CHECK:STDOUT: %.loc31_16.8: init %X = converted %Source.call.loc31, %Convert.call.loc31
  277. // CHECK:STDOUT: %.loc31_16.9: ref %X = temporary %.loc31_16.5, %.loc31_16.8
  278. // CHECK:STDOUT: %.loc31_16.10: %X = bind_value %.loc31_16.9
  279. // CHECK:STDOUT: %Sink_X.call: init %empty_tuple.type = call %Sink_X.ref(%.loc31_16.10)
  280. // CHECK:STDOUT: return
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: specific @Source(constants.%T) {
  284. // CHECK:STDOUT: %T.loc27_11.2 => constants.%T
  285. // CHECK:STDOUT: %T.patt.loc27_11.2 => constants.%T
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: !definition:
  288. // CHECK:STDOUT: %.loc27_35.2 => constants.%.14
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: specific @Source(%T.loc27_11.2) {
  292. // CHECK:STDOUT: %T.loc27_11.2 => constants.%T
  293. // CHECK:STDOUT: %T.patt.loc27_11.2 => constants.%T
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: specific @Source(constants.%X) {
  297. // CHECK:STDOUT: %T.loc27_11.2 => constants.%X
  298. // CHECK:STDOUT: %T.patt.loc27_11.2 => constants.%X
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: !definition:
  301. // CHECK:STDOUT: %.loc27_35.2 => constants.%.15
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: specific @Source(constants.%i32) {
  305. // CHECK:STDOUT: %T.loc27_11.2 => constants.%i32
  306. // CHECK:STDOUT: %T.patt.loc27_11.2 => constants.%i32
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: !definition:
  309. // CHECK:STDOUT: %.loc27_35.2 => constants.%.31
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT: