adapter_conversion.carbon 57 KB

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