adapter_conversion.carbon 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  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/as/adapter_conversion.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/as/adapter_conversion.carbon
  10. // --- adapt_class.carbon
  11. library "[[@TEST_NAME]]";
  12. class A {
  13. var x: i32;
  14. var y: i32;
  15. fn Make() -> A {
  16. return {.x = 1, .y = 2};
  17. }
  18. }
  19. class B {
  20. adapt A;
  21. }
  22. var a_ref: A = {.x = 1, .y = 2};
  23. let a_val: A = a_ref;
  24. // An `as` conversion to an adapter type preserves the expression category.
  25. let b_val: B = a_val as B;
  26. let b_ptr: B* = &(a_ref as B);
  27. var b_factory: B = A.Make() as B;
  28. // --- adapt_i32.carbon
  29. library "[[@TEST_NAME]]";
  30. class A {
  31. adapt i32;
  32. }
  33. let a: A = (1 as i32) as A;
  34. let n: i32 = a as i32;
  35. // --- multi_level_adapt.carbon
  36. library "[[@TEST_NAME]]";
  37. class A { adapt {}; }
  38. class B { adapt A; }
  39. class C { adapt B; }
  40. class D { adapt C; }
  41. let d: D = {} as D;
  42. // --- init_class_value.carbon
  43. library "[[@TEST_NAME]]";
  44. class A {
  45. var x: i32;
  46. var y: i32;
  47. }
  48. class B {
  49. adapt A;
  50. }
  51. let b_value: B = ({.x = 1, .y = 2} as A) as B;
  52. // --- fail_init_class_variable.carbon
  53. library "[[@TEST_NAME]]";
  54. class A {
  55. var x: i32;
  56. var y: i32;
  57. }
  58. class B {
  59. adapt A;
  60. }
  61. // TODO: Here, we treat `{.x = 1, .y = 2} as A` as a value expression, not an
  62. // initializing expression, so `(...) as B` is a value expression too, requiring
  63. // a copy to perform initialization. It's not clear whether that is the right
  64. // behavior.
  65. // CHECK:STDERR: fail_init_class_variable.carbon:[[@LINE+4]]:17: error: cannot copy value of type `B` [CopyOfUncopyableType]
  66. // CHECK:STDERR: var b_init: B = ({.x = 1, .y = 2} as A) as B;
  67. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. // CHECK:STDERR:
  69. var b_init: B = ({.x = 1, .y = 2} as A) as B;
  70. // --- init_tuple_value.carbon
  71. library "[[@TEST_NAME]]";
  72. class Noncopyable {
  73. // TODO: Ensure this remains non-copyable once we have rules for class copyability.
  74. }
  75. class A {
  76. adapt (i32, Noncopyable);
  77. }
  78. fn F(a: A) {
  79. let a_value: A = (a as (i32, Noncopyable)) as A;
  80. }
  81. // --- fail_init_tuple_variable.carbon
  82. library "[[@TEST_NAME]]";
  83. class Noncopyable {
  84. // TODO: Ensure this remains non-copyable once we have rules for class copyability.
  85. }
  86. class A {
  87. adapt (i32, Noncopyable);
  88. }
  89. fn F(a: A) {
  90. // TODO: Here, we treat `a as (i32, Noncopyable)` as a value expression, not an
  91. // initializing expression, so `(...) as A` is a value expression too, requiring
  92. // a copy to perform initialization. It's not clear whether that is the right
  93. // behavior.
  94. // CHECK:STDERR: fail_init_tuple_variable.carbon:[[@LINE+7]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType]
  95. // CHECK:STDERR: var a_init: A = (a as (i32, Noncopyable)) as A;
  96. // CHECK:STDERR: ^~~~~~~~~~~~~
  97. // CHECK:STDERR: fail_init_tuple_variable.carbon:[[@LINE+4]]:19: note: in copy of `A` [InCopy]
  98. // CHECK:STDERR: var a_init: A = (a as (i32, Noncopyable)) as A;
  99. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100. // CHECK:STDERR:
  101. var a_init: A = (a as (i32, Noncopyable)) as A;
  102. }
  103. // --- fail_adapt_init_from_struct.carbon
  104. library "[[@TEST_NAME]]";
  105. class A {
  106. var x: i32;
  107. }
  108. class B {
  109. adapt A;
  110. }
  111. // We do not try to implicitly convert from the first operand of `as` to the
  112. // adapted type of the second operand.
  113. // CHECK:STDERR: fail_adapt_init_from_struct.carbon:[[@LINE+7]]:12: error: cannot convert expression of type `{.x: Core.IntLiteral}` to `B` with `as` [ConversionFailure]
  114. // CHECK:STDERR: var b: B = {.x = 1} as B;
  115. // CHECK:STDERR: ^~~~~~~~~~~~~
  116. // CHECK:STDERR: fail_adapt_init_from_struct.carbon:[[@LINE+4]]:12: note: type `{.x: Core.IntLiteral}` does not implement interface `Core.As(B)` [MissingImplInMemberAccessNote]
  117. // CHECK:STDERR: var b: B = {.x = 1} as B;
  118. // CHECK:STDERR: ^~~~~~~~~~~~~
  119. // CHECK:STDERR:
  120. var b: B = {.x = 1} as B;
  121. // CHECK:STDOUT: --- adapt_class.carbon
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: constants {
  124. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  125. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  126. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  127. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [concrete]
  128. // CHECK:STDOUT: %Make.type: type = fn_type @Make [concrete]
  129. // CHECK:STDOUT: %Make: %Make.type = struct_value () [concrete]
  130. // CHECK:STDOUT: %struct_type.x.y.871: type = struct_type {.x: %i32, .y: %i32} [concrete]
  131. // CHECK:STDOUT: %complete_type.70a: <witness> = complete_type_witness %struct_type.x.y.871 [concrete]
  132. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  133. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  134. // CHECK:STDOUT: %struct_type.x.y.4cf: type = struct_type {.x: Core.IntLiteral, .y: Core.IntLiteral} [concrete]
  135. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  136. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  137. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.4f9(%int_32) [concrete]
  138. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  139. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  140. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%impl_witness.d39) [concrete]
  141. // CHECK:STDOUT: %.be7: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  142. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  143. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  144. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  145. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  146. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  147. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  148. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  149. // CHECK:STDOUT: %A.val: %A = struct_value (%int_1.5d2, %int_2.ef8) [concrete]
  150. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  151. // CHECK:STDOUT: %ptr.e79: type = ptr_type %B [concrete]
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: imports {
  155. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  156. // CHECK:STDOUT: .Int = %Core.Int
  157. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  158. // CHECK:STDOUT: import Core//prelude
  159. // CHECK:STDOUT: import Core//prelude/...
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: file {
  164. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  165. // CHECK:STDOUT: .Core = imports.%Core
  166. // CHECK:STDOUT: .A = %A.decl
  167. // CHECK:STDOUT: .B = %B.decl
  168. // CHECK:STDOUT: .a_ref = %a_ref
  169. // CHECK:STDOUT: .a_val = %a_val
  170. // CHECK:STDOUT: .b_val = %b_val
  171. // CHECK:STDOUT: .b_ptr = %b_ptr
  172. // CHECK:STDOUT: .b_factory = %b_factory
  173. // CHECK:STDOUT: }
  174. // CHECK:STDOUT: %Core.import = import Core
  175. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  176. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  177. // CHECK:STDOUT: name_binding_decl {
  178. // CHECK:STDOUT: %a_ref.patt: %A = binding_pattern a_ref
  179. // CHECK:STDOUT: %.loc17: %A = var_pattern %a_ref.patt
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT: %a_ref.var: ref %A = var a_ref
  182. // CHECK:STDOUT: %A.ref.loc17: type = name_ref A, %A.decl [concrete = constants.%A]
  183. // CHECK:STDOUT: %a_ref: ref %A = bind_name a_ref, %a_ref.var
  184. // CHECK:STDOUT: name_binding_decl {
  185. // CHECK:STDOUT: %a_val.patt: %A = binding_pattern a_val
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: %A.ref.loc18: type = name_ref A, %A.decl [concrete = constants.%A]
  188. // CHECK:STDOUT: %a_val: ref %A = bind_name a_val, @__global_init.%a_ref.ref.loc18
  189. // CHECK:STDOUT: name_binding_decl {
  190. // CHECK:STDOUT: %b_val.patt: %B = binding_pattern b_val
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT: %B.ref.loc21: type = name_ref B, %B.decl [concrete = constants.%B]
  193. // CHECK:STDOUT: %b_val: ref %B = bind_name b_val, @__global_init.%.loc21_22.2
  194. // CHECK:STDOUT: name_binding_decl {
  195. // CHECK:STDOUT: %b_ptr.patt: %ptr.e79 = binding_pattern b_ptr
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: %.loc22: type = splice_block %ptr [concrete = constants.%ptr.e79] {
  198. // CHECK:STDOUT: %B.ref.loc22: type = name_ref B, %B.decl [concrete = constants.%B]
  199. // CHECK:STDOUT: %ptr: type = ptr_type %B.ref.loc22 [concrete = constants.%ptr.e79]
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT: %b_ptr: %ptr.e79 = bind_name b_ptr, @__global_init.%addr
  202. // CHECK:STDOUT: name_binding_decl {
  203. // CHECK:STDOUT: %b_factory.patt: %B = binding_pattern b_factory
  204. // CHECK:STDOUT: %.loc24: %B = var_pattern %b_factory.patt
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT: %b_factory.var: ref %B = var b_factory
  207. // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, %B.decl [concrete = constants.%B]
  208. // CHECK:STDOUT: %b_factory: ref %B = bind_name b_factory, %b_factory.var
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: class @A {
  212. // CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [concrete]
  213. // CHECK:STDOUT: name_binding_decl {
  214. // CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT: %.var.loc5: ref %A.elem = var <none>
  217. // CHECK:STDOUT: %.loc6_8: %A.elem = field_decl y, element1 [concrete]
  218. // CHECK:STDOUT: name_binding_decl {
  219. // CHECK:STDOUT: %.loc6_3: %A.elem = var_pattern %.loc6_8
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT: %.var.loc6: ref %A.elem = var <none>
  222. // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [concrete = constants.%Make] {
  223. // CHECK:STDOUT: %return.patt: %A = return_slot_pattern
  224. // CHECK:STDOUT: %return.param_patt: %A = out_param_pattern %return.patt, call_param0
  225. // CHECK:STDOUT: } {
  226. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  227. // CHECK:STDOUT: %return.param: ref %A = out_param call_param0
  228. // CHECK:STDOUT: %return: ref %A = return_slot %return.param
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %struct_type.x.y: type = struct_type {.x: %i32, .y: %i32} [concrete = constants.%struct_type.x.y.871]
  231. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.y [concrete = constants.%complete_type.70a]
  232. // CHECK:STDOUT: complete_type_witness = %complete_type
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: !members:
  235. // CHECK:STDOUT: .Self = constants.%A
  236. // CHECK:STDOUT: .x = %.loc5_8
  237. // CHECK:STDOUT: .y = %.loc6_8
  238. // CHECK:STDOUT: .A = <poisoned>
  239. // CHECK:STDOUT: .Make = %Make.decl
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: class @B {
  243. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  244. // CHECK:STDOUT: adapt_decl %A.ref [concrete]
  245. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.x.y.871 [concrete = constants.%complete_type.70a]
  246. // CHECK:STDOUT: complete_type_witness = %complete_type
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: !members:
  249. // CHECK:STDOUT: .Self = constants.%B
  250. // CHECK:STDOUT: .A = <poisoned>
  251. // CHECK:STDOUT: }
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: fn @Make() -> %return.param_patt: %A {
  254. // CHECK:STDOUT: !entry:
  255. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  256. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  257. // CHECK:STDOUT: %.loc9_27.1: %struct_type.x.y.4cf = struct_literal (%int_1, %int_2)
  258. // CHECK:STDOUT: %impl.elem0.loc9_27.1: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  259. // CHECK:STDOUT: %bound_method.loc9_27.1: <bound method> = bound_method %int_1, %impl.elem0.loc9_27.1 [concrete = constants.%Convert.bound.ab5]
  260. // CHECK:STDOUT: %specific_fn.loc9_27.1: <specific function> = specific_function %impl.elem0.loc9_27.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  261. // CHECK:STDOUT: %bound_method.loc9_27.2: <bound method> = bound_method %int_1, %specific_fn.loc9_27.1 [concrete = constants.%bound_method.9a1]
  262. // CHECK:STDOUT: %int.convert_checked.loc9_27.1: init %i32 = call %bound_method.loc9_27.2(%int_1) [concrete = constants.%int_1.5d2]
  263. // CHECK:STDOUT: %.loc9_27.2: init %i32 = converted %int_1, %int.convert_checked.loc9_27.1 [concrete = constants.%int_1.5d2]
  264. // CHECK:STDOUT: %.loc9_27.3: ref %i32 = class_element_access %return, element0
  265. // CHECK:STDOUT: %.loc9_27.4: init %i32 = initialize_from %.loc9_27.2 to %.loc9_27.3 [concrete = constants.%int_1.5d2]
  266. // CHECK:STDOUT: %impl.elem0.loc9_27.2: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  267. // CHECK:STDOUT: %bound_method.loc9_27.3: <bound method> = bound_method %int_2, %impl.elem0.loc9_27.2 [concrete = constants.%Convert.bound.ef9]
  268. // CHECK:STDOUT: %specific_fn.loc9_27.2: <specific function> = specific_function %impl.elem0.loc9_27.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  269. // CHECK:STDOUT: %bound_method.loc9_27.4: <bound method> = bound_method %int_2, %specific_fn.loc9_27.2 [concrete = constants.%bound_method.b92]
  270. // CHECK:STDOUT: %int.convert_checked.loc9_27.2: init %i32 = call %bound_method.loc9_27.4(%int_2) [concrete = constants.%int_2.ef8]
  271. // CHECK:STDOUT: %.loc9_27.5: init %i32 = converted %int_2, %int.convert_checked.loc9_27.2 [concrete = constants.%int_2.ef8]
  272. // CHECK:STDOUT: %.loc9_27.6: ref %i32 = class_element_access %return, element1
  273. // CHECK:STDOUT: %.loc9_27.7: init %i32 = initialize_from %.loc9_27.5 to %.loc9_27.6 [concrete = constants.%int_2.ef8]
  274. // CHECK:STDOUT: %.loc9_27.8: init %A = class_init (%.loc9_27.4, %.loc9_27.7), %return [concrete = constants.%A.val]
  275. // CHECK:STDOUT: %.loc9_28: init %A = converted %.loc9_27.1, %.loc9_27.8 [concrete = constants.%A.val]
  276. // CHECK:STDOUT: return %.loc9_28 to %return
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: fn @__global_init() {
  280. // CHECK:STDOUT: !entry:
  281. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  282. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  283. // CHECK:STDOUT: %.loc17_31.1: %struct_type.x.y.4cf = struct_literal (%int_1, %int_2)
  284. // CHECK:STDOUT: %impl.elem0.loc17_31.1: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  285. // CHECK:STDOUT: %bound_method.loc17_31.1: <bound method> = bound_method %int_1, %impl.elem0.loc17_31.1 [concrete = constants.%Convert.bound.ab5]
  286. // CHECK:STDOUT: %specific_fn.loc17_31.1: <specific function> = specific_function %impl.elem0.loc17_31.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  287. // CHECK:STDOUT: %bound_method.loc17_31.2: <bound method> = bound_method %int_1, %specific_fn.loc17_31.1 [concrete = constants.%bound_method.9a1]
  288. // CHECK:STDOUT: %int.convert_checked.loc17_31.1: init %i32 = call %bound_method.loc17_31.2(%int_1) [concrete = constants.%int_1.5d2]
  289. // CHECK:STDOUT: %.loc17_31.2: init %i32 = converted %int_1, %int.convert_checked.loc17_31.1 [concrete = constants.%int_1.5d2]
  290. // CHECK:STDOUT: %.loc17_31.3: ref %i32 = class_element_access file.%a_ref.var, element0
  291. // CHECK:STDOUT: %.loc17_31.4: init %i32 = initialize_from %.loc17_31.2 to %.loc17_31.3 [concrete = constants.%int_1.5d2]
  292. // CHECK:STDOUT: %impl.elem0.loc17_31.2: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  293. // CHECK:STDOUT: %bound_method.loc17_31.3: <bound method> = bound_method %int_2, %impl.elem0.loc17_31.2 [concrete = constants.%Convert.bound.ef9]
  294. // CHECK:STDOUT: %specific_fn.loc17_31.2: <specific function> = specific_function %impl.elem0.loc17_31.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  295. // CHECK:STDOUT: %bound_method.loc17_31.4: <bound method> = bound_method %int_2, %specific_fn.loc17_31.2 [concrete = constants.%bound_method.b92]
  296. // CHECK:STDOUT: %int.convert_checked.loc17_31.2: init %i32 = call %bound_method.loc17_31.4(%int_2) [concrete = constants.%int_2.ef8]
  297. // CHECK:STDOUT: %.loc17_31.5: init %i32 = converted %int_2, %int.convert_checked.loc17_31.2 [concrete = constants.%int_2.ef8]
  298. // CHECK:STDOUT: %.loc17_31.6: ref %i32 = class_element_access file.%a_ref.var, element1
  299. // CHECK:STDOUT: %.loc17_31.7: init %i32 = initialize_from %.loc17_31.5 to %.loc17_31.6 [concrete = constants.%int_2.ef8]
  300. // CHECK:STDOUT: %.loc17_31.8: init %A = class_init (%.loc17_31.4, %.loc17_31.7), file.%a_ref.var [concrete = constants.%A.val]
  301. // CHECK:STDOUT: %.loc17_1: init %A = converted %.loc17_31.1, %.loc17_31.8 [concrete = constants.%A.val]
  302. // CHECK:STDOUT: assign file.%a_ref.var, %.loc17_1
  303. // CHECK:STDOUT: %a_ref.ref.loc18: ref %A = name_ref a_ref, file.%a_ref
  304. // CHECK:STDOUT: %a_val.ref: ref %A = name_ref a_val, file.%a_val
  305. // CHECK:STDOUT: %B.ref.loc21: type = name_ref B, file.%B.decl [concrete = constants.%B]
  306. // CHECK:STDOUT: %.loc21_22.1: ref %B = as_compatible %a_val.ref
  307. // CHECK:STDOUT: %.loc21_22.2: ref %B = converted %a_val.ref, %.loc21_22.1
  308. // CHECK:STDOUT: %a_ref.ref.loc22: ref %A = name_ref a_ref, file.%a_ref
  309. // CHECK:STDOUT: %B.ref.loc22: type = name_ref B, file.%B.decl [concrete = constants.%B]
  310. // CHECK:STDOUT: %.loc22_25.1: ref %B = as_compatible %a_ref.ref.loc22
  311. // CHECK:STDOUT: %.loc22_25.2: ref %B = converted %a_ref.ref.loc22, %.loc22_25.1
  312. // CHECK:STDOUT: %addr: %ptr.e79 = addr_of %.loc22_25.2
  313. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  314. // CHECK:STDOUT: %Make.ref: %Make.type = name_ref Make, @A.%Make.decl [concrete = constants.%Make]
  315. // CHECK:STDOUT: %.loc24_1: ref %B = splice_block file.%b_factory.var {}
  316. // CHECK:STDOUT: %Make.call: init %A = call %Make.ref() to %.loc24_1
  317. // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [concrete = constants.%B]
  318. // CHECK:STDOUT: %.loc24_29.1: init %B = as_compatible %Make.call
  319. // CHECK:STDOUT: %.loc24_29.2: init %B = converted %Make.call, %.loc24_29.1
  320. // CHECK:STDOUT: assign file.%b_factory.var, %.loc24_29.2
  321. // CHECK:STDOUT: return
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: --- adapt_i32.carbon
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: constants {
  327. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  328. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  329. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  330. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  331. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [concrete]
  332. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  333. // CHECK:STDOUT: %As.type.fd4: type = facet_type <@As, @As(%i32)> [concrete]
  334. // CHECK:STDOUT: %Convert.type.99b: type = fn_type @Convert.1, @As(%i32) [concrete]
  335. // CHECK:STDOUT: %impl_witness.882: <witness> = impl_witness (imports.%Core.import_ref.78a), @impl.686(%int_32) [concrete]
  336. // CHECK:STDOUT: %Convert.type.4fd: type = fn_type @Convert.5, @impl.686(%int_32) [concrete]
  337. // CHECK:STDOUT: %Convert.197: %Convert.type.4fd = struct_value () [concrete]
  338. // CHECK:STDOUT: %As.facet: %As.type.fd4 = facet_value Core.IntLiteral, (%impl_witness.882) [concrete]
  339. // CHECK:STDOUT: %.249: type = fn_type_with_self_type %Convert.type.99b, %As.facet [concrete]
  340. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.197 [concrete]
  341. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.197, @Convert.5(%int_32) [concrete]
  342. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  343. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  344. // CHECK:STDOUT: %int_1.e78: %A = int_value 1 [concrete]
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: imports {
  348. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  349. // CHECK:STDOUT: .Int = %Core.Int
  350. // CHECK:STDOUT: .As = %Core.As
  351. // CHECK:STDOUT: import Core//prelude
  352. // CHECK:STDOUT: import Core//prelude/...
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: file {
  357. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  358. // CHECK:STDOUT: .Core = imports.%Core
  359. // CHECK:STDOUT: .A = %A.decl
  360. // CHECK:STDOUT: .a = %a
  361. // CHECK:STDOUT: .n = %n
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT: %Core.import = import Core
  364. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  365. // CHECK:STDOUT: name_binding_decl {
  366. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [concrete = constants.%A]
  369. // CHECK:STDOUT: %a: %A = bind_name a, @__global_init.%.loc8_23.2
  370. // CHECK:STDOUT: name_binding_decl {
  371. // CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT: %.loc9: type = splice_block %i32 [concrete = constants.%i32] {
  374. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  375. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT: %n: %i32 = bind_name n, @__global_init.%.loc9_16.2
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: class @A {
  381. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  382. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  383. // CHECK:STDOUT: adapt_decl %i32 [concrete]
  384. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%i32.builtin [concrete = constants.%complete_type.f8a]
  385. // CHECK:STDOUT: complete_type_witness = %complete_type
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: !members:
  388. // CHECK:STDOUT: .Self = constants.%A
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: fn @__global_init() {
  392. // CHECK:STDOUT: !entry:
  393. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  394. // CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  395. // CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  396. // CHECK:STDOUT: %impl.elem0: %.249 = impl_witness_access constants.%impl_witness.882, element0 [concrete = constants.%Convert.197]
  397. // CHECK:STDOUT: %bound_method.loc8_15.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  398. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  399. // CHECK:STDOUT: %bound_method.loc8_15.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  400. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_15.2(%int_1) [concrete = constants.%int_1.5d2]
  401. // CHECK:STDOUT: %.loc8_15.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  402. // CHECK:STDOUT: %.loc8_15.2: %i32 = converted %int_1, %.loc8_15.1 [concrete = constants.%int_1.5d2]
  403. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  404. // CHECK:STDOUT: %.loc8_23.1: %A = as_compatible %.loc8_15.2 [concrete = constants.%int_1.e78]
  405. // CHECK:STDOUT: %.loc8_23.2: %A = converted %.loc8_15.2, %.loc8_23.1 [concrete = constants.%int_1.e78]
  406. // CHECK:STDOUT: %a.ref: %A = name_ref a, file.%a
  407. // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  408. // CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  409. // CHECK:STDOUT: %.loc9_16.1: %i32 = as_compatible %a.ref
  410. // CHECK:STDOUT: %.loc9_16.2: %i32 = converted %a.ref, %.loc9_16.1
  411. // CHECK:STDOUT: return
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: --- multi_level_adapt.carbon
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: constants {
  417. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  418. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  419. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  420. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  421. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  422. // CHECK:STDOUT: %D: type = class_type @D [concrete]
  423. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  424. // CHECK:STDOUT: %D.val: %D = struct_value () [concrete]
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: imports {
  428. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  429. // CHECK:STDOUT: import Core//prelude
  430. // CHECK:STDOUT: import Core//prelude/...
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: file {
  435. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  436. // CHECK:STDOUT: .Core = imports.%Core
  437. // CHECK:STDOUT: .A = %A.decl
  438. // CHECK:STDOUT: .B = %B.decl
  439. // CHECK:STDOUT: .C = %C.decl
  440. // CHECK:STDOUT: .D = %D.decl
  441. // CHECK:STDOUT: .d = %d
  442. // CHECK:STDOUT: }
  443. // CHECK:STDOUT: %Core.import = import Core
  444. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  445. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  446. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  447. // CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {}
  448. // CHECK:STDOUT: name_binding_decl {
  449. // CHECK:STDOUT: %d.patt: %D = binding_pattern d
  450. // CHECK:STDOUT: }
  451. // CHECK:STDOUT: %D.ref: type = name_ref D, %D.decl [concrete = constants.%D]
  452. // CHECK:STDOUT: %d: %D = bind_name d, @__global_init.%.loc9_15.2
  453. // CHECK:STDOUT: }
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: class @A {
  456. // CHECK:STDOUT: %.loc4_18: %empty_struct_type = struct_literal ()
  457. // CHECK:STDOUT: %.loc4_19: type = converted %.loc4_18, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  458. // CHECK:STDOUT: adapt_decl %.loc4_19 [concrete]
  459. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  460. // CHECK:STDOUT: complete_type_witness = %complete_type
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: !members:
  463. // CHECK:STDOUT: .Self = constants.%A
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: class @B {
  467. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  468. // CHECK:STDOUT: adapt_decl %A.ref [concrete]
  469. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  470. // CHECK:STDOUT: complete_type_witness = %complete_type
  471. // CHECK:STDOUT:
  472. // CHECK:STDOUT: !members:
  473. // CHECK:STDOUT: .Self = constants.%B
  474. // CHECK:STDOUT: .A = <poisoned>
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT:
  477. // CHECK:STDOUT: class @C {
  478. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  479. // CHECK:STDOUT: adapt_decl %B.ref [concrete]
  480. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  481. // CHECK:STDOUT: complete_type_witness = %complete_type
  482. // CHECK:STDOUT:
  483. // CHECK:STDOUT: !members:
  484. // CHECK:STDOUT: .Self = constants.%C
  485. // CHECK:STDOUT: .B = <poisoned>
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT:
  488. // CHECK:STDOUT: class @D {
  489. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  490. // CHECK:STDOUT: adapt_decl %C.ref [concrete]
  491. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  492. // CHECK:STDOUT: complete_type_witness = %complete_type
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: !members:
  495. // CHECK:STDOUT: .Self = constants.%D
  496. // CHECK:STDOUT: .C = <poisoned>
  497. // CHECK:STDOUT: }
  498. // CHECK:STDOUT:
  499. // CHECK:STDOUT: fn @__global_init() {
  500. // CHECK:STDOUT: !entry:
  501. // CHECK:STDOUT: %.loc9_13: %empty_struct_type = struct_literal ()
  502. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D]
  503. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  504. // CHECK:STDOUT: %.loc9_15.1: %D = as_compatible %empty_struct [concrete = constants.%D.val]
  505. // CHECK:STDOUT: %.loc9_15.2: %D = converted %.loc9_13, %.loc9_15.1 [concrete = constants.%D.val]
  506. // CHECK:STDOUT: return
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: --- init_class_value.carbon
  510. // CHECK:STDOUT:
  511. // CHECK:STDOUT: constants {
  512. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  513. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  514. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  515. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [concrete]
  516. // CHECK:STDOUT: %struct_type.x.y.871: type = struct_type {.x: %i32, .y: %i32} [concrete]
  517. // CHECK:STDOUT: %complete_type.70a: <witness> = complete_type_witness %struct_type.x.y.871 [concrete]
  518. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  519. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  520. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  521. // CHECK:STDOUT: %struct_type.x.y.4cf: type = struct_type {.x: Core.IntLiteral, .y: Core.IntLiteral} [concrete]
  522. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  523. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  524. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.4f9(%int_32) [concrete]
  525. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  526. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  527. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%impl_witness.d39) [concrete]
  528. // CHECK:STDOUT: %.be7: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  529. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  530. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  531. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  532. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  533. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  534. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  535. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  536. // CHECK:STDOUT: %A.val: %A = struct_value (%int_1.5d2, %int_2.ef8) [concrete]
  537. // CHECK:STDOUT: }
  538. // CHECK:STDOUT:
  539. // CHECK:STDOUT: imports {
  540. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  541. // CHECK:STDOUT: .Int = %Core.Int
  542. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  543. // CHECK:STDOUT: import Core//prelude
  544. // CHECK:STDOUT: import Core//prelude/...
  545. // CHECK:STDOUT: }
  546. // CHECK:STDOUT: }
  547. // CHECK:STDOUT:
  548. // CHECK:STDOUT: file {
  549. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  550. // CHECK:STDOUT: .Core = imports.%Core
  551. // CHECK:STDOUT: .A = %A.decl
  552. // CHECK:STDOUT: .B = %B.decl
  553. // CHECK:STDOUT: .b_value = %b_value
  554. // CHECK:STDOUT: }
  555. // CHECK:STDOUT: %Core.import = import Core
  556. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  557. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  558. // CHECK:STDOUT: name_binding_decl {
  559. // CHECK:STDOUT: %b_value.patt: %B = binding_pattern b_value
  560. // CHECK:STDOUT: }
  561. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [concrete = constants.%B]
  562. // CHECK:STDOUT: %b_value: ref %B = bind_name b_value, @__global_init.%.loc13_42.2
  563. // CHECK:STDOUT: }
  564. // CHECK:STDOUT:
  565. // CHECK:STDOUT: class @A {
  566. // CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [concrete]
  567. // CHECK:STDOUT: name_binding_decl {
  568. // CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT: %.var.loc5: ref %A.elem = var <none>
  571. // CHECK:STDOUT: %.loc6_8: %A.elem = field_decl y, element1 [concrete]
  572. // CHECK:STDOUT: name_binding_decl {
  573. // CHECK:STDOUT: %.loc6_3: %A.elem = var_pattern %.loc6_8
  574. // CHECK:STDOUT: }
  575. // CHECK:STDOUT: %.var.loc6: ref %A.elem = var <none>
  576. // CHECK:STDOUT: %struct_type.x.y: type = struct_type {.x: %i32, .y: %i32} [concrete = constants.%struct_type.x.y.871]
  577. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.y [concrete = constants.%complete_type.70a]
  578. // CHECK:STDOUT: complete_type_witness = %complete_type
  579. // CHECK:STDOUT:
  580. // CHECK:STDOUT: !members:
  581. // CHECK:STDOUT: .Self = constants.%A
  582. // CHECK:STDOUT: .x = %.loc5_8
  583. // CHECK:STDOUT: .y = %.loc6_8
  584. // CHECK:STDOUT: }
  585. // CHECK:STDOUT:
  586. // CHECK:STDOUT: class @B {
  587. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  588. // CHECK:STDOUT: adapt_decl %A.ref [concrete]
  589. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.x.y.871 [concrete = constants.%complete_type.70a]
  590. // CHECK:STDOUT: complete_type_witness = %complete_type
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: !members:
  593. // CHECK:STDOUT: .Self = constants.%B
  594. // CHECK:STDOUT: .A = <poisoned>
  595. // CHECK:STDOUT: }
  596. // CHECK:STDOUT:
  597. // CHECK:STDOUT: fn @__global_init() {
  598. // CHECK:STDOUT: !entry:
  599. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  600. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  601. // CHECK:STDOUT: %.loc13_34.1: %struct_type.x.y.4cf = struct_literal (%int_1, %int_2)
  602. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  603. // CHECK:STDOUT: %impl.elem0.loc13_34.1: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  604. // CHECK:STDOUT: %bound_method.loc13_34.1: <bound method> = bound_method %int_1, %impl.elem0.loc13_34.1 [concrete = constants.%Convert.bound.ab5]
  605. // CHECK:STDOUT: %specific_fn.loc13_34.1: <specific function> = specific_function %impl.elem0.loc13_34.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  606. // CHECK:STDOUT: %bound_method.loc13_34.2: <bound method> = bound_method %int_1, %specific_fn.loc13_34.1 [concrete = constants.%bound_method.9a1]
  607. // CHECK:STDOUT: %int.convert_checked.loc13_34.1: init %i32 = call %bound_method.loc13_34.2(%int_1) [concrete = constants.%int_1.5d2]
  608. // CHECK:STDOUT: %.loc13_34.2: init %i32 = converted %int_1, %int.convert_checked.loc13_34.1 [concrete = constants.%int_1.5d2]
  609. // CHECK:STDOUT: %.loc13_34.3: ref %A = temporary_storage
  610. // CHECK:STDOUT: %.loc13_34.4: ref %i32 = class_element_access %.loc13_34.3, element0
  611. // CHECK:STDOUT: %.loc13_34.5: init %i32 = initialize_from %.loc13_34.2 to %.loc13_34.4 [concrete = constants.%int_1.5d2]
  612. // CHECK:STDOUT: %impl.elem0.loc13_34.2: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  613. // CHECK:STDOUT: %bound_method.loc13_34.3: <bound method> = bound_method %int_2, %impl.elem0.loc13_34.2 [concrete = constants.%Convert.bound.ef9]
  614. // CHECK:STDOUT: %specific_fn.loc13_34.2: <specific function> = specific_function %impl.elem0.loc13_34.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  615. // CHECK:STDOUT: %bound_method.loc13_34.4: <bound method> = bound_method %int_2, %specific_fn.loc13_34.2 [concrete = constants.%bound_method.b92]
  616. // CHECK:STDOUT: %int.convert_checked.loc13_34.2: init %i32 = call %bound_method.loc13_34.4(%int_2) [concrete = constants.%int_2.ef8]
  617. // CHECK:STDOUT: %.loc13_34.6: init %i32 = converted %int_2, %int.convert_checked.loc13_34.2 [concrete = constants.%int_2.ef8]
  618. // CHECK:STDOUT: %.loc13_34.7: ref %i32 = class_element_access %.loc13_34.3, element1
  619. // CHECK:STDOUT: %.loc13_34.8: init %i32 = initialize_from %.loc13_34.6 to %.loc13_34.7 [concrete = constants.%int_2.ef8]
  620. // CHECK:STDOUT: %.loc13_34.9: init %A = class_init (%.loc13_34.5, %.loc13_34.8), %.loc13_34.3 [concrete = constants.%A.val]
  621. // CHECK:STDOUT: %.loc13_34.10: ref %A = temporary %.loc13_34.3, %.loc13_34.9
  622. // CHECK:STDOUT: %.loc13_36: ref %A = converted %.loc13_34.1, %.loc13_34.10
  623. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  624. // CHECK:STDOUT: %.loc13_42.1: ref %B = as_compatible %.loc13_36
  625. // CHECK:STDOUT: %.loc13_42.2: ref %B = converted %.loc13_36, %.loc13_42.1
  626. // CHECK:STDOUT: return
  627. // CHECK:STDOUT: }
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: --- fail_init_class_variable.carbon
  630. // CHECK:STDOUT:
  631. // CHECK:STDOUT: constants {
  632. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  633. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  634. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  635. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [concrete]
  636. // CHECK:STDOUT: %struct_type.x.y.871: type = struct_type {.x: %i32, .y: %i32} [concrete]
  637. // CHECK:STDOUT: %complete_type.70a: <witness> = complete_type_witness %struct_type.x.y.871 [concrete]
  638. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  639. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  640. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  641. // CHECK:STDOUT: %struct_type.x.y.4cf: type = struct_type {.x: Core.IntLiteral, .y: Core.IntLiteral} [concrete]
  642. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  643. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  644. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.4f9(%int_32) [concrete]
  645. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  646. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  647. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%impl_witness.d39) [concrete]
  648. // CHECK:STDOUT: %.be7: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  649. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  650. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  651. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  652. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  653. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  654. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  655. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  656. // CHECK:STDOUT: %A.val: %A = struct_value (%int_1.5d2, %int_2.ef8) [concrete]
  657. // CHECK:STDOUT: }
  658. // CHECK:STDOUT:
  659. // CHECK:STDOUT: imports {
  660. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  661. // CHECK:STDOUT: .Int = %Core.Int
  662. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  663. // CHECK:STDOUT: import Core//prelude
  664. // CHECK:STDOUT: import Core//prelude/...
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT: }
  667. // CHECK:STDOUT:
  668. // CHECK:STDOUT: file {
  669. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  670. // CHECK:STDOUT: .Core = imports.%Core
  671. // CHECK:STDOUT: .A = %A.decl
  672. // CHECK:STDOUT: .B = %B.decl
  673. // CHECK:STDOUT: .b_init = %b_init
  674. // CHECK:STDOUT: }
  675. // CHECK:STDOUT: %Core.import = import Core
  676. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  677. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  678. // CHECK:STDOUT: name_binding_decl {
  679. // CHECK:STDOUT: %b_init.patt: %B = binding_pattern b_init
  680. // CHECK:STDOUT: %.loc22: %B = var_pattern %b_init.patt
  681. // CHECK:STDOUT: }
  682. // CHECK:STDOUT: %b_init.var: ref %B = var b_init
  683. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [concrete = constants.%B]
  684. // CHECK:STDOUT: %b_init: ref %B = bind_name b_init, %b_init.var
  685. // CHECK:STDOUT: }
  686. // CHECK:STDOUT:
  687. // CHECK:STDOUT: class @A {
  688. // CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [concrete]
  689. // CHECK:STDOUT: name_binding_decl {
  690. // CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8
  691. // CHECK:STDOUT: }
  692. // CHECK:STDOUT: %.var.loc5: ref %A.elem = var <none>
  693. // CHECK:STDOUT: %.loc6_8: %A.elem = field_decl y, element1 [concrete]
  694. // CHECK:STDOUT: name_binding_decl {
  695. // CHECK:STDOUT: %.loc6_3: %A.elem = var_pattern %.loc6_8
  696. // CHECK:STDOUT: }
  697. // CHECK:STDOUT: %.var.loc6: ref %A.elem = var <none>
  698. // CHECK:STDOUT: %struct_type.x.y: type = struct_type {.x: %i32, .y: %i32} [concrete = constants.%struct_type.x.y.871]
  699. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.y [concrete = constants.%complete_type.70a]
  700. // CHECK:STDOUT: complete_type_witness = %complete_type
  701. // CHECK:STDOUT:
  702. // CHECK:STDOUT: !members:
  703. // CHECK:STDOUT: .Self = constants.%A
  704. // CHECK:STDOUT: .x = %.loc5_8
  705. // CHECK:STDOUT: .y = %.loc6_8
  706. // CHECK:STDOUT: }
  707. // CHECK:STDOUT:
  708. // CHECK:STDOUT: class @B {
  709. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  710. // CHECK:STDOUT: adapt_decl %A.ref [concrete]
  711. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.x.y.871 [concrete = constants.%complete_type.70a]
  712. // CHECK:STDOUT: complete_type_witness = %complete_type
  713. // CHECK:STDOUT:
  714. // CHECK:STDOUT: !members:
  715. // CHECK:STDOUT: .Self = constants.%B
  716. // CHECK:STDOUT: .A = <poisoned>
  717. // CHECK:STDOUT: }
  718. // CHECK:STDOUT:
  719. // CHECK:STDOUT: fn @__global_init() {
  720. // CHECK:STDOUT: !entry:
  721. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  722. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  723. // CHECK:STDOUT: %.loc22_33.1: %struct_type.x.y.4cf = struct_literal (%int_1, %int_2)
  724. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  725. // CHECK:STDOUT: %impl.elem0.loc22_33.1: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  726. // CHECK:STDOUT: %bound_method.loc22_33.1: <bound method> = bound_method %int_1, %impl.elem0.loc22_33.1 [concrete = constants.%Convert.bound.ab5]
  727. // CHECK:STDOUT: %specific_fn.loc22_33.1: <specific function> = specific_function %impl.elem0.loc22_33.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  728. // CHECK:STDOUT: %bound_method.loc22_33.2: <bound method> = bound_method %int_1, %specific_fn.loc22_33.1 [concrete = constants.%bound_method.9a1]
  729. // CHECK:STDOUT: %int.convert_checked.loc22_33.1: init %i32 = call %bound_method.loc22_33.2(%int_1) [concrete = constants.%int_1.5d2]
  730. // CHECK:STDOUT: %.loc22_33.2: init %i32 = converted %int_1, %int.convert_checked.loc22_33.1 [concrete = constants.%int_1.5d2]
  731. // CHECK:STDOUT: %.loc22_33.3: ref %A = temporary_storage
  732. // CHECK:STDOUT: %.loc22_33.4: ref %i32 = class_element_access %.loc22_33.3, element0
  733. // CHECK:STDOUT: %.loc22_33.5: init %i32 = initialize_from %.loc22_33.2 to %.loc22_33.4 [concrete = constants.%int_1.5d2]
  734. // CHECK:STDOUT: %impl.elem0.loc22_33.2: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  735. // CHECK:STDOUT: %bound_method.loc22_33.3: <bound method> = bound_method %int_2, %impl.elem0.loc22_33.2 [concrete = constants.%Convert.bound.ef9]
  736. // CHECK:STDOUT: %specific_fn.loc22_33.2: <specific function> = specific_function %impl.elem0.loc22_33.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  737. // CHECK:STDOUT: %bound_method.loc22_33.4: <bound method> = bound_method %int_2, %specific_fn.loc22_33.2 [concrete = constants.%bound_method.b92]
  738. // CHECK:STDOUT: %int.convert_checked.loc22_33.2: init %i32 = call %bound_method.loc22_33.4(%int_2) [concrete = constants.%int_2.ef8]
  739. // CHECK:STDOUT: %.loc22_33.6: init %i32 = converted %int_2, %int.convert_checked.loc22_33.2 [concrete = constants.%int_2.ef8]
  740. // CHECK:STDOUT: %.loc22_33.7: ref %i32 = class_element_access %.loc22_33.3, element1
  741. // CHECK:STDOUT: %.loc22_33.8: init %i32 = initialize_from %.loc22_33.6 to %.loc22_33.7 [concrete = constants.%int_2.ef8]
  742. // CHECK:STDOUT: %.loc22_33.9: init %A = class_init (%.loc22_33.5, %.loc22_33.8), %.loc22_33.3 [concrete = constants.%A.val]
  743. // CHECK:STDOUT: %.loc22_33.10: ref %A = temporary %.loc22_33.3, %.loc22_33.9
  744. // CHECK:STDOUT: %.loc22_35: ref %A = converted %.loc22_33.1, %.loc22_33.10
  745. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  746. // CHECK:STDOUT: %.loc22_41.1: ref %B = as_compatible %.loc22_35
  747. // CHECK:STDOUT: %.loc22_41.2: ref %B = converted %.loc22_35, %.loc22_41.1
  748. // CHECK:STDOUT: %.loc22_41.3: %B = bind_value %.loc22_41.2
  749. // CHECK:STDOUT: assign file.%b_init.var, <error>
  750. // CHECK:STDOUT: return
  751. // CHECK:STDOUT: }
  752. // CHECK:STDOUT:
  753. // CHECK:STDOUT: --- init_tuple_value.carbon
  754. // CHECK:STDOUT:
  755. // CHECK:STDOUT: constants {
  756. // CHECK:STDOUT: %Noncopyable: type = class_type @Noncopyable [concrete]
  757. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  758. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  759. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  760. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  761. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  762. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  763. // CHECK:STDOUT: %tuple.type.560: type = tuple_type (%i32, %Noncopyable) [concrete]
  764. // CHECK:STDOUT: %complete_type.ce5: <witness> = complete_type_witness %tuple.type.560 [concrete]
  765. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  766. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  767. // CHECK:STDOUT: }
  768. // CHECK:STDOUT:
  769. // CHECK:STDOUT: imports {
  770. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  771. // CHECK:STDOUT: .Int = %Core.Int
  772. // CHECK:STDOUT: import Core//prelude
  773. // CHECK:STDOUT: import Core//prelude/...
  774. // CHECK:STDOUT: }
  775. // CHECK:STDOUT: }
  776. // CHECK:STDOUT:
  777. // CHECK:STDOUT: file {
  778. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  779. // CHECK:STDOUT: .Core = imports.%Core
  780. // CHECK:STDOUT: .Noncopyable = %Noncopyable.decl
  781. // CHECK:STDOUT: .A = %A.decl
  782. // CHECK:STDOUT: .F = %F.decl
  783. // CHECK:STDOUT: }
  784. // CHECK:STDOUT: %Core.import = import Core
  785. // CHECK:STDOUT: %Noncopyable.decl: type = class_decl @Noncopyable [concrete = constants.%Noncopyable] {} {}
  786. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  787. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  788. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  789. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, call_param0
  790. // CHECK:STDOUT: } {
  791. // CHECK:STDOUT: %a.param: %A = value_param call_param0
  792. // CHECK:STDOUT: %A.ref.loc12: type = name_ref A, file.%A.decl [concrete = constants.%A]
  793. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  794. // CHECK:STDOUT: }
  795. // CHECK:STDOUT: }
  796. // CHECK:STDOUT:
  797. // CHECK:STDOUT: class @Noncopyable {
  798. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  799. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  800. // CHECK:STDOUT: complete_type_witness = %complete_type
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: !members:
  803. // CHECK:STDOUT: .Self = constants.%Noncopyable
  804. // CHECK:STDOUT: }
  805. // CHECK:STDOUT:
  806. // CHECK:STDOUT: class @A {
  807. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  808. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  809. // CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [concrete = constants.%Noncopyable]
  810. // CHECK:STDOUT: %.loc9_26: %tuple.type.24b = tuple_literal (%i32, %Noncopyable.ref)
  811. // CHECK:STDOUT: %.loc9_27: type = converted %.loc9_26, constants.%tuple.type.560 [concrete = constants.%tuple.type.560]
  812. // CHECK:STDOUT: adapt_decl %.loc9_27 [concrete]
  813. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%tuple.type.560 [concrete = constants.%complete_type.ce5]
  814. // CHECK:STDOUT: complete_type_witness = %complete_type
  815. // CHECK:STDOUT:
  816. // CHECK:STDOUT: !members:
  817. // CHECK:STDOUT: .Self = constants.%A
  818. // CHECK:STDOUT: .Noncopyable = <poisoned>
  819. // CHECK:STDOUT: }
  820. // CHECK:STDOUT:
  821. // CHECK:STDOUT: fn @F(%a.param_patt: %A) {
  822. // CHECK:STDOUT: !entry:
  823. // CHECK:STDOUT: name_binding_decl {
  824. // CHECK:STDOUT: %a_value.patt: %A = binding_pattern a_value
  825. // CHECK:STDOUT: }
  826. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  827. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  828. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  829. // CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [concrete = constants.%Noncopyable]
  830. // CHECK:STDOUT: %.loc13_43.1: %tuple.type.24b = tuple_literal (%i32, %Noncopyable.ref)
  831. // CHECK:STDOUT: %.loc13_43.2: type = converted %.loc13_43.1, constants.%tuple.type.560 [concrete = constants.%tuple.type.560]
  832. // CHECK:STDOUT: %.loc13_23.1: %tuple.type.560 = as_compatible %a.ref
  833. // CHECK:STDOUT: %.loc13_23.2: %tuple.type.560 = converted %a.ref, %.loc13_23.1
  834. // CHECK:STDOUT: %A.ref.loc13_49: type = name_ref A, file.%A.decl [concrete = constants.%A]
  835. // CHECK:STDOUT: %.loc13_46.1: %A = as_compatible %.loc13_23.2
  836. // CHECK:STDOUT: %.loc13_46.2: %A = converted %.loc13_23.2, %.loc13_46.1
  837. // CHECK:STDOUT: %A.ref.loc13_16: type = name_ref A, file.%A.decl [concrete = constants.%A]
  838. // CHECK:STDOUT: %a_value: %A = bind_name a_value, %.loc13_46.2
  839. // CHECK:STDOUT: return
  840. // CHECK:STDOUT: }
  841. // CHECK:STDOUT:
  842. // CHECK:STDOUT: --- fail_init_tuple_variable.carbon
  843. // CHECK:STDOUT:
  844. // CHECK:STDOUT: constants {
  845. // CHECK:STDOUT: %Noncopyable: type = class_type @Noncopyable [concrete]
  846. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  847. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  848. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  849. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  850. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  851. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  852. // CHECK:STDOUT: %tuple.type.560: type = tuple_type (%i32, %Noncopyable) [concrete]
  853. // CHECK:STDOUT: %complete_type.ce5: <witness> = complete_type_witness %tuple.type.560 [concrete]
  854. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  855. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  856. // CHECK:STDOUT: }
  857. // CHECK:STDOUT:
  858. // CHECK:STDOUT: imports {
  859. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  860. // CHECK:STDOUT: .Int = %Core.Int
  861. // CHECK:STDOUT: import Core//prelude
  862. // CHECK:STDOUT: import Core//prelude/...
  863. // CHECK:STDOUT: }
  864. // CHECK:STDOUT: }
  865. // CHECK:STDOUT:
  866. // CHECK:STDOUT: file {
  867. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  868. // CHECK:STDOUT: .Core = imports.%Core
  869. // CHECK:STDOUT: .Noncopyable = %Noncopyable.decl
  870. // CHECK:STDOUT: .A = %A.decl
  871. // CHECK:STDOUT: .F = %F.decl
  872. // CHECK:STDOUT: }
  873. // CHECK:STDOUT: %Core.import = import Core
  874. // CHECK:STDOUT: %Noncopyable.decl: type = class_decl @Noncopyable [concrete = constants.%Noncopyable] {} {}
  875. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  876. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  877. // CHECK:STDOUT: %a.patt: %A = binding_pattern a
  878. // CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, call_param0
  879. // CHECK:STDOUT: } {
  880. // CHECK:STDOUT: %a.param: %A = value_param call_param0
  881. // CHECK:STDOUT: %A.ref.loc12: type = name_ref A, file.%A.decl [concrete = constants.%A]
  882. // CHECK:STDOUT: %a: %A = bind_name a, %a.param
  883. // CHECK:STDOUT: }
  884. // CHECK:STDOUT: }
  885. // CHECK:STDOUT:
  886. // CHECK:STDOUT: class @Noncopyable {
  887. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  888. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  889. // CHECK:STDOUT: complete_type_witness = %complete_type
  890. // CHECK:STDOUT:
  891. // CHECK:STDOUT: !members:
  892. // CHECK:STDOUT: .Self = constants.%Noncopyable
  893. // CHECK:STDOUT: }
  894. // CHECK:STDOUT:
  895. // CHECK:STDOUT: class @A {
  896. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  897. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  898. // CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [concrete = constants.%Noncopyable]
  899. // CHECK:STDOUT: %.loc9_26: %tuple.type.24b = tuple_literal (%i32, %Noncopyable.ref)
  900. // CHECK:STDOUT: %.loc9_27: type = converted %.loc9_26, constants.%tuple.type.560 [concrete = constants.%tuple.type.560]
  901. // CHECK:STDOUT: adapt_decl %.loc9_27 [concrete]
  902. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%tuple.type.560 [concrete = constants.%complete_type.ce5]
  903. // CHECK:STDOUT: complete_type_witness = %complete_type
  904. // CHECK:STDOUT:
  905. // CHECK:STDOUT: !members:
  906. // CHECK:STDOUT: .Self = constants.%A
  907. // CHECK:STDOUT: .Noncopyable = <poisoned>
  908. // CHECK:STDOUT: }
  909. // CHECK:STDOUT:
  910. // CHECK:STDOUT: fn @F(%a.param_patt: %A) {
  911. // CHECK:STDOUT: !entry:
  912. // CHECK:STDOUT: name_binding_decl {
  913. // CHECK:STDOUT: %a_init.patt: %A = binding_pattern a_init
  914. // CHECK:STDOUT: %.loc25_3.1: %A = var_pattern %a_init.patt
  915. // CHECK:STDOUT: }
  916. // CHECK:STDOUT: %a_init.var: ref %A = var a_init
  917. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  918. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  919. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  920. // CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [concrete = constants.%Noncopyable]
  921. // CHECK:STDOUT: %.loc25_42.1: %tuple.type.24b = tuple_literal (%i32, %Noncopyable.ref)
  922. // CHECK:STDOUT: %.loc25_42.2: type = converted %.loc25_42.1, constants.%tuple.type.560 [concrete = constants.%tuple.type.560]
  923. // CHECK:STDOUT: %.loc25_22.1: %tuple.type.560 = as_compatible %a.ref
  924. // CHECK:STDOUT: %.loc25_22.2: %tuple.type.560 = converted %a.ref, %.loc25_22.1
  925. // CHECK:STDOUT: %A.ref.loc25_48: type = name_ref A, file.%A.decl [concrete = constants.%A]
  926. // CHECK:STDOUT: %.loc25_45.1: %A = as_compatible %.loc25_22.2
  927. // CHECK:STDOUT: %.loc25_45.2: %A = converted %.loc25_22.2, %.loc25_45.1
  928. // CHECK:STDOUT: %.loc25_3.2: %tuple.type.560 = as_compatible %.loc25_45.2
  929. // CHECK:STDOUT: %tuple.elem0.loc25_3.1: %i32 = tuple_access %.loc25_3.2, element0
  930. // CHECK:STDOUT: %.loc25_3.3: ref %tuple.type.560 = as_compatible %a_init.var
  931. // CHECK:STDOUT: %tuple.elem0.loc25_3.2: ref %i32 = tuple_access %.loc25_3.3, element0
  932. // CHECK:STDOUT: %.loc25_3.4: init %i32 = initialize_from %tuple.elem0.loc25_3.1 to %tuple.elem0.loc25_3.2
  933. // CHECK:STDOUT: %tuple.elem1: %Noncopyable = tuple_access %.loc25_3.2, element1
  934. // CHECK:STDOUT: assign %a_init.var, <error>
  935. // CHECK:STDOUT: %A.ref.loc25_15: type = name_ref A, file.%A.decl [concrete = constants.%A]
  936. // CHECK:STDOUT: %a_init: ref %A = bind_name a_init, %a_init.var
  937. // CHECK:STDOUT: return
  938. // CHECK:STDOUT: }
  939. // CHECK:STDOUT:
  940. // CHECK:STDOUT: --- fail_adapt_init_from_struct.carbon
  941. // CHECK:STDOUT:
  942. // CHECK:STDOUT: constants {
  943. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  944. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  945. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  946. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [concrete]
  947. // CHECK:STDOUT: %struct_type.x.ed6: type = struct_type {.x: %i32} [concrete]
  948. // CHECK:STDOUT: %complete_type.1ec: <witness> = complete_type_witness %struct_type.x.ed6 [concrete]
  949. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  950. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  951. // CHECK:STDOUT: %struct_type.x.c96: type = struct_type {.x: Core.IntLiteral} [concrete]
  952. // CHECK:STDOUT: }
  953. // CHECK:STDOUT:
  954. // CHECK:STDOUT: imports {
  955. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  956. // CHECK:STDOUT: .Int = %Core.Int
  957. // CHECK:STDOUT: .As = %Core.As
  958. // CHECK:STDOUT: import Core//prelude
  959. // CHECK:STDOUT: import Core//prelude/...
  960. // CHECK:STDOUT: }
  961. // CHECK:STDOUT: }
  962. // CHECK:STDOUT:
  963. // CHECK:STDOUT: file {
  964. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  965. // CHECK:STDOUT: .Core = imports.%Core
  966. // CHECK:STDOUT: .A = %A.decl
  967. // CHECK:STDOUT: .B = %B.decl
  968. // CHECK:STDOUT: .b = %b
  969. // CHECK:STDOUT: }
  970. // CHECK:STDOUT: %Core.import = import Core
  971. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  972. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  973. // CHECK:STDOUT: name_binding_decl {
  974. // CHECK:STDOUT: %b.patt: %B = binding_pattern b
  975. // CHECK:STDOUT: %.loc22: %B = var_pattern %b.patt
  976. // CHECK:STDOUT: }
  977. // CHECK:STDOUT: %b.var: ref %B = var b
  978. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [concrete = constants.%B]
  979. // CHECK:STDOUT: %b: ref %B = bind_name b, %b.var
  980. // CHECK:STDOUT: }
  981. // CHECK:STDOUT:
  982. // CHECK:STDOUT: class @A {
  983. // CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [concrete]
  984. // CHECK:STDOUT: name_binding_decl {
  985. // CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8
  986. // CHECK:STDOUT: }
  987. // CHECK:STDOUT: %.var: ref %A.elem = var <none>
  988. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %i32} [concrete = constants.%struct_type.x.ed6]
  989. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete = constants.%complete_type.1ec]
  990. // CHECK:STDOUT: complete_type_witness = %complete_type
  991. // CHECK:STDOUT:
  992. // CHECK:STDOUT: !members:
  993. // CHECK:STDOUT: .Self = constants.%A
  994. // CHECK:STDOUT: .x = %.loc5_8
  995. // CHECK:STDOUT: }
  996. // CHECK:STDOUT:
  997. // CHECK:STDOUT: class @B {
  998. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  999. // CHECK:STDOUT: adapt_decl %A.ref [concrete]
  1000. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.x.ed6 [concrete = constants.%complete_type.1ec]
  1001. // CHECK:STDOUT: complete_type_witness = %complete_type
  1002. // CHECK:STDOUT:
  1003. // CHECK:STDOUT: !members:
  1004. // CHECK:STDOUT: .Self = constants.%B
  1005. // CHECK:STDOUT: .A = <poisoned>
  1006. // CHECK:STDOUT: }
  1007. // CHECK:STDOUT:
  1008. // CHECK:STDOUT: fn @__global_init() {
  1009. // CHECK:STDOUT: !entry:
  1010. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  1011. // CHECK:STDOUT: %.loc22_19: %struct_type.x.c96 = struct_literal (%int_1)
  1012. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  1013. // CHECK:STDOUT: %.loc22_21: %B = converted %.loc22_19, <error> [concrete = <error>]
  1014. // CHECK:STDOUT: assign file.%b.var, <error>
  1015. // CHECK:STDOUT: return
  1016. // CHECK:STDOUT: }
  1017. // CHECK:STDOUT: