adapter_conversion.carbon 56 KB

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