adapter_conversion.carbon 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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. // --- fail_init_class.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. // TODO: Here, we treat `{.x = 1, .y = 2} as A` as a value expression, not an
  53. // initializing expression, so `(...) as B` is a value expression too, requiring
  54. // a copy to perform initialization. It's not clear whether that is the right
  55. // behavior.
  56. // CHECK:STDERR: fail_init_class.carbon:[[@LINE+4]]:17: error: cannot copy value of type `B`
  57. // CHECK:STDERR: var b_init: B = ({.x = 1, .y = 2} as A) as B;
  58. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  59. // CHECK:STDERR:
  60. var b_init: B = ({.x = 1, .y = 2} as A) as B;
  61. // --- fail_adapt_init_from_struct.carbon
  62. library "[[@TEST_NAME]]";
  63. class A {
  64. var x: i32;
  65. }
  66. class B {
  67. adapt A;
  68. }
  69. // We do not try to implicitly convert from the first operand of `as` to the
  70. // adapted type of the second operand.
  71. // CHECK:STDERR: fail_adapt_init_from_struct.carbon:[[@LINE+6]]:12: error: cannot convert from `{.x: i32}` to `B` with `as`
  72. // CHECK:STDERR: var b: B = {.x = 1} as B;
  73. // CHECK:STDERR: ^~~~~~~~~~~~~
  74. // CHECK:STDERR: fail_adapt_init_from_struct.carbon:[[@LINE+3]]:12: note: type `{.x: i32}` does not implement interface `As`
  75. // CHECK:STDERR: var b: B = {.x = 1} as B;
  76. // CHECK:STDERR: ^~~~~~~~~~~~~
  77. var b: B = {.x = 1} as B;
  78. // CHECK:STDOUT: --- adapt_class.carbon
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: constants {
  81. // CHECK:STDOUT: %A: type = class_type @A [template]
  82. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  83. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  84. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  85. // CHECK:STDOUT: %.2: type = unbound_element_type %A, i32 [template]
  86. // CHECK:STDOUT: %Make.type: type = fn_type @Make [template]
  87. // CHECK:STDOUT: %Make: %Make.type = struct_value () [template]
  88. // CHECK:STDOUT: %.3: type = struct_type {.x: i32, .y: i32} [template]
  89. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  90. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  91. // CHECK:STDOUT: %.6: i32 = int_literal 1 [template]
  92. // CHECK:STDOUT: %.7: i32 = int_literal 2 [template]
  93. // CHECK:STDOUT: %struct: %A = struct_value (%.6, %.7) [template]
  94. // CHECK:STDOUT: %B: type = class_type @B [template]
  95. // CHECK:STDOUT: %.8: <witness> = complete_type_witness %A [template]
  96. // CHECK:STDOUT: %.9: type = ptr_type %B [template]
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: imports {
  100. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  101. // CHECK:STDOUT: .Int32 = %import_ref
  102. // CHECK:STDOUT: import Core//prelude
  103. // CHECK:STDOUT: import Core//prelude/operators
  104. // CHECK:STDOUT: import Core//prelude/types
  105. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  106. // CHECK:STDOUT: import Core//prelude/operators/as
  107. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  108. // CHECK:STDOUT: import Core//prelude/operators/comparison
  109. // CHECK:STDOUT: import Core//prelude/types/bool
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: file {
  115. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  116. // CHECK:STDOUT: .Core = imports.%Core
  117. // CHECK:STDOUT: .A = %A.decl
  118. // CHECK:STDOUT: .B = %B.decl
  119. // CHECK:STDOUT: .a_ref = %a_ref
  120. // CHECK:STDOUT: .a_val = @__global_init.%a_val
  121. // CHECK:STDOUT: .b_val = @__global_init.%b_val
  122. // CHECK:STDOUT: .b_ptr = @__global_init.%b_ptr
  123. // CHECK:STDOUT: .b_factory = %b_factory
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: %Core.import = import Core
  126. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  127. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  128. // CHECK:STDOUT: %A.ref.loc17: type = name_ref A, %A.decl [template = constants.%A]
  129. // CHECK:STDOUT: %a_ref.var: ref %A = var a_ref
  130. // CHECK:STDOUT: %a_ref: ref %A = bind_name a_ref, %a_ref.var
  131. // CHECK:STDOUT: %A.ref.loc18: type = name_ref A, %A.decl [template = constants.%A]
  132. // CHECK:STDOUT: %B.ref.loc21: type = name_ref B, %B.decl [template = constants.%B]
  133. // CHECK:STDOUT: %B.ref.loc22: type = name_ref B, %B.decl [template = constants.%B]
  134. // CHECK:STDOUT: %.loc22: type = ptr_type %B [template = constants.%.9]
  135. // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, %B.decl [template = constants.%B]
  136. // CHECK:STDOUT: %b_factory.var: ref %B = var b_factory
  137. // CHECK:STDOUT: %b_factory: ref %B = bind_name b_factory, %b_factory.var
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: class @A {
  141. // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
  142. // CHECK:STDOUT: %.loc5_10.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
  143. // CHECK:STDOUT: %.loc5_10.2: type = converted %int.make_type_32.loc5, %.loc5_10.1 [template = i32]
  144. // CHECK:STDOUT: %.loc5_8: %.2 = field_decl x, element0 [template]
  145. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  146. // CHECK:STDOUT: %.loc6_10.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  147. // CHECK:STDOUT: %.loc6_10.2: type = converted %int.make_type_32.loc6, %.loc6_10.1 [template = i32]
  148. // CHECK:STDOUT: %.loc6_8: %.2 = field_decl y, element1 [template]
  149. // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] {} {
  150. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  151. // CHECK:STDOUT: %return: ref %A = var <return slot>
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.3 [template = constants.%.4]
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: !members:
  156. // CHECK:STDOUT: .Self = constants.%A
  157. // CHECK:STDOUT: .x = %.loc5_8
  158. // CHECK:STDOUT: .y = %.loc6_8
  159. // CHECK:STDOUT: .Make = %Make.decl
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: class @B {
  163. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  164. // CHECK:STDOUT: adapt_decl %A
  165. // CHECK:STDOUT: %.loc15: <witness> = complete_type_witness %A [template = constants.%.8]
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: !members:
  168. // CHECK:STDOUT: .Self = constants.%B
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: fn @Make() -> %return: %A {
  174. // CHECK:STDOUT: !entry:
  175. // CHECK:STDOUT: %.loc9_18: i32 = int_literal 1 [template = constants.%.6]
  176. // CHECK:STDOUT: %.loc9_26: i32 = int_literal 2 [template = constants.%.7]
  177. // CHECK:STDOUT: %.loc9_27.1: %.3 = struct_literal (%.loc9_18, %.loc9_26)
  178. // CHECK:STDOUT: %.loc9_27.2: ref i32 = class_element_access %return, element0
  179. // CHECK:STDOUT: %.loc9_27.3: init i32 = initialize_from %.loc9_18 to %.loc9_27.2 [template = constants.%.6]
  180. // CHECK:STDOUT: %.loc9_27.4: ref i32 = class_element_access %return, element1
  181. // CHECK:STDOUT: %.loc9_27.5: init i32 = initialize_from %.loc9_26 to %.loc9_27.4 [template = constants.%.7]
  182. // CHECK:STDOUT: %.loc9_27.6: init %A = class_init (%.loc9_27.3, %.loc9_27.5), %return [template = constants.%struct]
  183. // CHECK:STDOUT: %.loc9_28: init %A = converted %.loc9_27.1, %.loc9_27.6 [template = constants.%struct]
  184. // CHECK:STDOUT: return %.loc9_28 to %return
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: fn @__global_init() {
  188. // CHECK:STDOUT: !entry:
  189. // CHECK:STDOUT: %.loc17_22: i32 = int_literal 1 [template = constants.%.6]
  190. // CHECK:STDOUT: %.loc17_30: i32 = int_literal 2 [template = constants.%.7]
  191. // CHECK:STDOUT: %.loc17_31.1: %.3 = struct_literal (%.loc17_22, %.loc17_30)
  192. // CHECK:STDOUT: %.loc17_31.2: ref i32 = class_element_access file.%a_ref.var, element0
  193. // CHECK:STDOUT: %.loc17_31.3: init i32 = initialize_from %.loc17_22 to %.loc17_31.2 [template = constants.%.6]
  194. // CHECK:STDOUT: %.loc17_31.4: ref i32 = class_element_access file.%a_ref.var, element1
  195. // CHECK:STDOUT: %.loc17_31.5: init i32 = initialize_from %.loc17_30 to %.loc17_31.4 [template = constants.%.7]
  196. // CHECK:STDOUT: %.loc17_31.6: init %A = class_init (%.loc17_31.3, %.loc17_31.5), file.%a_ref.var [template = constants.%struct]
  197. // CHECK:STDOUT: %.loc17_32: init %A = converted %.loc17_31.1, %.loc17_31.6 [template = constants.%struct]
  198. // CHECK:STDOUT: assign file.%a_ref.var, %.loc17_32
  199. // CHECK:STDOUT: %a_ref.ref.loc18: ref %A = name_ref a_ref, file.%a_ref
  200. // CHECK:STDOUT: %.loc18: %A = bind_value %a_ref.ref.loc18
  201. // CHECK:STDOUT: %a_val: %A = bind_name a_val, %.loc18
  202. // CHECK:STDOUT: %a_val.ref: %A = name_ref a_val, %a_val
  203. // CHECK:STDOUT: %B.ref.loc21: type = name_ref B, file.%B.decl [template = constants.%B]
  204. // CHECK:STDOUT: %.loc21_22.1: %B = as_compatible %a_val.ref
  205. // CHECK:STDOUT: %.loc21_22.2: %B = converted %a_val.ref, %.loc21_22.1
  206. // CHECK:STDOUT: %b_val: %B = bind_name b_val, %.loc21_22.2
  207. // CHECK:STDOUT: %a_ref.ref.loc22: ref %A = name_ref a_ref, file.%a_ref
  208. // CHECK:STDOUT: %B.ref.loc22: type = name_ref B, file.%B.decl [template = constants.%B]
  209. // CHECK:STDOUT: %.loc22_25.1: ref %B = as_compatible %a_ref.ref.loc22
  210. // CHECK:STDOUT: %.loc22_25.2: ref %B = converted %a_ref.ref.loc22, %.loc22_25.1
  211. // CHECK:STDOUT: %.loc22_17: %.9 = addr_of %.loc22_25.2
  212. // CHECK:STDOUT: %b_ptr: %.9 = bind_name b_ptr, %.loc22_17
  213. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  214. // CHECK:STDOUT: %Make.ref: %Make.type = name_ref Make, @A.%Make.decl [template = constants.%Make]
  215. // CHECK:STDOUT: %.loc24_5: ref %B = splice_block file.%b_factory.var {}
  216. // CHECK:STDOUT: %Make.call: init %A = call %Make.ref() to %.loc24_5
  217. // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [template = constants.%B]
  218. // CHECK:STDOUT: %.loc24_29.1: init %B = as_compatible %Make.call
  219. // CHECK:STDOUT: %.loc24_29.2: init %B = converted %Make.call, %.loc24_29.1
  220. // CHECK:STDOUT: assign file.%b_factory.var, %.loc24_29.2
  221. // CHECK:STDOUT: return
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: --- adapt_i32.carbon
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: constants {
  227. // CHECK:STDOUT: %A: type = class_type @A [template]
  228. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  229. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  230. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  231. // CHECK:STDOUT: %.2: <witness> = complete_type_witness i32 [template]
  232. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: imports {
  236. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  237. // CHECK:STDOUT: .Int32 = %import_ref
  238. // CHECK:STDOUT: import Core//prelude
  239. // CHECK:STDOUT: import Core//prelude/operators
  240. // CHECK:STDOUT: import Core//prelude/types
  241. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  242. // CHECK:STDOUT: import Core//prelude/operators/as
  243. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  244. // CHECK:STDOUT: import Core//prelude/operators/comparison
  245. // CHECK:STDOUT: import Core//prelude/types/bool
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: file {
  251. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  252. // CHECK:STDOUT: .Core = imports.%Core
  253. // CHECK:STDOUT: .A = %A.decl
  254. // CHECK:STDOUT: .a = @__global_init.%a
  255. // CHECK:STDOUT: .n = @__global_init.%n
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT: %Core.import = import Core
  258. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  259. // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A]
  260. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  261. // CHECK:STDOUT: %.loc9_8.1: type = value_of_initializer %int.make_type_32 [template = i32]
  262. // CHECK:STDOUT: %.loc9_8.2: type = converted %int.make_type_32, %.loc9_8.1 [template = i32]
  263. // CHECK:STDOUT: }
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: class @A {
  266. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  267. // CHECK:STDOUT: %.loc5_12.1: type = value_of_initializer %int.make_type_32 [template = i32]
  268. // CHECK:STDOUT: %.loc5_12.2: type = converted %int.make_type_32, %.loc5_12.1 [template = i32]
  269. // CHECK:STDOUT: adapt_decl i32
  270. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness i32 [template = constants.%.2]
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: !members:
  273. // CHECK:STDOUT: .Self = constants.%A
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: fn @__global_init() {
  279. // CHECK:STDOUT: !entry:
  280. // CHECK:STDOUT: %.loc8_13: i32 = int_literal 1 [template = constants.%.3]
  281. // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
  282. // CHECK:STDOUT: %.loc8_18.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
  283. // CHECK:STDOUT: %.loc8_18.2: type = converted %int.make_type_32.loc8, %.loc8_18.1 [template = i32]
  284. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  285. // CHECK:STDOUT: %.loc8_23.1: %A = as_compatible %.loc8_13 [template = constants.%.3]
  286. // CHECK:STDOUT: %.loc8_23.2: %A = converted %.loc8_13, %.loc8_23.1 [template = constants.%.3]
  287. // CHECK:STDOUT: %a: %A = bind_name a, %.loc8_23.2
  288. // CHECK:STDOUT: %a.ref: %A = name_ref a, %a
  289. // CHECK:STDOUT: %int.make_type_32.loc9: init type = call constants.%Int32() [template = i32]
  290. // CHECK:STDOUT: %.loc9_19.1: type = value_of_initializer %int.make_type_32.loc9 [template = i32]
  291. // CHECK:STDOUT: %.loc9_19.2: type = converted %int.make_type_32.loc9, %.loc9_19.1 [template = i32]
  292. // CHECK:STDOUT: %.loc9_16.1: i32 = as_compatible %a.ref
  293. // CHECK:STDOUT: %.loc9_16.2: i32 = converted %a.ref, %.loc9_16.1
  294. // CHECK:STDOUT: %n: i32 = bind_name n, %.loc9_16.2
  295. // CHECK:STDOUT: return
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: --- multi_level_adapt.carbon
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: constants {
  301. // CHECK:STDOUT: %A: type = class_type @A [template]
  302. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  303. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  304. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.1 [template]
  305. // CHECK:STDOUT: %B: type = class_type @B [template]
  306. // CHECK:STDOUT: %C: type = class_type @C [template]
  307. // CHECK:STDOUT: %D: type = class_type @D [template]
  308. // CHECK:STDOUT: %struct: %.1 = struct_value () [template]
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: imports {
  312. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  313. // CHECK:STDOUT: import Core//prelude
  314. // CHECK:STDOUT: import Core//prelude/operators
  315. // CHECK:STDOUT: import Core//prelude/types
  316. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  317. // CHECK:STDOUT: import Core//prelude/operators/as
  318. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  319. // CHECK:STDOUT: import Core//prelude/operators/comparison
  320. // CHECK:STDOUT: import Core//prelude/types/bool
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: file {
  325. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  326. // CHECK:STDOUT: .Core = imports.%Core
  327. // CHECK:STDOUT: .A = %A.decl
  328. // CHECK:STDOUT: .B = %B.decl
  329. // CHECK:STDOUT: .C = %C.decl
  330. // CHECK:STDOUT: .D = %D.decl
  331. // CHECK:STDOUT: .d = @__global_init.%d
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT: %Core.import = import Core
  334. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  335. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  336. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  337. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  338. // CHECK:STDOUT: %D.ref: type = name_ref D, %D.decl [template = constants.%D]
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: class @A {
  342. // CHECK:STDOUT: %.loc4_18: %.1 = struct_literal ()
  343. // CHECK:STDOUT: %.loc4_19: type = converted %.loc4_18, constants.%.1 [template = constants.%.1]
  344. // CHECK:STDOUT: adapt_decl %.1
  345. // CHECK:STDOUT: %.loc4_21: <witness> = complete_type_witness %.1 [template = constants.%.3]
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: !members:
  348. // CHECK:STDOUT: .Self = constants.%A
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: class @B {
  352. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  353. // CHECK:STDOUT: adapt_decl %A
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: !members:
  356. // CHECK:STDOUT: .Self = constants.%B
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: class @C {
  360. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  361. // CHECK:STDOUT: adapt_decl %B
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: !members:
  364. // CHECK:STDOUT: .Self = constants.%C
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: class @D {
  368. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  369. // CHECK:STDOUT: adapt_decl %C
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: !members:
  372. // CHECK:STDOUT: .Self = constants.%D
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: fn @__global_init() {
  376. // CHECK:STDOUT: !entry:
  377. // CHECK:STDOUT: %.loc9_13: %.1 = struct_literal ()
  378. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  379. // CHECK:STDOUT: %struct: %.1 = struct_value () [template = constants.%struct]
  380. // CHECK:STDOUT: %.loc9_15.1: %D = as_compatible %struct [template = constants.%struct]
  381. // CHECK:STDOUT: %.loc9_15.2: %D = converted %.loc9_13, %.loc9_15.1 [template = constants.%struct]
  382. // CHECK:STDOUT: %d: %D = bind_name d, %.loc9_15.2
  383. // CHECK:STDOUT: return
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: --- fail_init_class.carbon
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: constants {
  389. // CHECK:STDOUT: %A: type = class_type @A [template]
  390. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  391. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  392. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  393. // CHECK:STDOUT: %.2: type = unbound_element_type %A, i32 [template]
  394. // CHECK:STDOUT: %.3: type = struct_type {.x: i32, .y: i32} [template]
  395. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  396. // CHECK:STDOUT: %B: type = class_type @B [template]
  397. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  398. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %A [template]
  399. // CHECK:STDOUT: %.7: i32 = int_literal 1 [template]
  400. // CHECK:STDOUT: %.8: i32 = int_literal 2 [template]
  401. // CHECK:STDOUT: %struct: %A = struct_value (%.7, %.8) [template]
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: imports {
  405. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  406. // CHECK:STDOUT: .Int32 = %import_ref
  407. // CHECK:STDOUT: import Core//prelude
  408. // CHECK:STDOUT: import Core//prelude/operators
  409. // CHECK:STDOUT: import Core//prelude/types
  410. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  411. // CHECK:STDOUT: import Core//prelude/operators/as
  412. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  413. // CHECK:STDOUT: import Core//prelude/operators/comparison
  414. // CHECK:STDOUT: import Core//prelude/types/bool
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: file {
  420. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  421. // CHECK:STDOUT: .Core = imports.%Core
  422. // CHECK:STDOUT: .A = %A.decl
  423. // CHECK:STDOUT: .B = %B.decl
  424. // CHECK:STDOUT: .b_value = @__global_init.%b_value
  425. // CHECK:STDOUT: .b_init = %b_init
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT: %Core.import = import Core
  428. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  429. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  430. // CHECK:STDOUT: %B.ref.loc13: type = name_ref B, %B.decl [template = constants.%B]
  431. // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, %B.decl [template = constants.%B]
  432. // CHECK:STDOUT: %b_init.var: ref %B = var b_init
  433. // CHECK:STDOUT: %b_init: ref %B = bind_name b_init, %b_init.var
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: class @A {
  437. // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
  438. // CHECK:STDOUT: %.loc5_10.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
  439. // CHECK:STDOUT: %.loc5_10.2: type = converted %int.make_type_32.loc5, %.loc5_10.1 [template = i32]
  440. // CHECK:STDOUT: %.loc5_8: %.2 = field_decl x, element0 [template]
  441. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  442. // CHECK:STDOUT: %.loc6_10.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  443. // CHECK:STDOUT: %.loc6_10.2: type = converted %int.make_type_32.loc6, %.loc6_10.1 [template = i32]
  444. // CHECK:STDOUT: %.loc6_8: %.2 = field_decl y, element1 [template]
  445. // CHECK:STDOUT: %.loc7: <witness> = complete_type_witness %.3 [template = constants.%.4]
  446. // CHECK:STDOUT:
  447. // CHECK:STDOUT: !members:
  448. // CHECK:STDOUT: .Self = constants.%A
  449. // CHECK:STDOUT: .x = %.loc5_8
  450. // CHECK:STDOUT: .y = %.loc6_8
  451. // CHECK:STDOUT: }
  452. // CHECK:STDOUT:
  453. // CHECK:STDOUT: class @B {
  454. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  455. // CHECK:STDOUT: adapt_decl %A
  456. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %A [template = constants.%.6]
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: !members:
  459. // CHECK:STDOUT: .Self = constants.%B
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  463. // CHECK:STDOUT:
  464. // CHECK:STDOUT: fn @__global_init() {
  465. // CHECK:STDOUT: !entry:
  466. // CHECK:STDOUT: %.loc13_25: i32 = int_literal 1 [template = constants.%.7]
  467. // CHECK:STDOUT: %.loc13_33: i32 = int_literal 2 [template = constants.%.8]
  468. // CHECK:STDOUT: %.loc13_34.1: %.3 = struct_literal (%.loc13_25, %.loc13_33)
  469. // CHECK:STDOUT: %A.ref.loc13: type = name_ref A, file.%A.decl [template = constants.%A]
  470. // CHECK:STDOUT: %.loc13_34.2: ref %A = temporary_storage
  471. // CHECK:STDOUT: %.loc13_34.3: ref i32 = class_element_access %.loc13_34.2, element0
  472. // CHECK:STDOUT: %.loc13_34.4: init i32 = initialize_from %.loc13_25 to %.loc13_34.3 [template = constants.%.7]
  473. // CHECK:STDOUT: %.loc13_34.5: ref i32 = class_element_access %.loc13_34.2, element1
  474. // CHECK:STDOUT: %.loc13_34.6: init i32 = initialize_from %.loc13_33 to %.loc13_34.5 [template = constants.%.8]
  475. // CHECK:STDOUT: %.loc13_34.7: init %A = class_init (%.loc13_34.4, %.loc13_34.6), %.loc13_34.2 [template = constants.%struct]
  476. // CHECK:STDOUT: %.loc13_34.8: ref %A = temporary %.loc13_34.2, %.loc13_34.7
  477. // CHECK:STDOUT: %.loc13_36: ref %A = converted %.loc13_34.1, %.loc13_34.8
  478. // CHECK:STDOUT: %B.ref.loc13: type = name_ref B, file.%B.decl [template = constants.%B]
  479. // CHECK:STDOUT: %.loc13_42.1: ref %B = as_compatible %.loc13_36
  480. // CHECK:STDOUT: %.loc13_42.2: ref %B = converted %.loc13_36, %.loc13_42.1
  481. // CHECK:STDOUT: %.loc13_42.3: %B = bind_value %.loc13_42.2
  482. // CHECK:STDOUT: %b_value: %B = bind_name b_value, %.loc13_42.3
  483. // CHECK:STDOUT: %.loc24_24: i32 = int_literal 1 [template = constants.%.7]
  484. // CHECK:STDOUT: %.loc24_32: i32 = int_literal 2 [template = constants.%.8]
  485. // CHECK:STDOUT: %.loc24_33.1: %.3 = struct_literal (%.loc24_24, %.loc24_32)
  486. // CHECK:STDOUT: %A.ref.loc24: type = name_ref A, file.%A.decl [template = constants.%A]
  487. // CHECK:STDOUT: %.loc24_33.2: ref %A = temporary_storage
  488. // CHECK:STDOUT: %.loc24_33.3: ref i32 = class_element_access %.loc24_33.2, element0
  489. // CHECK:STDOUT: %.loc24_33.4: init i32 = initialize_from %.loc24_24 to %.loc24_33.3 [template = constants.%.7]
  490. // CHECK:STDOUT: %.loc24_33.5: ref i32 = class_element_access %.loc24_33.2, element1
  491. // CHECK:STDOUT: %.loc24_33.6: init i32 = initialize_from %.loc24_32 to %.loc24_33.5 [template = constants.%.8]
  492. // CHECK:STDOUT: %.loc24_33.7: init %A = class_init (%.loc24_33.4, %.loc24_33.6), %.loc24_33.2 [template = constants.%struct]
  493. // CHECK:STDOUT: %.loc24_33.8: ref %A = temporary %.loc24_33.2, %.loc24_33.7
  494. // CHECK:STDOUT: %.loc24_35: ref %A = converted %.loc24_33.1, %.loc24_33.8
  495. // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [template = constants.%B]
  496. // CHECK:STDOUT: %.loc24_41.1: ref %B = as_compatible %.loc24_35
  497. // CHECK:STDOUT: %.loc24_41.2: ref %B = converted %.loc24_35, %.loc24_41.1
  498. // CHECK:STDOUT: %.loc24_41.3: %B = bind_value %.loc24_41.2
  499. // CHECK:STDOUT: assign file.%b_init.var, <error>
  500. // CHECK:STDOUT: return
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: --- fail_adapt_init_from_struct.carbon
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: constants {
  506. // CHECK:STDOUT: %A: type = class_type @A [template]
  507. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  508. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  509. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  510. // CHECK:STDOUT: %.2: type = unbound_element_type %A, i32 [template]
  511. // CHECK:STDOUT: %.3: type = struct_type {.x: i32} [template]
  512. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  513. // CHECK:STDOUT: %B: type = class_type @B [template]
  514. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  515. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %A [template]
  516. // CHECK:STDOUT: %.7: i32 = int_literal 1 [template]
  517. // CHECK:STDOUT: %As.type: type = generic_interface_type @As [template]
  518. // CHECK:STDOUT: %As: %As.type = struct_value () [template]
  519. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic]
  520. // CHECK:STDOUT: %.8: type = interface_type @As, @As(%Dest) [symbolic]
  521. // CHECK:STDOUT: %Self.1: @As.%.1 (%.8) = bind_symbolic_name Self 1 [symbolic]
  522. // CHECK:STDOUT: %Self.2: %.8 = bind_symbolic_name Self 1 [symbolic]
  523. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @As(%Dest) [symbolic]
  524. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  525. // CHECK:STDOUT: %.9: type = assoc_entity_type %.8, %Convert.type.1 [symbolic]
  526. // CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  527. // CHECK:STDOUT: %.11: type = interface_type @As, @As(%B) [template]
  528. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @As(%B) [template]
  529. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  530. // CHECK:STDOUT: %.12: type = assoc_entity_type %.11, %Convert.type.2 [template]
  531. // CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.6 [template]
  532. // CHECK:STDOUT: %.14: %.9 = assoc_entity element0, imports.%import_ref.7 [symbolic]
  533. // CHECK:STDOUT: %struct: %.3 = struct_value (%.7) [template]
  534. // CHECK:STDOUT: }
  535. // CHECK:STDOUT:
  536. // CHECK:STDOUT: imports {
  537. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  538. // CHECK:STDOUT: .Int32 = %import_ref.1
  539. // CHECK:STDOUT: .As = %import_ref.2
  540. // CHECK:STDOUT: import Core//prelude
  541. // CHECK:STDOUT: import Core//prelude/operators
  542. // CHECK:STDOUT: import Core//prelude/types
  543. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  544. // CHECK:STDOUT: import Core//prelude/operators/as
  545. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  546. // CHECK:STDOUT: import Core//prelude/operators/comparison
  547. // CHECK:STDOUT: import Core//prelude/types/bool
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  550. // CHECK:STDOUT: %import_ref.2: %As.type = import_ref Core//prelude/operators/as, inst+5, loaded [template = constants.%As]
  551. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/as, inst+11, unloaded
  552. // CHECK:STDOUT: %import_ref.4: @As.%.2 (%.9) = import_ref Core//prelude/operators/as, inst+29, loaded [symbolic = @As.%.3 (constants.%.14)]
  553. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+22, unloaded
  554. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+22, unloaded
  555. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+22, unloaded
  556. // CHECK:STDOUT: }
  557. // CHECK:STDOUT:
  558. // CHECK:STDOUT: file {
  559. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  560. // CHECK:STDOUT: .Core = imports.%Core
  561. // CHECK:STDOUT: .A = %A.decl
  562. // CHECK:STDOUT: .B = %B.decl
  563. // CHECK:STDOUT: .b = %b
  564. // CHECK:STDOUT: }
  565. // CHECK:STDOUT: %Core.import = import Core
  566. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  567. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  568. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B]
  569. // CHECK:STDOUT: %b.var: ref %B = var b
  570. // CHECK:STDOUT: %b: ref %B = bind_name b, %b.var
  571. // CHECK:STDOUT: }
  572. // CHECK:STDOUT:
  573. // CHECK:STDOUT: generic interface @As(constants.%Dest: type) {
  574. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: !definition:
  577. // CHECK:STDOUT: %.1: type = interface_type @As, @As(%Dest) [symbolic = %.1 (constants.%.8)]
  578. // CHECK:STDOUT: %Self: %.8 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)]
  579. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @As(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  580. // CHECK:STDOUT: %Convert: @As.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  581. // CHECK:STDOUT: %.2: type = assoc_entity_type @As.%.1 (%.8), @As.%Convert.type (%Convert.type.1) [symbolic = %.2 (constants.%.9)]
  582. // CHECK:STDOUT: %.3: @As.%.2 (%.9) = assoc_entity element0, imports.%import_ref.6 [symbolic = %.3 (constants.%.10)]
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: interface {
  585. // CHECK:STDOUT: !members:
  586. // CHECK:STDOUT: .Self = imports.%import_ref.3
  587. // CHECK:STDOUT: .Convert = imports.%import_ref.4
  588. // CHECK:STDOUT: witness = (imports.%import_ref.5)
  589. // CHECK:STDOUT: }
  590. // CHECK:STDOUT: }
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: class @A {
  593. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  594. // CHECK:STDOUT: %.loc5_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
  595. // CHECK:STDOUT: %.loc5_10.2: type = converted %int.make_type_32, %.loc5_10.1 [template = i32]
  596. // CHECK:STDOUT: %.loc5_8: %.2 = field_decl x, element0 [template]
  597. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.3 [template = constants.%.4]
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: !members:
  600. // CHECK:STDOUT: .Self = constants.%A
  601. // CHECK:STDOUT: .x = %.loc5_8
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT:
  604. // CHECK:STDOUT: class @B {
  605. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  606. // CHECK:STDOUT: adapt_decl %A
  607. // CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %A [template = constants.%.6]
  608. // CHECK:STDOUT:
  609. // CHECK:STDOUT: !members:
  610. // CHECK:STDOUT: .Self = constants.%B
  611. // CHECK:STDOUT: }
  612. // CHECK:STDOUT:
  613. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  614. // CHECK:STDOUT:
  615. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @As.%.1 (%.8)) {
  616. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  617. // CHECK:STDOUT: %.1: type = interface_type @As, @As(%Dest) [symbolic = %.1 (constants.%.8)]
  618. // CHECK:STDOUT: %Self: %.8 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)]
  619. // CHECK:STDOUT:
  620. // CHECK:STDOUT: fn[%self: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  621. // CHECK:STDOUT: }
  622. // CHECK:STDOUT:
  623. // CHECK:STDOUT: fn @__global_init() {
  624. // CHECK:STDOUT: !entry:
  625. // CHECK:STDOUT: %.loc21_18: i32 = int_literal 1 [template = constants.%.7]
  626. // CHECK:STDOUT: %.loc21_19.1: %.3 = struct_literal (%.loc21_18)
  627. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  628. // CHECK:STDOUT: %.loc21_21.1: type = interface_type @As, @As(constants.%B) [template = constants.%.11]
  629. // CHECK:STDOUT: %.loc21_21.2: %.12 = specific_constant imports.%import_ref.4, @As(constants.%B) [template = constants.%.13]
  630. // CHECK:STDOUT: %Convert.ref: %.12 = name_ref Convert, %.loc21_21.2 [template = constants.%.13]
  631. // CHECK:STDOUT: %struct: %.3 = struct_value (%.loc21_18) [template = constants.%struct]
  632. // CHECK:STDOUT: %.loc21_19.2: %.3 = converted %.loc21_19.1, %struct [template = constants.%struct]
  633. // CHECK:STDOUT: %.loc21_21.3: %B = converted %.loc21_19.1, <error> [template = <error>]
  634. // CHECK:STDOUT: assign file.%b.var, <error>
  635. // CHECK:STDOUT: return
  636. // CHECK:STDOUT: }
  637. // CHECK:STDOUT:
  638. // CHECK:STDOUT: specific @As(constants.%Dest) {
  639. // CHECK:STDOUT: %Dest => constants.%Dest
  640. // CHECK:STDOUT: }
  641. // CHECK:STDOUT:
  642. // CHECK:STDOUT: specific @As(@As.%Dest) {
  643. // CHECK:STDOUT: %Dest => constants.%Dest
  644. // CHECK:STDOUT: }
  645. // CHECK:STDOUT:
  646. // CHECK:STDOUT: specific @As(@Convert.%Dest) {
  647. // CHECK:STDOUT: %Dest => constants.%Dest
  648. // CHECK:STDOUT: }
  649. // CHECK:STDOUT:
  650. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  651. // CHECK:STDOUT: %Dest => constants.%Dest
  652. // CHECK:STDOUT: %.1 => constants.%.8
  653. // CHECK:STDOUT: %Self => constants.%Self.1
  654. // CHECK:STDOUT: }
  655. // CHECK:STDOUT:
  656. // CHECK:STDOUT: specific @As(constants.%B) {
  657. // CHECK:STDOUT: %Dest => constants.%B
  658. // CHECK:STDOUT:
  659. // CHECK:STDOUT: !definition:
  660. // CHECK:STDOUT: %.1 => constants.%.11
  661. // CHECK:STDOUT: %Self => constants.%Self.2
  662. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  663. // CHECK:STDOUT: %Convert => constants.%Convert.2
  664. // CHECK:STDOUT: %.2 => constants.%.12
  665. // CHECK:STDOUT: %.3 => constants.%.13
  666. // CHECK:STDOUT: }
  667. // CHECK:STDOUT: