ref.carbon 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/let/ref.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/ref.carbon
  12. // --- local.carbon
  13. library "[[@TEST_NAME]]";
  14. fn F(a: i32) {
  15. var b: i32 = a;
  16. //@dump-sem-ir-begin
  17. let ref c: i32 = b;
  18. let (ref d: i32, ref e: i32) = (b, c);
  19. //@dump-sem-ir-end
  20. }
  21. // --- param.carbon
  22. library "[[@TEST_NAME]]";
  23. //@dump-sem-ir-begin
  24. fn F(ref a: i32) {
  25. a = 1;
  26. }
  27. fn G() {
  28. var x: i32 = 0;
  29. F(x);
  30. }
  31. //@dump-sem-ir-end
  32. // --- self.carbon
  33. library "[[@TEST_NAME]]";
  34. //@dump-sem-ir-begin
  35. class C {
  36. var a: i32;
  37. fn F[ref self: Self]() {
  38. self.a = 1;
  39. }
  40. }
  41. //@dump-sem-ir-end
  42. // --- fail_ref_to_value.carbon
  43. library "[[@TEST_NAME]]";
  44. fn F(a: i32) {
  45. // CHECK:STDERR: fail_ref_to_value.carbon:[[@LINE+4]]:20: error: cannot bind durable reference to non-reference value of type `i32` [ConversionFailureNonRefToRef]
  46. // CHECK:STDERR: let ref b: i32 = a;
  47. // CHECK:STDERR: ^
  48. // CHECK:STDERR:
  49. let ref b: i32 = a;
  50. }
  51. // --- fail_ref_to_temporary.carbon
  52. library "[[@TEST_NAME]]";
  53. fn G() -> i32;
  54. fn F() {
  55. // CHECK:STDERR: fail_ref_to_temporary.carbon:[[@LINE+4]]:20: error: cannot bind durable reference to non-reference value of type `i32` [ConversionFailureNonRefToRef]
  56. // CHECK:STDERR: let ref a: i32 = G();
  57. // CHECK:STDERR: ^~~
  58. // CHECK:STDERR:
  59. let ref a: i32 = G();
  60. }
  61. // CHECK:STDOUT: --- local.carbon
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: constants {
  64. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  65. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  66. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  67. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete]
  68. // CHECK:STDOUT: %pattern_type.511: type = pattern_type %tuple.type.d07 [concrete]
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: imports {
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn @F(%a.param: %i32) {
  75. // CHECK:STDOUT: !entry:
  76. // CHECK:STDOUT: <elided>
  77. // CHECK:STDOUT: name_binding_decl {
  78. // CHECK:STDOUT: %c.patt: %pattern_type.7ce = ref_binding_pattern c [concrete]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %b.ref.loc7: ref %i32 = name_ref b, %b
  81. // CHECK:STDOUT: %.loc7: type = splice_block %i32.loc7 [concrete = constants.%i32] {
  82. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  83. // CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %c: ref %i32 = ref_binding c, %b.ref.loc7
  86. // CHECK:STDOUT: name_binding_decl {
  87. // CHECK:STDOUT: %d.patt: %pattern_type.7ce = ref_binding_pattern d [concrete]
  88. // CHECK:STDOUT: %e.patt: %pattern_type.7ce = ref_binding_pattern e [concrete]
  89. // CHECK:STDOUT: %.loc8_30: %pattern_type.511 = tuple_pattern (%d.patt, %e.patt) [concrete]
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: %b.ref.loc8: ref %i32 = name_ref b, %b
  92. // CHECK:STDOUT: %c.ref: ref %i32 = name_ref c, %c
  93. // CHECK:STDOUT: %.loc8_39: %tuple.type.d07 = tuple_literal (%b.ref.loc8, %c.ref)
  94. // CHECK:STDOUT: %.loc8_15: type = splice_block %i32.loc8_15 [concrete = constants.%i32] {
  95. // CHECK:STDOUT: %int_32.loc8_15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  96. // CHECK:STDOUT: %i32.loc8_15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: %d: ref %i32 = ref_binding d, %b.ref.loc8
  99. // CHECK:STDOUT: %.loc8_27: type = splice_block %i32.loc8_27 [concrete = constants.%i32] {
  100. // CHECK:STDOUT: %int_32.loc8_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  101. // CHECK:STDOUT: %i32.loc8_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %e: ref %i32 = ref_binding e, %c.ref
  104. // CHECK:STDOUT: <elided>
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: --- param.carbon
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: constants {
  110. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  111. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  112. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  113. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  114. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  115. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  116. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  117. // CHECK:STDOUT: %ImplicitAs.type.d14: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  118. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  119. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  120. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  121. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51 = struct_value () [symbolic]
  122. // CHECK:STDOUT: %ImplicitAs.impl_witness.bc9: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.132, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  123. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  124. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e = struct_value () [concrete]
  125. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.d14 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.bc9) [concrete]
  126. // CHECK:STDOUT: %.322: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet [concrete]
  127. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.265: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  128. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  129. // CHECK:STDOUT: %bound_method.dfc: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  130. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  131. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  132. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  133. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
  134. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.0b3: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  135. // CHECK:STDOUT: %bound_method.9be: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  136. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
  137. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  138. // CHECK:STDOUT: %facet_value: %type_where = facet_value %i32, () [concrete]
  139. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d4e: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [concrete]
  140. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.424: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d4e = struct_value () [concrete]
  141. // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: imports {
  145. // CHECK:STDOUT: %Core.import_ref.e24: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1)]
  146. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.132 = impl_witness_table (%Core.import_ref.e24), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: file {
  150. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  151. // CHECK:STDOUT: %a.patt: %pattern_type.7ce = ref_binding_pattern a [concrete]
  152. // CHECK:STDOUT: %a.param_patt: %pattern_type.7ce = ref_param_pattern %a.patt, call_param0 [concrete]
  153. // CHECK:STDOUT: } {
  154. // CHECK:STDOUT: %a.param: ref %i32 = ref_param call_param0
  155. // CHECK:STDOUT: %.loc5: type = splice_block %i32 [concrete = constants.%i32] {
  156. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  157. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: %a: ref %i32 = ref_binding a, %a.param
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: fn @F(%a.param: %i32) {
  165. // CHECK:STDOUT: !entry:
  166. // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
  167. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  168. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  169. // CHECK:STDOUT: %bound_method.loc6_5.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.265]
  170. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  171. // CHECK:STDOUT: %bound_method.loc6_5.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method.dfc]
  172. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc6_5.2(%int_1) [concrete = constants.%int_1.5d2]
  173. // CHECK:STDOUT: %.loc6: init %i32 = converted %int_1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.5d2]
  174. // CHECK:STDOUT: assign %a.ref, %.loc6
  175. // CHECK:STDOUT: return
  176. // CHECK:STDOUT: }
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: fn @G() {
  179. // CHECK:STDOUT: !entry:
  180. // CHECK:STDOUT: name_binding_decl {
  181. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = ref_binding_pattern x [concrete]
  182. // CHECK:STDOUT: %x.var_patt: %pattern_type.7ce = var_pattern %x.patt [concrete]
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT: %x.var: ref %i32 = var %x.var_patt
  185. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
  186. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  187. // CHECK:STDOUT: %bound_method.loc10_3.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.0b3]
  188. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  189. // CHECK:STDOUT: %bound_method.loc10_3.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method.9be]
  190. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc10_3.2(%int_0) [concrete = constants.%int_0.6a9]
  191. // CHECK:STDOUT: %.loc10_3: init %i32 = converted %int_0, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9]
  192. // CHECK:STDOUT: assign %x.var, %.loc10_3
  193. // CHECK:STDOUT: %.loc10_10: type = splice_block %i32 [concrete = constants.%i32] {
  194. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  195. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: %x: ref %i32 = ref_binding x, %x.var
  198. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  199. // CHECK:STDOUT: %x.ref: ref %i32 = name_ref x, %x
  200. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref(%x.ref)
  201. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %x.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.424
  202. // CHECK:STDOUT: <elided>
  203. // CHECK:STDOUT: %bound_method.loc10_3.3: <bound method> = bound_method %x.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn
  204. // CHECK:STDOUT: %addr: %ptr.235 = addr_of %x.var
  205. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method.loc10_3.3(%addr)
  206. // CHECK:STDOUT: return
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: --- self.carbon
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: constants {
  212. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  213. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  214. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  215. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [concrete]
  216. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  217. // CHECK:STDOUT: %C.F.type: type = fn_type @C.F [concrete]
  218. // CHECK:STDOUT: %C.F: %C.F.type = struct_value () [concrete]
  219. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [concrete]
  220. // CHECK:STDOUT: %complete_type.fd7: <witness> = complete_type_witness %struct_type.a [concrete]
  221. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  222. // CHECK:STDOUT: %ImplicitAs.type.d14: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  223. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  224. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  225. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  226. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51 = struct_value () [symbolic]
  227. // CHECK:STDOUT: %ImplicitAs.impl_witness.bc9: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.132, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  228. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  229. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e = struct_value () [concrete]
  230. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.d14 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.bc9) [concrete]
  231. // CHECK:STDOUT: %.322: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet [concrete]
  232. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  233. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  234. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  235. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: imports {
  239. // CHECK:STDOUT: %Core.import_ref.e24: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1)]
  240. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.132 = impl_witness_table (%Core.import_ref.e24), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: file {
  244. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: class @C {
  248. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  249. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  250. // CHECK:STDOUT: %.loc6: %C.elem = field_decl a, element0 [concrete]
  251. // CHECK:STDOUT: %C.F.decl: %C.F.type = fn_decl @C.F [concrete = constants.%C.F] {
  252. // CHECK:STDOUT: %self.patt: %pattern_type.c48 = ref_binding_pattern self [concrete]
  253. // CHECK:STDOUT: %self.param_patt: %pattern_type.c48 = ref_param_pattern %self.patt, call_param0 [concrete]
  254. // CHECK:STDOUT: } {
  255. // CHECK:STDOUT: %self.param: ref %C = ref_param call_param0
  256. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  257. // CHECK:STDOUT: %self: ref %C = ref_binding self, %self.param
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.a [concrete = constants.%complete_type.fd7]
  260. // CHECK:STDOUT: complete_type_witness = %complete_type
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: !members:
  263. // CHECK:STDOUT: .Self = constants.%C
  264. // CHECK:STDOUT: .a = %.loc6
  265. // CHECK:STDOUT: .F = %C.F.decl
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: fn @C.F(%self.param: %C) {
  269. // CHECK:STDOUT: !entry:
  270. // CHECK:STDOUT: %self.ref: ref %C = name_ref self, %self
  271. // CHECK:STDOUT: %a.ref: %C.elem = name_ref a, @C.%.loc6 [concrete = @C.%.loc6]
  272. // CHECK:STDOUT: %.loc9_9: ref %i32 = class_element_access %self.ref, element0
  273. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  274. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  275. // CHECK:STDOUT: %bound_method.loc9_12.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  276. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  277. // CHECK:STDOUT: %bound_method.loc9_12.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  278. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc9_12.2(%int_1) [concrete = constants.%int_1.5d2]
  279. // CHECK:STDOUT: %.loc9_12: init %i32 = converted %int_1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.5d2]
  280. // CHECK:STDOUT: assign %.loc9_9, %.loc9_12
  281. // CHECK:STDOUT: return
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT: