extend_adapt.carbon 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/extend_adapt.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/extend_adapt.carbon
  10. // --- basic.carbon
  11. library "[[@TEST_NAME]]";
  12. class SomeClassAdapter;
  13. class SomeClass {
  14. var a: i32;
  15. var b: i32;
  16. fn StaticMemberFunction();
  17. fn AdapterMethod[self: SomeClassAdapter]();
  18. }
  19. class SomeClassAdapter {
  20. extend adapt SomeClass;
  21. }
  22. fn TestStaticMemberFunction(a: SomeClassAdapter) {
  23. a.StaticMemberFunction();
  24. }
  25. fn TestAdapterMethod(a: SomeClassAdapter) {
  26. a.AdapterMethod();
  27. }
  28. // --- fail_todo_method_access.carbon
  29. library "[[@TEST_NAME]]";
  30. class SomeClass {
  31. fn F[self: Self]();
  32. }
  33. class SomeClassAdapter {
  34. extend adapt SomeClass;
  35. }
  36. fn F(a: SomeClassAdapter) {
  37. // CHECK:STDERR: fail_todo_method_access.carbon:[[@LINE+10]]:3: error: cannot implicitly convert from `SomeClassAdapter` to `SomeClass`
  38. // CHECK:STDERR: a.F();
  39. // CHECK:STDERR: ^
  40. // CHECK:STDERR: fail_todo_method_access.carbon:[[@LINE+7]]:3: note: type `SomeClassAdapter` does not implement interface `ImplicitAs`
  41. // CHECK:STDERR: a.F();
  42. // CHECK:STDERR: ^
  43. // CHECK:STDERR: fail_todo_method_access.carbon:[[@LINE-14]]:8: note: initializing `self` parameter of method declared here
  44. // CHECK:STDERR: fn F[self: Self]();
  45. // CHECK:STDERR: ^~~~~~~~~~
  46. // CHECK:STDERR:
  47. a.F();
  48. }
  49. // --- fail_todo_field_access.carbon
  50. library "[[@TEST_NAME]]";
  51. class SomeClass {
  52. var a: i32;
  53. var b: i32;
  54. }
  55. class SomeClassAdapter {
  56. extend adapt SomeClass;
  57. }
  58. fn F(a: SomeClassAdapter) -> i32 {
  59. // CHECK:STDERR: fail_todo_field_access.carbon:[[@LINE+7]]:10: error: cannot implicitly convert from `SomeClassAdapter` to `SomeClass`
  60. // CHECK:STDERR: return a.b;
  61. // CHECK:STDERR: ^~~
  62. // CHECK:STDERR: fail_todo_field_access.carbon:[[@LINE+4]]:10: note: type `SomeClassAdapter` does not implement interface `ImplicitAs`
  63. // CHECK:STDERR: return a.b;
  64. // CHECK:STDERR: ^~~
  65. // CHECK:STDERR:
  66. return a.b;
  67. }
  68. // --- fail_todo_adapt_non_class.carbon
  69. library "[[@TEST_NAME]]";
  70. class StructAdapter {
  71. // CHECK:STDERR: fail_todo_adapt_non_class.carbon:[[@LINE+3]]:3: error: semantics TODO: `extending non-class type`
  72. // CHECK:STDERR: extend adapt {.a: i32, .b: i32};
  73. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. extend adapt {.a: i32, .b: i32};
  75. }
  76. // CHECK:STDOUT: --- basic.carbon
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: constants {
  79. // CHECK:STDOUT: %SomeClassAdapter: type = class_type @SomeClassAdapter [template]
  80. // CHECK:STDOUT: %SomeClass: type = class_type @SomeClass [template]
  81. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  82. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  83. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  84. // CHECK:STDOUT: %.2: type = unbound_element_type %SomeClass, i32 [template]
  85. // CHECK:STDOUT: %StaticMemberFunction.type: type = fn_type @StaticMemberFunction [template]
  86. // CHECK:STDOUT: %StaticMemberFunction: %StaticMemberFunction.type = struct_value () [template]
  87. // CHECK:STDOUT: %AdapterMethod.type: type = fn_type @AdapterMethod [template]
  88. // CHECK:STDOUT: %AdapterMethod: %AdapterMethod.type = struct_value () [template]
  89. // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
  90. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  91. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  92. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %SomeClass [template]
  93. // CHECK:STDOUT: %TestStaticMemberFunction.type: type = fn_type @TestStaticMemberFunction [template]
  94. // CHECK:STDOUT: %TestStaticMemberFunction: %TestStaticMemberFunction.type = struct_value () [template]
  95. // CHECK:STDOUT: %TestAdapterMethod.type: type = fn_type @TestAdapterMethod [template]
  96. // CHECK:STDOUT: %TestAdapterMethod: %TestAdapterMethod.type = struct_value () [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+9, 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: .SomeClassAdapter = %SomeClassAdapter.decl.loc4
  118. // CHECK:STDOUT: .SomeClass = %SomeClass.decl
  119. // CHECK:STDOUT: .TestStaticMemberFunction = %TestStaticMemberFunction.decl
  120. // CHECK:STDOUT: .TestAdapterMethod = %TestAdapterMethod.decl
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT: %Core.import = import Core
  123. // CHECK:STDOUT: %SomeClassAdapter.decl.loc4: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} {}
  124. // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {} {}
  125. // CHECK:STDOUT: %SomeClassAdapter.decl.loc15: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} {}
  126. // CHECK:STDOUT: %TestStaticMemberFunction.decl: %TestStaticMemberFunction.type = fn_decl @TestStaticMemberFunction [template = constants.%TestStaticMemberFunction] {
  127. // CHECK:STDOUT: %a.patt: %SomeClassAdapter = binding_pattern a
  128. // CHECK:STDOUT: %a.param_patt: %SomeClassAdapter = param_pattern %a.patt, runtime_param0
  129. // CHECK:STDOUT: } {
  130. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, file.%SomeClassAdapter.decl.loc4 [template = constants.%SomeClassAdapter]
  131. // CHECK:STDOUT: %param: %SomeClassAdapter = param runtime_param0
  132. // CHECK:STDOUT: %a: %SomeClassAdapter = bind_name a, %param
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT: %TestAdapterMethod.decl: %TestAdapterMethod.type = fn_decl @TestAdapterMethod [template = constants.%TestAdapterMethod] {
  135. // CHECK:STDOUT: %a.patt: %SomeClassAdapter = binding_pattern a
  136. // CHECK:STDOUT: %a.param_patt: %SomeClassAdapter = param_pattern %a.patt, runtime_param0
  137. // CHECK:STDOUT: } {
  138. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, file.%SomeClassAdapter.decl.loc4 [template = constants.%SomeClassAdapter]
  139. // CHECK:STDOUT: %param: %SomeClassAdapter = param runtime_param0
  140. // CHECK:STDOUT: %a: %SomeClassAdapter = bind_name a, %param
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: class @SomeClassAdapter {
  145. // CHECK:STDOUT: %SomeClass.ref: type = name_ref SomeClass, file.%SomeClass.decl [template = constants.%SomeClass]
  146. // CHECK:STDOUT: adapt_decl %SomeClass
  147. // CHECK:STDOUT: %.loc17: <witness> = complete_type_witness %SomeClass [template = constants.%.6]
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: !members:
  150. // CHECK:STDOUT: .Self = constants.%SomeClassAdapter
  151. // CHECK:STDOUT: extend name_scope2
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: class @SomeClass {
  155. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  156. // CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  157. // CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32.loc7, %.loc7_10.1 [template = i32]
  158. // CHECK:STDOUT: %.loc7_8: %.2 = field_decl a, element0 [template]
  159. // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
  160. // CHECK:STDOUT: %.loc8_10.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
  161. // CHECK:STDOUT: %.loc8_10.2: type = converted %int.make_type_32.loc8, %.loc8_10.1 [template = i32]
  162. // CHECK:STDOUT: %.loc8_8: %.2 = field_decl b, element1 [template]
  163. // CHECK:STDOUT: %StaticMemberFunction.decl: %StaticMemberFunction.type = fn_decl @StaticMemberFunction [template = constants.%StaticMemberFunction] {} {}
  164. // CHECK:STDOUT: %AdapterMethod.decl: %AdapterMethod.type = fn_decl @AdapterMethod [template = constants.%AdapterMethod] {
  165. // CHECK:STDOUT: %self.patt: %SomeClassAdapter = binding_pattern self
  166. // CHECK:STDOUT: %self.param_patt: %SomeClassAdapter = param_pattern %self.patt, runtime_param0
  167. // CHECK:STDOUT: } {
  168. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, file.%SomeClassAdapter.decl.loc4 [template = constants.%SomeClassAdapter]
  169. // CHECK:STDOUT: %param: %SomeClassAdapter = param runtime_param0
  170. // CHECK:STDOUT: %self: %SomeClassAdapter = bind_name self, %param
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT: %.loc13: <witness> = complete_type_witness %.3 [template = constants.%.4]
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: !members:
  175. // CHECK:STDOUT: .Self = constants.%SomeClass
  176. // CHECK:STDOUT: .a = %.loc7_8
  177. // CHECK:STDOUT: .b = %.loc8_8
  178. // CHECK:STDOUT: .StaticMemberFunction = %StaticMemberFunction.decl
  179. // CHECK:STDOUT: .AdapterMethod = %AdapterMethod.decl
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: fn @StaticMemberFunction();
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: fn @AdapterMethod[%self.param_patt: %SomeClassAdapter]();
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: fn @TestStaticMemberFunction(%a.param_patt: %SomeClassAdapter) {
  189. // CHECK:STDOUT: !entry:
  190. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  191. // CHECK:STDOUT: %StaticMemberFunction.ref: %StaticMemberFunction.type = name_ref StaticMemberFunction, @SomeClass.%StaticMemberFunction.decl [template = constants.%StaticMemberFunction]
  192. // CHECK:STDOUT: %StaticMemberFunction.call: init %.1 = call %StaticMemberFunction.ref()
  193. // CHECK:STDOUT: return
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: fn @TestAdapterMethod(%a.param_patt: %SomeClassAdapter) {
  197. // CHECK:STDOUT: !entry:
  198. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  199. // CHECK:STDOUT: %AdapterMethod.ref: %AdapterMethod.type = name_ref AdapterMethod, @SomeClass.%AdapterMethod.decl [template = constants.%AdapterMethod]
  200. // CHECK:STDOUT: %.loc24: <bound method> = bound_method %a.ref, %AdapterMethod.ref
  201. // CHECK:STDOUT: %AdapterMethod.call: init %.1 = call %.loc24(%a.ref)
  202. // CHECK:STDOUT: return
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: --- fail_todo_method_access.carbon
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: constants {
  208. // CHECK:STDOUT: %SomeClass: type = class_type @SomeClass [template]
  209. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  210. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  211. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  212. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  213. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  214. // CHECK:STDOUT: %SomeClassAdapter: type = class_type @SomeClassAdapter [template]
  215. // CHECK:STDOUT: %.4: type = ptr_type %.2 [template]
  216. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %SomeClass [template]
  217. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  218. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  219. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  220. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  221. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  222. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  223. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  224. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  225. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  226. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  227. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  228. // CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  229. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  230. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%SomeClass) [template]
  231. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%SomeClass) [template]
  232. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  233. // CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  234. // CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.5 [template]
  235. // CHECK:STDOUT: %.10: %.6 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: imports {
  239. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  240. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  241. // CHECK:STDOUT: import Core//prelude
  242. // CHECK:STDOUT: import Core//prelude/operators
  243. // CHECK:STDOUT: import Core//prelude/types
  244. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  245. // CHECK:STDOUT: import Core//prelude/operators/as
  246. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  247. // CHECK:STDOUT: import Core//prelude/operators/comparison
  248. // CHECK:STDOUT: import Core//prelude/types/bool
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+46, loaded [template = constants.%ImplicitAs]
  251. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+52, unloaded
  252. // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.6) = import_ref Core//prelude/operators/as, inst+71, loaded [symbolic = @ImplicitAs.%.2 (constants.%.10)]
  253. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+64, unloaded
  254. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+64, unloaded
  255. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+64, unloaded
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: file {
  259. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  260. // CHECK:STDOUT: .Core = imports.%Core
  261. // CHECK:STDOUT: .SomeClass = %SomeClass.decl
  262. // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl
  263. // CHECK:STDOUT: .F = %F.decl
  264. // CHECK:STDOUT: }
  265. // CHECK:STDOUT: %Core.import = import Core
  266. // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {} {}
  267. // CHECK:STDOUT: %SomeClassAdapter.decl: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} {}
  268. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  269. // CHECK:STDOUT: %a.patt: %SomeClassAdapter = binding_pattern a
  270. // CHECK:STDOUT: %a.param_patt: %SomeClassAdapter = param_pattern %a.patt, runtime_param0
  271. // CHECK:STDOUT: } {
  272. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, file.%SomeClassAdapter.decl [template = constants.%SomeClassAdapter]
  273. // CHECK:STDOUT: %param: %SomeClassAdapter = param runtime_param0
  274. // CHECK:STDOUT: %a: %SomeClassAdapter = bind_name a, %param
  275. // CHECK:STDOUT: }
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  279. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  280. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: !definition:
  283. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  284. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  285. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  286. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  287. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.6)]
  288. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.6) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.7)]
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: interface {
  291. // CHECK:STDOUT: !members:
  292. // CHECK:STDOUT: .Self = imports.%import_ref.2
  293. // CHECK:STDOUT: .Convert = imports.%import_ref.3
  294. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: class @SomeClass {
  299. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {
  300. // CHECK:STDOUT: %self.patt: %SomeClass = binding_pattern self
  301. // CHECK:STDOUT: %self.param_patt: %SomeClass = param_pattern %self.patt, runtime_param0
  302. // CHECK:STDOUT: } {
  303. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%SomeClass [template = constants.%SomeClass]
  304. // CHECK:STDOUT: %param: %SomeClass = param runtime_param0
  305. // CHECK:STDOUT: %self: %SomeClass = bind_name self, %param
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.2 [template = constants.%.3]
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: !members:
  310. // CHECK:STDOUT: .Self = constants.%SomeClass
  311. // CHECK:STDOUT: .F = %F.decl
  312. // CHECK:STDOUT: }
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: class @SomeClassAdapter {
  315. // CHECK:STDOUT: %SomeClass.ref: type = name_ref SomeClass, file.%SomeClass.decl [template = constants.%SomeClass]
  316. // CHECK:STDOUT: adapt_decl %SomeClass
  317. // CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %SomeClass [template = constants.%.5]
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: !members:
  320. // CHECK:STDOUT: .Self = constants.%SomeClassAdapter
  321. // CHECK:STDOUT: extend name_scope2
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: fn @F.1[%self.param_patt: %SomeClass]();
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: fn @F.2(%a.param_patt: %SomeClassAdapter) {
  327. // CHECK:STDOUT: !entry:
  328. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  329. // CHECK:STDOUT: %F.ref: %F.type.1 = name_ref F, @SomeClass.%F.decl [template = constants.%F.1]
  330. // CHECK:STDOUT: %.loc23_4: <bound method> = bound_method %a.ref, %F.ref
  331. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%SomeClass) [template = constants.%ImplicitAs.type.3]
  332. // CHECK:STDOUT: %.loc23_3.1: %.8 = specific_constant imports.%import_ref.3, @ImplicitAs(constants.%SomeClass) [template = constants.%.9]
  333. // CHECK:STDOUT: %Convert.ref: %.8 = name_ref Convert, %.loc23_3.1 [template = constants.%.9]
  334. // CHECK:STDOUT: %.loc23_3.2: %SomeClass = converted %a.ref, <error> [template = <error>]
  335. // CHECK:STDOUT: %F.call: init %.1 = call %.loc23_4(<invalid>) [template = <error>]
  336. // CHECK:STDOUT: return
  337. // CHECK:STDOUT: }
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  340. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  341. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  342. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  348. // CHECK:STDOUT: %Dest => constants.%Dest
  349. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  353. // CHECK:STDOUT: %Dest => constants.%Dest
  354. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  358. // CHECK:STDOUT: %Dest => constants.%Dest
  359. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  363. // CHECK:STDOUT: %Dest => constants.%Dest
  364. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  365. // CHECK:STDOUT: %Self => constants.%Self.1
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: specific @ImplicitAs(constants.%SomeClass) {
  369. // CHECK:STDOUT: %Dest => constants.%SomeClass
  370. // CHECK:STDOUT: %Dest.patt => constants.%SomeClass
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: !definition:
  373. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  374. // CHECK:STDOUT: %Self => constants.%Self.2
  375. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  376. // CHECK:STDOUT: %Convert => constants.%Convert.2
  377. // CHECK:STDOUT: %.1 => constants.%.8
  378. // CHECK:STDOUT: %.2 => constants.%.9
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: --- fail_todo_field_access.carbon
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: constants {
  384. // CHECK:STDOUT: %SomeClass: type = class_type @SomeClass [template]
  385. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  386. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  387. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  388. // CHECK:STDOUT: %.2: type = unbound_element_type %SomeClass, i32 [template]
  389. // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
  390. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  391. // CHECK:STDOUT: %SomeClassAdapter: type = class_type @SomeClassAdapter [template]
  392. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  393. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %SomeClass [template]
  394. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  395. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  396. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  397. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  398. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  399. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  400. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  401. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  402. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  403. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  404. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  405. // CHECK:STDOUT: %.7: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  406. // CHECK:STDOUT: %.8: %.7 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  407. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%SomeClass) [template]
  408. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%SomeClass) [template]
  409. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  410. // CHECK:STDOUT: %.9: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  411. // CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.6 [template]
  412. // CHECK:STDOUT: %.11: %.7 = assoc_entity element0, imports.%import_ref.7 [symbolic]
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: imports {
  416. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  417. // CHECK:STDOUT: .Int32 = %import_ref.1
  418. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  419. // CHECK:STDOUT: import Core//prelude
  420. // CHECK:STDOUT: import Core//prelude/operators
  421. // CHECK:STDOUT: import Core//prelude/types
  422. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  423. // CHECK:STDOUT: import Core//prelude/operators/as
  424. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  425. // CHECK:STDOUT: import Core//prelude/operators/comparison
  426. // CHECK:STDOUT: import Core//prelude/types/bool
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  429. // CHECK:STDOUT: %import_ref.2: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+46, loaded [template = constants.%ImplicitAs]
  430. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/as, inst+52, unloaded
  431. // CHECK:STDOUT: %import_ref.4: @ImplicitAs.%.1 (%.7) = import_ref Core//prelude/operators/as, inst+71, loaded [symbolic = @ImplicitAs.%.2 (constants.%.11)]
  432. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+64, unloaded
  433. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+64, unloaded
  434. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+64, unloaded
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT:
  437. // CHECK:STDOUT: file {
  438. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  439. // CHECK:STDOUT: .Core = imports.%Core
  440. // CHECK:STDOUT: .SomeClass = %SomeClass.decl
  441. // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl
  442. // CHECK:STDOUT: .F = %F.decl
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT: %Core.import = import Core
  445. // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {} {}
  446. // CHECK:STDOUT: %SomeClassAdapter.decl: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} {}
  447. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  448. // CHECK:STDOUT: %a.patt: %SomeClassAdapter = binding_pattern a
  449. // CHECK:STDOUT: %a.param_patt: %SomeClassAdapter = param_pattern %a.patt, runtime_param0
  450. // CHECK:STDOUT: } {
  451. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, file.%SomeClassAdapter.decl [template = constants.%SomeClassAdapter]
  452. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  453. // CHECK:STDOUT: %.loc13_30.1: type = value_of_initializer %int.make_type_32 [template = i32]
  454. // CHECK:STDOUT: %.loc13_30.2: type = converted %int.make_type_32, %.loc13_30.1 [template = i32]
  455. // CHECK:STDOUT: %return: ref i32 = var <return slot>
  456. // CHECK:STDOUT: %param: %SomeClassAdapter = param runtime_param0
  457. // CHECK:STDOUT: %a: %SomeClassAdapter = bind_name a, %param
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT: }
  460. // CHECK:STDOUT:
  461. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  462. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  463. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  464. // CHECK:STDOUT:
  465. // CHECK:STDOUT: !definition:
  466. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  467. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  468. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  469. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  470. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.7)]
  471. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.7) = assoc_entity element0, imports.%import_ref.6 [symbolic = %.2 (constants.%.8)]
  472. // CHECK:STDOUT:
  473. // CHECK:STDOUT: interface {
  474. // CHECK:STDOUT: !members:
  475. // CHECK:STDOUT: .Self = imports.%import_ref.3
  476. // CHECK:STDOUT: .Convert = imports.%import_ref.4
  477. // CHECK:STDOUT: witness = (imports.%import_ref.5)
  478. // CHECK:STDOUT: }
  479. // CHECK:STDOUT: }
  480. // CHECK:STDOUT:
  481. // CHECK:STDOUT: class @SomeClass {
  482. // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
  483. // CHECK:STDOUT: %.loc5_10.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
  484. // CHECK:STDOUT: %.loc5_10.2: type = converted %int.make_type_32.loc5, %.loc5_10.1 [template = i32]
  485. // CHECK:STDOUT: %.loc5_8: %.2 = field_decl a, element0 [template]
  486. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  487. // CHECK:STDOUT: %.loc6_10.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  488. // CHECK:STDOUT: %.loc6_10.2: type = converted %int.make_type_32.loc6, %.loc6_10.1 [template = i32]
  489. // CHECK:STDOUT: %.loc6_8: %.2 = field_decl b, element1 [template]
  490. // CHECK:STDOUT: %.loc7: <witness> = complete_type_witness %.3 [template = constants.%.4]
  491. // CHECK:STDOUT:
  492. // CHECK:STDOUT: !members:
  493. // CHECK:STDOUT: .Self = constants.%SomeClass
  494. // CHECK:STDOUT: .a = %.loc5_8
  495. // CHECK:STDOUT: .b = %.loc6_8
  496. // CHECK:STDOUT: }
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: class @SomeClassAdapter {
  499. // CHECK:STDOUT: %SomeClass.ref: type = name_ref SomeClass, file.%SomeClass.decl [template = constants.%SomeClass]
  500. // CHECK:STDOUT: adapt_decl %SomeClass
  501. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %SomeClass [template = constants.%.6]
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: !members:
  504. // CHECK:STDOUT: .Self = constants.%SomeClassAdapter
  505. // CHECK:STDOUT: extend name_scope2
  506. // CHECK:STDOUT: }
  507. // CHECK:STDOUT:
  508. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: fn @F(%a.param_patt: %SomeClassAdapter) -> i32 {
  511. // CHECK:STDOUT: !entry:
  512. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  513. // CHECK:STDOUT: %b.ref: %.2 = name_ref b, @SomeClass.%.loc6_8 [template = @SomeClass.%.loc6_8]
  514. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%SomeClass) [template = constants.%ImplicitAs.type.3]
  515. // CHECK:STDOUT: %.loc21_11.1: %.9 = specific_constant imports.%import_ref.4, @ImplicitAs(constants.%SomeClass) [template = constants.%.10]
  516. // CHECK:STDOUT: %Convert.ref: %.9 = name_ref Convert, %.loc21_11.1 [template = constants.%.10]
  517. // CHECK:STDOUT: %.loc21_11.2: %SomeClass = converted %a.ref, <error> [template = <error>]
  518. // CHECK:STDOUT: %.loc21_11.3: i32 = class_element_access <error>, element1 [template = <error>]
  519. // CHECK:STDOUT: return <error>
  520. // CHECK:STDOUT: }
  521. // CHECK:STDOUT:
  522. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  523. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  524. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  525. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  526. // CHECK:STDOUT:
  527. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  531. // CHECK:STDOUT: %Dest => constants.%Dest
  532. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  533. // CHECK:STDOUT: }
  534. // CHECK:STDOUT:
  535. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  536. // CHECK:STDOUT: %Dest => constants.%Dest
  537. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  538. // CHECK:STDOUT: }
  539. // CHECK:STDOUT:
  540. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  541. // CHECK:STDOUT: %Dest => constants.%Dest
  542. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  543. // CHECK:STDOUT: }
  544. // CHECK:STDOUT:
  545. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  546. // CHECK:STDOUT: %Dest => constants.%Dest
  547. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  548. // CHECK:STDOUT: %Self => constants.%Self.1
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: specific @ImplicitAs(constants.%SomeClass) {
  552. // CHECK:STDOUT: %Dest => constants.%SomeClass
  553. // CHECK:STDOUT: %Dest.patt => constants.%SomeClass
  554. // CHECK:STDOUT:
  555. // CHECK:STDOUT: !definition:
  556. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  557. // CHECK:STDOUT: %Self => constants.%Self.2
  558. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  559. // CHECK:STDOUT: %Convert => constants.%Convert.2
  560. // CHECK:STDOUT: %.1 => constants.%.9
  561. // CHECK:STDOUT: %.2 => constants.%.10
  562. // CHECK:STDOUT: }
  563. // CHECK:STDOUT:
  564. // CHECK:STDOUT: --- fail_todo_adapt_non_class.carbon
  565. // CHECK:STDOUT:
  566. // CHECK:STDOUT: constants {
  567. // CHECK:STDOUT: %StructAdapter: type = class_type @StructAdapter [template]
  568. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  569. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  570. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  571. // CHECK:STDOUT: %.2: type = struct_type {.a: i32, .b: i32} [template]
  572. // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
  573. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.2 [template]
  574. // CHECK:STDOUT: }
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: imports {
  577. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  578. // CHECK:STDOUT: .Int32 = %import_ref
  579. // CHECK:STDOUT: import Core//prelude
  580. // CHECK:STDOUT: import Core//prelude/operators
  581. // CHECK:STDOUT: import Core//prelude/types
  582. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  583. // CHECK:STDOUT: import Core//prelude/operators/as
  584. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  585. // CHECK:STDOUT: import Core//prelude/operators/comparison
  586. // CHECK:STDOUT: import Core//prelude/types/bool
  587. // CHECK:STDOUT: }
  588. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  589. // CHECK:STDOUT: }
  590. // CHECK:STDOUT:
  591. // CHECK:STDOUT: file {
  592. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  593. // CHECK:STDOUT: .Core = imports.%Core
  594. // CHECK:STDOUT: .StructAdapter = %StructAdapter.decl
  595. // CHECK:STDOUT: }
  596. // CHECK:STDOUT: %Core.import = import Core
  597. // CHECK:STDOUT: %StructAdapter.decl: type = class_decl @StructAdapter [template = constants.%StructAdapter] {} {}
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT:
  600. // CHECK:STDOUT: class @StructAdapter {
  601. // CHECK:STDOUT: %int.make_type_32.loc8_21: init type = call constants.%Int32() [template = i32]
  602. // CHECK:STDOUT: %.loc8_21.1: type = value_of_initializer %int.make_type_32.loc8_21 [template = i32]
  603. // CHECK:STDOUT: %.loc8_21.2: type = converted %int.make_type_32.loc8_21, %.loc8_21.1 [template = i32]
  604. // CHECK:STDOUT: %int.make_type_32.loc8_30: init type = call constants.%Int32() [template = i32]
  605. // CHECK:STDOUT: %.loc8_30.1: type = value_of_initializer %int.make_type_32.loc8_30 [template = i32]
  606. // CHECK:STDOUT: %.loc8_30.2: type = converted %int.make_type_32.loc8_30, %.loc8_30.1 [template = i32]
  607. // CHECK:STDOUT: %.loc8_33: type = struct_type {.a: i32, .b: i32} [template = constants.%.2]
  608. // CHECK:STDOUT: adapt_decl %.2
  609. // CHECK:STDOUT: %.loc9: <witness> = complete_type_witness %.2 [template = constants.%.4]
  610. // CHECK:STDOUT:
  611. // CHECK:STDOUT: !members:
  612. // CHECK:STDOUT: .Self = constants.%StructAdapter
  613. // CHECK:STDOUT: has_error
  614. // CHECK:STDOUT: }
  615. // CHECK:STDOUT:
  616. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  617. // CHECK:STDOUT: