reorder_qualified.carbon 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. // 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/class/reorder_qualified.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/reorder_qualified.carbon
  14. class A {
  15. class B {
  16. class C;
  17. fn BF();
  18. var b: i32;
  19. }
  20. class B.C {
  21. class D {
  22. fn F();
  23. fn DF();
  24. var d: i32;
  25. }
  26. fn D.DF() {
  27. // A, B, C, and D are complete here.
  28. var a: A = {.a = 1};
  29. var b: B = {.b = 2};
  30. var c: C = {.c = 3};
  31. var d: D = {.d = 4};
  32. // Unqualified lookup looks in all of them.
  33. AF();
  34. BF();
  35. CF();
  36. DF();
  37. }
  38. fn CF();
  39. var c: i32;
  40. }
  41. fn AF();
  42. var a: i32;
  43. }
  44. // CHECK:STDOUT: --- reorder_qualified.carbon
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: constants {
  47. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  48. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  49. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  50. // CHECK:STDOUT: %BF.type: type = fn_type @BF [concrete]
  51. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  52. // CHECK:STDOUT: %BF: %BF.type = struct_value () [concrete]
  53. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  54. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  55. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  56. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  57. // CHECK:STDOUT: %B.elem: type = unbound_element_type %B, %i32 [concrete]
  58. // CHECK:STDOUT: %struct_type.b.0a3: type = struct_type {.b: %i32} [concrete]
  59. // CHECK:STDOUT: %complete_type.ba8: <witness> = complete_type_witness %struct_type.b.0a3 [concrete]
  60. // CHECK:STDOUT: %D: type = class_type @D [concrete]
  61. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  62. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  63. // CHECK:STDOUT: %DF.type: type = fn_type @DF [concrete]
  64. // CHECK:STDOUT: %DF: %DF.type = struct_value () [concrete]
  65. // CHECK:STDOUT: %D.elem: type = unbound_element_type %D, %i32 [concrete]
  66. // CHECK:STDOUT: %struct_type.d.b7b: type = struct_type {.d: %i32} [concrete]
  67. // CHECK:STDOUT: %complete_type.860: <witness> = complete_type_witness %struct_type.d.b7b [concrete]
  68. // CHECK:STDOUT: %CF.type: type = fn_type @CF [concrete]
  69. // CHECK:STDOUT: %CF: %CF.type = struct_value () [concrete]
  70. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [concrete]
  71. // CHECK:STDOUT: %struct_type.c.b66: type = struct_type {.c: %i32} [concrete]
  72. // CHECK:STDOUT: %complete_type.836: <witness> = complete_type_witness %struct_type.c.b66 [concrete]
  73. // CHECK:STDOUT: %AF.type: type = fn_type @AF [concrete]
  74. // CHECK:STDOUT: %AF: %AF.type = struct_value () [concrete]
  75. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [concrete]
  76. // CHECK:STDOUT: %struct_type.a.ba9: type = struct_type {.a: %i32} [concrete]
  77. // CHECK:STDOUT: %complete_type.fd7: <witness> = complete_type_witness %struct_type.a.ba9 [concrete]
  78. // CHECK:STDOUT: %pattern_type.c10: type = pattern_type %A [concrete]
  79. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  80. // CHECK:STDOUT: %struct_type.a.a6c: type = struct_type {.a: Core.IntLiteral} [concrete]
  81. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  82. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  83. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  84. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  85. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  86. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  87. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  88. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  89. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  90. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  91. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  92. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  93. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  94. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  95. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  96. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  97. // CHECK:STDOUT: %A.val: %A = struct_value (%int_1.5d2) [concrete]
  98. // CHECK:STDOUT: %pattern_type.98e: type = pattern_type %B [concrete]
  99. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  100. // CHECK:STDOUT: %struct_type.b.a15: type = struct_type {.b: Core.IntLiteral} [concrete]
  101. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  102. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  103. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  104. // CHECK:STDOUT: %B.val: %B = struct_value (%int_2.ef8) [concrete]
  105. // CHECK:STDOUT: %pattern_type.6d8: type = pattern_type %C [concrete]
  106. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  107. // CHECK:STDOUT: %struct_type.c.5b8: type = struct_type {.c: Core.IntLiteral} [concrete]
  108. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
  109. // CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
  110. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  111. // CHECK:STDOUT: %C.val: %C = struct_value (%int_3.822) [concrete]
  112. // CHECK:STDOUT: %pattern_type.d58: type = pattern_type %D [concrete]
  113. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
  114. // CHECK:STDOUT: %struct_type.d.3ea: type = struct_type {.d: Core.IntLiteral} [concrete]
  115. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [concrete]
  116. // CHECK:STDOUT: %bound_method.1da: <bound method> = bound_method %int_4.0c1, %Convert.specific_fn [concrete]
  117. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
  118. // CHECK:STDOUT: %D.val: %D = struct_value (%int_4.940) [concrete]
  119. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  120. // CHECK:STDOUT: %Op.type.7e3: type = fn_type @Op.3, @impl.49c(%D) [concrete]
  121. // CHECK:STDOUT: %Op.47c: %Op.type.7e3 = struct_value () [concrete]
  122. // CHECK:STDOUT: %ptr.321: type = ptr_type %D [concrete]
  123. // CHECK:STDOUT: %Op.specific_fn.ceb: <specific function> = specific_function %Op.47c, @Op.3(%D) [concrete]
  124. // CHECK:STDOUT: %Op.type.2eb: type = fn_type @Op.3, @impl.49c(%C) [concrete]
  125. // CHECK:STDOUT: %Op.f77: %Op.type.2eb = struct_value () [concrete]
  126. // CHECK:STDOUT: %ptr.388: type = ptr_type %C [concrete]
  127. // CHECK:STDOUT: %Op.specific_fn.c65: <specific function> = specific_function %Op.f77, @Op.3(%C) [concrete]
  128. // CHECK:STDOUT: %Op.type.266: type = fn_type @Op.3, @impl.49c(%B) [concrete]
  129. // CHECK:STDOUT: %Op.4a4: %Op.type.266 = struct_value () [concrete]
  130. // CHECK:STDOUT: %ptr.01b: type = ptr_type %B [concrete]
  131. // CHECK:STDOUT: %Op.specific_fn.70c: <specific function> = specific_function %Op.4a4, @Op.3(%B) [concrete]
  132. // CHECK:STDOUT: %Op.type.b96: type = fn_type @Op.3, @impl.49c(%A) [concrete]
  133. // CHECK:STDOUT: %Op.885: %Op.type.b96 = struct_value () [concrete]
  134. // CHECK:STDOUT: %ptr.6db: type = ptr_type %A [concrete]
  135. // CHECK:STDOUT: %Op.specific_fn.716: <specific function> = specific_function %Op.885, @Op.3(%A) [concrete]
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: imports {
  139. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  140. // CHECK:STDOUT: .Int = %Core.Int
  141. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  142. // CHECK:STDOUT: .Destroy = %Core.Destroy
  143. // CHECK:STDOUT: import Core//prelude
  144. // CHECK:STDOUT: import Core//prelude/...
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  147. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  148. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  149. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  150. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: file {
  154. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  155. // CHECK:STDOUT: .Core = imports.%Core
  156. // CHECK:STDOUT: .A = %A.decl
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT: %Core.import = import Core
  159. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: class @A {
  163. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  164. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  165. // CHECK:STDOUT: %AF.decl: %AF.type = fn_decl @AF [concrete = constants.%AF] {} {}
  166. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  167. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  168. // CHECK:STDOUT: %.loc50: %A.elem = field_decl a, element0 [concrete]
  169. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [concrete = constants.%struct_type.a.ba9]
  170. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.a [concrete = constants.%complete_type.fd7]
  171. // CHECK:STDOUT: complete_type_witness = %complete_type
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: !members:
  174. // CHECK:STDOUT: .Self = constants.%A
  175. // CHECK:STDOUT: .B = %B.decl
  176. // CHECK:STDOUT: .AF = %AF.decl
  177. // CHECK:STDOUT: .a = %.loc50
  178. // CHECK:STDOUT: .A = <poisoned>
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: class @B {
  182. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  183. // CHECK:STDOUT: %BF.decl: %BF.type = fn_decl @BF [concrete = constants.%BF] {} {}
  184. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  185. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  186. // CHECK:STDOUT: %.loc20: %B.elem = field_decl b, element0 [concrete]
  187. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %i32} [concrete = constants.%struct_type.b.0a3]
  188. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.b [concrete = constants.%complete_type.ba8]
  189. // CHECK:STDOUT: complete_type_witness = %complete_type
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: !members:
  192. // CHECK:STDOUT: .Self = constants.%B
  193. // CHECK:STDOUT: .C = %C.decl
  194. // CHECK:STDOUT: .BF = %BF.decl
  195. // CHECK:STDOUT: .b = %.loc20
  196. // CHECK:STDOUT: .A = <poisoned>
  197. // CHECK:STDOUT: .B = <poisoned>
  198. // CHECK:STDOUT: .AF = <poisoned>
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: class @C {
  202. // CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {}
  203. // CHECK:STDOUT: %DF.decl: %DF.type = fn_decl @DF [concrete = constants.%DF] {} {}
  204. // CHECK:STDOUT: %CF.decl: %CF.type = fn_decl @CF [concrete = constants.%CF] {} {}
  205. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  206. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  207. // CHECK:STDOUT: %.loc46: %C.elem = field_decl c, element0 [concrete]
  208. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c.b66]
  209. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.c [concrete = constants.%complete_type.836]
  210. // CHECK:STDOUT: complete_type_witness = %complete_type
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: !members:
  213. // CHECK:STDOUT: .Self = constants.%C
  214. // CHECK:STDOUT: .D = %D.decl
  215. // CHECK:STDOUT: .CF = %CF.decl
  216. // CHECK:STDOUT: .c = %.loc46
  217. // CHECK:STDOUT: .A = <poisoned>
  218. // CHECK:STDOUT: .B = <poisoned>
  219. // CHECK:STDOUT: .C = <poisoned>
  220. // CHECK:STDOUT: .AF = <poisoned>
  221. // CHECK:STDOUT: .BF = <poisoned>
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: class @D {
  225. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  226. // CHECK:STDOUT: %DF.decl: %DF.type = fn_decl @DF [concrete = constants.%DF] {} {}
  227. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  228. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  229. // CHECK:STDOUT: %.loc28: %D.elem = field_decl d, element0 [concrete]
  230. // CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %i32} [concrete = constants.%struct_type.d.b7b]
  231. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.d [concrete = constants.%complete_type.860]
  232. // CHECK:STDOUT: complete_type_witness = %complete_type
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: !members:
  235. // CHECK:STDOUT: .Self = constants.%D
  236. // CHECK:STDOUT: .F = %F.decl
  237. // CHECK:STDOUT: .DF = %DF.decl
  238. // CHECK:STDOUT: .d = %.loc28
  239. // CHECK:STDOUT: .A = <poisoned>
  240. // CHECK:STDOUT: .B = <poisoned>
  241. // CHECK:STDOUT: .C = <poisoned>
  242. // CHECK:STDOUT: .D = <poisoned>
  243. // CHECK:STDOUT: .AF = <poisoned>
  244. // CHECK:STDOUT: .BF = <poisoned>
  245. // CHECK:STDOUT: .CF = <poisoned>
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: fn @BF();
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: fn @F();
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: fn @DF() {
  253. // CHECK:STDOUT: !entry:
  254. // CHECK:STDOUT: name_binding_decl {
  255. // CHECK:STDOUT: %a.patt: %pattern_type.c10 = binding_pattern a [concrete]
  256. // CHECK:STDOUT: %a.var_patt: %pattern_type.c10 = var_pattern %a.patt [concrete]
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT: %a.var: ref %A = var %a.var_patt
  259. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  260. // CHECK:STDOUT: %.loc33_25.1: %struct_type.a.a6c = struct_literal (%int_1)
  261. // CHECK:STDOUT: %impl.elem0.loc33: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  262. // CHECK:STDOUT: %bound_method.loc33_25.1: <bound method> = bound_method %int_1, %impl.elem0.loc33 [concrete = constants.%Convert.bound.ab5]
  263. // CHECK:STDOUT: %specific_fn.loc33: <specific function> = specific_function %impl.elem0.loc33, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  264. // CHECK:STDOUT: %bound_method.loc33_25.2: <bound method> = bound_method %int_1, %specific_fn.loc33 [concrete = constants.%bound_method.9a1]
  265. // CHECK:STDOUT: %int.convert_checked.loc33: init %i32 = call %bound_method.loc33_25.2(%int_1) [concrete = constants.%int_1.5d2]
  266. // CHECK:STDOUT: %.loc33_25.2: init %i32 = converted %int_1, %int.convert_checked.loc33 [concrete = constants.%int_1.5d2]
  267. // CHECK:STDOUT: %.loc33_25.3: ref %i32 = class_element_access %a.var, element0
  268. // CHECK:STDOUT: %.loc33_25.4: init %i32 = initialize_from %.loc33_25.2 to %.loc33_25.3 [concrete = constants.%int_1.5d2]
  269. // CHECK:STDOUT: %.loc33_25.5: init %A = class_init (%.loc33_25.4), %a.var [concrete = constants.%A.val]
  270. // CHECK:STDOUT: %.loc33_7: init %A = converted %.loc33_25.1, %.loc33_25.5 [concrete = constants.%A.val]
  271. // CHECK:STDOUT: assign %a.var, %.loc33_7
  272. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  273. // CHECK:STDOUT: %a: ref %A = bind_name a, %a.var
  274. // CHECK:STDOUT: name_binding_decl {
  275. // CHECK:STDOUT: %b.patt: %pattern_type.98e = binding_pattern b [concrete]
  276. // CHECK:STDOUT: %b.var_patt: %pattern_type.98e = var_pattern %b.patt [concrete]
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT: %b.var: ref %B = var %b.var_patt
  279. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  280. // CHECK:STDOUT: %.loc34_25.1: %struct_type.b.a15 = struct_literal (%int_2)
  281. // CHECK:STDOUT: %impl.elem0.loc34: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  282. // CHECK:STDOUT: %bound_method.loc34_25.1: <bound method> = bound_method %int_2, %impl.elem0.loc34 [concrete = constants.%Convert.bound.ef9]
  283. // CHECK:STDOUT: %specific_fn.loc34: <specific function> = specific_function %impl.elem0.loc34, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  284. // CHECK:STDOUT: %bound_method.loc34_25.2: <bound method> = bound_method %int_2, %specific_fn.loc34 [concrete = constants.%bound_method.b92]
  285. // CHECK:STDOUT: %int.convert_checked.loc34: init %i32 = call %bound_method.loc34_25.2(%int_2) [concrete = constants.%int_2.ef8]
  286. // CHECK:STDOUT: %.loc34_25.2: init %i32 = converted %int_2, %int.convert_checked.loc34 [concrete = constants.%int_2.ef8]
  287. // CHECK:STDOUT: %.loc34_25.3: ref %i32 = class_element_access %b.var, element0
  288. // CHECK:STDOUT: %.loc34_25.4: init %i32 = initialize_from %.loc34_25.2 to %.loc34_25.3 [concrete = constants.%int_2.ef8]
  289. // CHECK:STDOUT: %.loc34_25.5: init %B = class_init (%.loc34_25.4), %b.var [concrete = constants.%B.val]
  290. // CHECK:STDOUT: %.loc34_7: init %B = converted %.loc34_25.1, %.loc34_25.5 [concrete = constants.%B.val]
  291. // CHECK:STDOUT: assign %b.var, %.loc34_7
  292. // CHECK:STDOUT: %B.ref: type = name_ref B, @A.%B.decl [concrete = constants.%B]
  293. // CHECK:STDOUT: %b: ref %B = bind_name b, %b.var
  294. // CHECK:STDOUT: name_binding_decl {
  295. // CHECK:STDOUT: %c.patt: %pattern_type.6d8 = binding_pattern c [concrete]
  296. // CHECK:STDOUT: %c.var_patt: %pattern_type.6d8 = var_pattern %c.patt [concrete]
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt
  299. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  300. // CHECK:STDOUT: %.loc35_25.1: %struct_type.c.5b8 = struct_literal (%int_3)
  301. // CHECK:STDOUT: %impl.elem0.loc35: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  302. // CHECK:STDOUT: %bound_method.loc35_25.1: <bound method> = bound_method %int_3, %impl.elem0.loc35 [concrete = constants.%Convert.bound.b30]
  303. // CHECK:STDOUT: %specific_fn.loc35: <specific function> = specific_function %impl.elem0.loc35, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  304. // CHECK:STDOUT: %bound_method.loc35_25.2: <bound method> = bound_method %int_3, %specific_fn.loc35 [concrete = constants.%bound_method.047]
  305. // CHECK:STDOUT: %int.convert_checked.loc35: init %i32 = call %bound_method.loc35_25.2(%int_3) [concrete = constants.%int_3.822]
  306. // CHECK:STDOUT: %.loc35_25.2: init %i32 = converted %int_3, %int.convert_checked.loc35 [concrete = constants.%int_3.822]
  307. // CHECK:STDOUT: %.loc35_25.3: ref %i32 = class_element_access %c.var, element0
  308. // CHECK:STDOUT: %.loc35_25.4: init %i32 = initialize_from %.loc35_25.2 to %.loc35_25.3 [concrete = constants.%int_3.822]
  309. // CHECK:STDOUT: %.loc35_25.5: init %C = class_init (%.loc35_25.4), %c.var [concrete = constants.%C.val]
  310. // CHECK:STDOUT: %.loc35_7: init %C = converted %.loc35_25.1, %.loc35_25.5 [concrete = constants.%C.val]
  311. // CHECK:STDOUT: assign %c.var, %.loc35_7
  312. // CHECK:STDOUT: %C.ref: type = name_ref C, @B.%C.decl [concrete = constants.%C]
  313. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  314. // CHECK:STDOUT: name_binding_decl {
  315. // CHECK:STDOUT: %d.patt: %pattern_type.d58 = binding_pattern d [concrete]
  316. // CHECK:STDOUT: %d.var_patt: %pattern_type.d58 = var_pattern %d.patt [concrete]
  317. // CHECK:STDOUT: }
  318. // CHECK:STDOUT: %d.var: ref %D = var %d.var_patt
  319. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  320. // CHECK:STDOUT: %.loc36_25.1: %struct_type.d.3ea = struct_literal (%int_4)
  321. // CHECK:STDOUT: %impl.elem0.loc36: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  322. // CHECK:STDOUT: %bound_method.loc36_25.1: <bound method> = bound_method %int_4, %impl.elem0.loc36 [concrete = constants.%Convert.bound.ac3]
  323. // CHECK:STDOUT: %specific_fn.loc36: <specific function> = specific_function %impl.elem0.loc36, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  324. // CHECK:STDOUT: %bound_method.loc36_25.2: <bound method> = bound_method %int_4, %specific_fn.loc36 [concrete = constants.%bound_method.1da]
  325. // CHECK:STDOUT: %int.convert_checked.loc36: init %i32 = call %bound_method.loc36_25.2(%int_4) [concrete = constants.%int_4.940]
  326. // CHECK:STDOUT: %.loc36_25.2: init %i32 = converted %int_4, %int.convert_checked.loc36 [concrete = constants.%int_4.940]
  327. // CHECK:STDOUT: %.loc36_25.3: ref %i32 = class_element_access %d.var, element0
  328. // CHECK:STDOUT: %.loc36_25.4: init %i32 = initialize_from %.loc36_25.2 to %.loc36_25.3 [concrete = constants.%int_4.940]
  329. // CHECK:STDOUT: %.loc36_25.5: init %D = class_init (%.loc36_25.4), %d.var [concrete = constants.%D.val]
  330. // CHECK:STDOUT: %.loc36_7: init %D = converted %.loc36_25.1, %.loc36_25.5 [concrete = constants.%D.val]
  331. // CHECK:STDOUT: assign %d.var, %.loc36_7
  332. // CHECK:STDOUT: %D.ref: type = name_ref D, @C.%D.decl [concrete = constants.%D]
  333. // CHECK:STDOUT: %d: ref %D = bind_name d, %d.var
  334. // CHECK:STDOUT: %AF.ref: %AF.type = name_ref AF, @A.%AF.decl [concrete = constants.%AF]
  335. // CHECK:STDOUT: %AF.call: init %empty_tuple.type = call %AF.ref()
  336. // CHECK:STDOUT: %BF.ref: %BF.type = name_ref BF, @B.%BF.decl [concrete = constants.%BF]
  337. // CHECK:STDOUT: %BF.call: init %empty_tuple.type = call %BF.ref()
  338. // CHECK:STDOUT: %CF.ref: %CF.type = name_ref CF, @C.%CF.decl [concrete = constants.%CF]
  339. // CHECK:STDOUT: %CF.call: init %empty_tuple.type = call %CF.ref()
  340. // CHECK:STDOUT: %DF.ref: %DF.type = name_ref DF, @D.%DF.decl [concrete = constants.%DF]
  341. // CHECK:STDOUT: %DF.call: init %empty_tuple.type = call %DF.ref()
  342. // CHECK:STDOUT: %Op.bound.loc36: <bound method> = bound_method %d.var, constants.%Op.47c
  343. // CHECK:STDOUT: %Op.specific_fn.1: <specific function> = specific_function constants.%Op.47c, @Op.3(constants.%D) [concrete = constants.%Op.specific_fn.ceb]
  344. // CHECK:STDOUT: %bound_method.loc36_7: <bound method> = bound_method %d.var, %Op.specific_fn.1
  345. // CHECK:STDOUT: %addr.loc36: %ptr.321 = addr_of %d.var
  346. // CHECK:STDOUT: %no_op.loc36: init %empty_tuple.type = call %bound_method.loc36_7(%addr.loc36)
  347. // CHECK:STDOUT: %Op.bound.loc35: <bound method> = bound_method %c.var, constants.%Op.f77
  348. // CHECK:STDOUT: %Op.specific_fn.2: <specific function> = specific_function constants.%Op.f77, @Op.3(constants.%C) [concrete = constants.%Op.specific_fn.c65]
  349. // CHECK:STDOUT: %bound_method.loc35_7: <bound method> = bound_method %c.var, %Op.specific_fn.2
  350. // CHECK:STDOUT: %addr.loc35: %ptr.388 = addr_of %c.var
  351. // CHECK:STDOUT: %no_op.loc35: init %empty_tuple.type = call %bound_method.loc35_7(%addr.loc35)
  352. // CHECK:STDOUT: %Op.bound.loc34: <bound method> = bound_method %b.var, constants.%Op.4a4
  353. // CHECK:STDOUT: %Op.specific_fn.3: <specific function> = specific_function constants.%Op.4a4, @Op.3(constants.%B) [concrete = constants.%Op.specific_fn.70c]
  354. // CHECK:STDOUT: %bound_method.loc34_7: <bound method> = bound_method %b.var, %Op.specific_fn.3
  355. // CHECK:STDOUT: %addr.loc34: %ptr.01b = addr_of %b.var
  356. // CHECK:STDOUT: %no_op.loc34: init %empty_tuple.type = call %bound_method.loc34_7(%addr.loc34)
  357. // CHECK:STDOUT: %Op.bound.loc33: <bound method> = bound_method %a.var, constants.%Op.885
  358. // CHECK:STDOUT: %Op.specific_fn.4: <specific function> = specific_function constants.%Op.885, @Op.3(constants.%A) [concrete = constants.%Op.specific_fn.716]
  359. // CHECK:STDOUT: %bound_method.loc33_7: <bound method> = bound_method %a.var, %Op.specific_fn.4
  360. // CHECK:STDOUT: %addr.loc33: %ptr.6db = addr_of %a.var
  361. // CHECK:STDOUT: %no_op.loc33: init %empty_tuple.type = call %bound_method.loc33_7(%addr.loc33)
  362. // CHECK:STDOUT: return
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: fn @CF();
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: fn @AF();
  368. // CHECK:STDOUT: