reorder_qualified.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/reorder_qualified.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/reorder_qualified.carbon
  10. class A {
  11. class B {
  12. class C;
  13. fn BF();
  14. var b: i32;
  15. }
  16. class B.C {
  17. class D {
  18. fn F();
  19. fn DF();
  20. var d: i32;
  21. }
  22. fn D.DF() {
  23. // A, B, C, and D are complete here.
  24. var a: A = {.a = 1};
  25. var b: B = {.b = 2};
  26. var c: C = {.c = 3};
  27. var d: D = {.d = 4};
  28. // Unqualified lookup looks in all of them.
  29. AF();
  30. BF();
  31. CF();
  32. DF();
  33. }
  34. fn CF();
  35. var c: i32;
  36. }
  37. fn AF();
  38. var a: i32;
  39. }
  40. // CHECK:STDOUT: --- reorder_qualified.carbon
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: constants {
  43. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  44. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  45. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  46. // CHECK:STDOUT: %BF.type: type = fn_type @BF [concrete]
  47. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  48. // CHECK:STDOUT: %BF: %BF.type = struct_value () [concrete]
  49. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  50. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  51. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  52. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  53. // CHECK:STDOUT: %B.elem: type = unbound_element_type %B, %i32 [concrete]
  54. // CHECK:STDOUT: %struct_type.b.0a3: type = struct_type {.b: %i32} [concrete]
  55. // CHECK:STDOUT: %complete_type.ba8: <witness> = complete_type_witness %struct_type.b.0a3 [concrete]
  56. // CHECK:STDOUT: %D: type = class_type @D [concrete]
  57. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  58. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  59. // CHECK:STDOUT: %DF.type: type = fn_type @DF [concrete]
  60. // CHECK:STDOUT: %DF: %DF.type = struct_value () [concrete]
  61. // CHECK:STDOUT: %D.elem: type = unbound_element_type %D, %i32 [concrete]
  62. // CHECK:STDOUT: %struct_type.d.b7b: type = struct_type {.d: %i32} [concrete]
  63. // CHECK:STDOUT: %complete_type.860: <witness> = complete_type_witness %struct_type.d.b7b [concrete]
  64. // CHECK:STDOUT: %CF.type: type = fn_type @CF [concrete]
  65. // CHECK:STDOUT: %CF: %CF.type = struct_value () [concrete]
  66. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [concrete]
  67. // CHECK:STDOUT: %struct_type.c.b66: type = struct_type {.c: %i32} [concrete]
  68. // CHECK:STDOUT: %complete_type.836: <witness> = complete_type_witness %struct_type.c.b66 [concrete]
  69. // CHECK:STDOUT: %AF.type: type = fn_type @AF [concrete]
  70. // CHECK:STDOUT: %AF: %AF.type = struct_value () [concrete]
  71. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [concrete]
  72. // CHECK:STDOUT: %struct_type.a.ba9: type = struct_type {.a: %i32} [concrete]
  73. // CHECK:STDOUT: %complete_type.fd7: <witness> = complete_type_witness %struct_type.a.ba9 [concrete]
  74. // CHECK:STDOUT: %pattern_type.c10: type = pattern_type %A [concrete]
  75. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  76. // CHECK:STDOUT: %struct_type.a.a6c: type = struct_type {.a: Core.IntLiteral} [concrete]
  77. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  78. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  79. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  80. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  81. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  82. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  83. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  84. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  85. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  86. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  87. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  88. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  89. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  90. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  91. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  92. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  93. // CHECK:STDOUT: %A.val: %A = struct_value (%int_1.5d2) [concrete]
  94. // CHECK:STDOUT: %pattern_type.98e: type = pattern_type %B [concrete]
  95. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  96. // CHECK:STDOUT: %struct_type.b.a15: type = struct_type {.b: Core.IntLiteral} [concrete]
  97. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  98. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  99. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  100. // CHECK:STDOUT: %B.val: %B = struct_value (%int_2.ef8) [concrete]
  101. // CHECK:STDOUT: %pattern_type.6d8: type = pattern_type %C [concrete]
  102. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  103. // CHECK:STDOUT: %struct_type.c.5b8: type = struct_type {.c: Core.IntLiteral} [concrete]
  104. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
  105. // CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
  106. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  107. // CHECK:STDOUT: %C.val: %C = struct_value (%int_3.822) [concrete]
  108. // CHECK:STDOUT: %pattern_type.d58: type = pattern_type %D [concrete]
  109. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
  110. // CHECK:STDOUT: %struct_type.d.3ea: type = struct_type {.d: Core.IntLiteral} [concrete]
  111. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [concrete]
  112. // CHECK:STDOUT: %bound_method.1da: <bound method> = bound_method %int_4.0c1, %Convert.specific_fn [concrete]
  113. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
  114. // CHECK:STDOUT: %D.val: %D = struct_value (%int_4.940) [concrete]
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: imports {
  118. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  119. // CHECK:STDOUT: .Int = %Core.Int
  120. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  121. // CHECK:STDOUT: import Core//prelude
  122. // CHECK:STDOUT: import Core//prelude/...
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  125. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  126. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  127. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: file {
  131. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  132. // CHECK:STDOUT: .Core = imports.%Core
  133. // CHECK:STDOUT: .A = %A.decl
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %Core.import = import Core
  136. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: class @A {
  140. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  141. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  142. // CHECK:STDOUT: %AF.decl: %AF.type = fn_decl @AF [concrete = constants.%AF] {} {}
  143. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  144. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  145. // CHECK:STDOUT: %.loc46: %A.elem = field_decl a, element0 [concrete]
  146. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [concrete = constants.%struct_type.a.ba9]
  147. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.a [concrete = constants.%complete_type.fd7]
  148. // CHECK:STDOUT: complete_type_witness = %complete_type
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: !members:
  151. // CHECK:STDOUT: .Self = constants.%A
  152. // CHECK:STDOUT: .B = %B.decl
  153. // CHECK:STDOUT: .AF = %AF.decl
  154. // CHECK:STDOUT: .a = %.loc46
  155. // CHECK:STDOUT: .A = <poisoned>
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: class @B {
  159. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  160. // CHECK:STDOUT: %BF.decl: %BF.type = fn_decl @BF [concrete = constants.%BF] {} {}
  161. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  162. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  163. // CHECK:STDOUT: %.loc16: %B.elem = field_decl b, element0 [concrete]
  164. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %i32} [concrete = constants.%struct_type.b.0a3]
  165. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.b [concrete = constants.%complete_type.ba8]
  166. // CHECK:STDOUT: complete_type_witness = %complete_type
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: !members:
  169. // CHECK:STDOUT: .Self = constants.%B
  170. // CHECK:STDOUT: .C = %C.decl
  171. // CHECK:STDOUT: .BF = %BF.decl
  172. // CHECK:STDOUT: .b = %.loc16
  173. // CHECK:STDOUT: .A = <poisoned>
  174. // CHECK:STDOUT: .B = <poisoned>
  175. // CHECK:STDOUT: .AF = <poisoned>
  176. // CHECK:STDOUT: }
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: class @C {
  179. // CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {}
  180. // CHECK:STDOUT: %DF.decl: %DF.type = fn_decl @DF [concrete = constants.%DF] {} {}
  181. // CHECK:STDOUT: %CF.decl: %CF.type = fn_decl @CF [concrete = constants.%CF] {} {}
  182. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  183. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  184. // CHECK:STDOUT: %.loc42: %C.elem = field_decl c, element0 [concrete]
  185. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c.b66]
  186. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.c [concrete = constants.%complete_type.836]
  187. // CHECK:STDOUT: complete_type_witness = %complete_type
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: !members:
  190. // CHECK:STDOUT: .Self = constants.%C
  191. // CHECK:STDOUT: .D = %D.decl
  192. // CHECK:STDOUT: .CF = %CF.decl
  193. // CHECK:STDOUT: .c = %.loc42
  194. // CHECK:STDOUT: .A = <poisoned>
  195. // CHECK:STDOUT: .B = <poisoned>
  196. // CHECK:STDOUT: .C = <poisoned>
  197. // CHECK:STDOUT: .AF = <poisoned>
  198. // CHECK:STDOUT: .BF = <poisoned>
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: class @D {
  202. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  203. // CHECK:STDOUT: %DF.decl: %DF.type = fn_decl @DF [concrete = constants.%DF] {} {}
  204. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  205. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  206. // CHECK:STDOUT: %.loc24: %D.elem = field_decl d, element0 [concrete]
  207. // CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %i32} [concrete = constants.%struct_type.d.b7b]
  208. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.d [concrete = constants.%complete_type.860]
  209. // CHECK:STDOUT: complete_type_witness = %complete_type
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: !members:
  212. // CHECK:STDOUT: .Self = constants.%D
  213. // CHECK:STDOUT: .F = %F.decl
  214. // CHECK:STDOUT: .DF = %DF.decl
  215. // CHECK:STDOUT: .d = %.loc24
  216. // CHECK:STDOUT: .A = <poisoned>
  217. // CHECK:STDOUT: .B = <poisoned>
  218. // CHECK:STDOUT: .C = <poisoned>
  219. // CHECK:STDOUT: .D = <poisoned>
  220. // CHECK:STDOUT: .AF = <poisoned>
  221. // CHECK:STDOUT: .BF = <poisoned>
  222. // CHECK:STDOUT: .CF = <poisoned>
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: fn @BF();
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: fn @F();
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: fn @DF() {
  230. // CHECK:STDOUT: !entry:
  231. // CHECK:STDOUT: name_binding_decl {
  232. // CHECK:STDOUT: %a.patt: %pattern_type.c10 = binding_pattern a [concrete]
  233. // CHECK:STDOUT: %.loc29_7.1: %pattern_type.c10 = var_pattern %a.patt [concrete]
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT: %a.var: ref %A = var a
  236. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  237. // CHECK:STDOUT: %.loc29_25.1: %struct_type.a.a6c = struct_literal (%int_1)
  238. // CHECK:STDOUT: %impl.elem0.loc29: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  239. // CHECK:STDOUT: %bound_method.loc29_25.1: <bound method> = bound_method %int_1, %impl.elem0.loc29 [concrete = constants.%Convert.bound.ab5]
  240. // CHECK:STDOUT: %specific_fn.loc29: <specific function> = specific_function %impl.elem0.loc29, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  241. // CHECK:STDOUT: %bound_method.loc29_25.2: <bound method> = bound_method %int_1, %specific_fn.loc29 [concrete = constants.%bound_method.9a1]
  242. // CHECK:STDOUT: %int.convert_checked.loc29: init %i32 = call %bound_method.loc29_25.2(%int_1) [concrete = constants.%int_1.5d2]
  243. // CHECK:STDOUT: %.loc29_25.2: init %i32 = converted %int_1, %int.convert_checked.loc29 [concrete = constants.%int_1.5d2]
  244. // CHECK:STDOUT: %.loc29_25.3: ref %i32 = class_element_access %a.var, element0
  245. // CHECK:STDOUT: %.loc29_25.4: init %i32 = initialize_from %.loc29_25.2 to %.loc29_25.3 [concrete = constants.%int_1.5d2]
  246. // CHECK:STDOUT: %.loc29_25.5: init %A = class_init (%.loc29_25.4), %a.var [concrete = constants.%A.val]
  247. // CHECK:STDOUT: %.loc29_7.2: init %A = converted %.loc29_25.1, %.loc29_25.5 [concrete = constants.%A.val]
  248. // CHECK:STDOUT: assign %a.var, %.loc29_7.2
  249. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  250. // CHECK:STDOUT: %a: ref %A = bind_name a, %a.var
  251. // CHECK:STDOUT: name_binding_decl {
  252. // CHECK:STDOUT: %b.patt: %pattern_type.98e = binding_pattern b [concrete]
  253. // CHECK:STDOUT: %.loc30_7.1: %pattern_type.98e = var_pattern %b.patt [concrete]
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT: %b.var: ref %B = var b
  256. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  257. // CHECK:STDOUT: %.loc30_25.1: %struct_type.b.a15 = struct_literal (%int_2)
  258. // CHECK:STDOUT: %impl.elem0.loc30: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  259. // CHECK:STDOUT: %bound_method.loc30_25.1: <bound method> = bound_method %int_2, %impl.elem0.loc30 [concrete = constants.%Convert.bound.ef9]
  260. // CHECK:STDOUT: %specific_fn.loc30: <specific function> = specific_function %impl.elem0.loc30, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  261. // CHECK:STDOUT: %bound_method.loc30_25.2: <bound method> = bound_method %int_2, %specific_fn.loc30 [concrete = constants.%bound_method.b92]
  262. // CHECK:STDOUT: %int.convert_checked.loc30: init %i32 = call %bound_method.loc30_25.2(%int_2) [concrete = constants.%int_2.ef8]
  263. // CHECK:STDOUT: %.loc30_25.2: init %i32 = converted %int_2, %int.convert_checked.loc30 [concrete = constants.%int_2.ef8]
  264. // CHECK:STDOUT: %.loc30_25.3: ref %i32 = class_element_access %b.var, element0
  265. // CHECK:STDOUT: %.loc30_25.4: init %i32 = initialize_from %.loc30_25.2 to %.loc30_25.3 [concrete = constants.%int_2.ef8]
  266. // CHECK:STDOUT: %.loc30_25.5: init %B = class_init (%.loc30_25.4), %b.var [concrete = constants.%B.val]
  267. // CHECK:STDOUT: %.loc30_7.2: init %B = converted %.loc30_25.1, %.loc30_25.5 [concrete = constants.%B.val]
  268. // CHECK:STDOUT: assign %b.var, %.loc30_7.2
  269. // CHECK:STDOUT: %B.ref: type = name_ref B, @A.%B.decl [concrete = constants.%B]
  270. // CHECK:STDOUT: %b: ref %B = bind_name b, %b.var
  271. // CHECK:STDOUT: name_binding_decl {
  272. // CHECK:STDOUT: %c.patt: %pattern_type.6d8 = binding_pattern c [concrete]
  273. // CHECK:STDOUT: %.loc31_7.1: %pattern_type.6d8 = var_pattern %c.patt [concrete]
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT: %c.var: ref %C = var c
  276. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  277. // CHECK:STDOUT: %.loc31_25.1: %struct_type.c.5b8 = struct_literal (%int_3)
  278. // CHECK:STDOUT: %impl.elem0.loc31: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  279. // CHECK:STDOUT: %bound_method.loc31_25.1: <bound method> = bound_method %int_3, %impl.elem0.loc31 [concrete = constants.%Convert.bound.b30]
  280. // CHECK:STDOUT: %specific_fn.loc31: <specific function> = specific_function %impl.elem0.loc31, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  281. // CHECK:STDOUT: %bound_method.loc31_25.2: <bound method> = bound_method %int_3, %specific_fn.loc31 [concrete = constants.%bound_method.047]
  282. // CHECK:STDOUT: %int.convert_checked.loc31: init %i32 = call %bound_method.loc31_25.2(%int_3) [concrete = constants.%int_3.822]
  283. // CHECK:STDOUT: %.loc31_25.2: init %i32 = converted %int_3, %int.convert_checked.loc31 [concrete = constants.%int_3.822]
  284. // CHECK:STDOUT: %.loc31_25.3: ref %i32 = class_element_access %c.var, element0
  285. // CHECK:STDOUT: %.loc31_25.4: init %i32 = initialize_from %.loc31_25.2 to %.loc31_25.3 [concrete = constants.%int_3.822]
  286. // CHECK:STDOUT: %.loc31_25.5: init %C = class_init (%.loc31_25.4), %c.var [concrete = constants.%C.val]
  287. // CHECK:STDOUT: %.loc31_7.2: init %C = converted %.loc31_25.1, %.loc31_25.5 [concrete = constants.%C.val]
  288. // CHECK:STDOUT: assign %c.var, %.loc31_7.2
  289. // CHECK:STDOUT: %C.ref: type = name_ref C, @B.%C.decl [concrete = constants.%C]
  290. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  291. // CHECK:STDOUT: name_binding_decl {
  292. // CHECK:STDOUT: %d.patt: %pattern_type.d58 = binding_pattern d [concrete]
  293. // CHECK:STDOUT: %.loc32_7.1: %pattern_type.d58 = var_pattern %d.patt [concrete]
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: %d.var: ref %D = var d
  296. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  297. // CHECK:STDOUT: %.loc32_25.1: %struct_type.d.3ea = struct_literal (%int_4)
  298. // CHECK:STDOUT: %impl.elem0.loc32: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  299. // CHECK:STDOUT: %bound_method.loc32_25.1: <bound method> = bound_method %int_4, %impl.elem0.loc32 [concrete = constants.%Convert.bound.ac3]
  300. // CHECK:STDOUT: %specific_fn.loc32: <specific function> = specific_function %impl.elem0.loc32, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  301. // CHECK:STDOUT: %bound_method.loc32_25.2: <bound method> = bound_method %int_4, %specific_fn.loc32 [concrete = constants.%bound_method.1da]
  302. // CHECK:STDOUT: %int.convert_checked.loc32: init %i32 = call %bound_method.loc32_25.2(%int_4) [concrete = constants.%int_4.940]
  303. // CHECK:STDOUT: %.loc32_25.2: init %i32 = converted %int_4, %int.convert_checked.loc32 [concrete = constants.%int_4.940]
  304. // CHECK:STDOUT: %.loc32_25.3: ref %i32 = class_element_access %d.var, element0
  305. // CHECK:STDOUT: %.loc32_25.4: init %i32 = initialize_from %.loc32_25.2 to %.loc32_25.3 [concrete = constants.%int_4.940]
  306. // CHECK:STDOUT: %.loc32_25.5: init %D = class_init (%.loc32_25.4), %d.var [concrete = constants.%D.val]
  307. // CHECK:STDOUT: %.loc32_7.2: init %D = converted %.loc32_25.1, %.loc32_25.5 [concrete = constants.%D.val]
  308. // CHECK:STDOUT: assign %d.var, %.loc32_7.2
  309. // CHECK:STDOUT: %D.ref: type = name_ref D, @C.%D.decl [concrete = constants.%D]
  310. // CHECK:STDOUT: %d: ref %D = bind_name d, %d.var
  311. // CHECK:STDOUT: %AF.ref: %AF.type = name_ref AF, @A.%AF.decl [concrete = constants.%AF]
  312. // CHECK:STDOUT: %AF.call: init %empty_tuple.type = call %AF.ref()
  313. // CHECK:STDOUT: %BF.ref: %BF.type = name_ref BF, @B.%BF.decl [concrete = constants.%BF]
  314. // CHECK:STDOUT: %BF.call: init %empty_tuple.type = call %BF.ref()
  315. // CHECK:STDOUT: %CF.ref: %CF.type = name_ref CF, @C.%CF.decl [concrete = constants.%CF]
  316. // CHECK:STDOUT: %CF.call: init %empty_tuple.type = call %CF.ref()
  317. // CHECK:STDOUT: %DF.ref: %DF.type = name_ref DF, @D.%DF.decl [concrete = constants.%DF]
  318. // CHECK:STDOUT: %DF.call: init %empty_tuple.type = call %DF.ref()
  319. // CHECK:STDOUT: return
  320. // CHECK:STDOUT: }
  321. // CHECK:STDOUT:
  322. // CHECK:STDOUT: fn @CF();
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: fn @AF();
  325. // CHECK:STDOUT: