extend_adapt.carbon 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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 "basic";
  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 "fail_todo_method_access";
  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+7]]: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-11]]:8: Initializing `self` parameter of method declared here.
  41. // CHECK:STDERR: fn F[self: Self]();
  42. // CHECK:STDERR: ^~~~
  43. // CHECK:STDERR:
  44. a.F();
  45. }
  46. // --- fail_todo_field_access.carbon
  47. library "fail_todo_field_access";
  48. class SomeClass {
  49. var a: i32;
  50. var b: i32;
  51. }
  52. class SomeClassAdapter {
  53. extend adapt SomeClass;
  54. }
  55. fn F(a: SomeClassAdapter) -> i32 {
  56. // CHECK:STDERR: fail_todo_field_access.carbon:[[@LINE+4]]:10: ERROR: Cannot implicitly convert from `SomeClassAdapter` to `SomeClass`.
  57. // CHECK:STDERR: return a.b;
  58. // CHECK:STDERR: ^~~
  59. // CHECK:STDERR:
  60. return a.b;
  61. }
  62. // --- fail_todo_adapt_non_class.carbon
  63. library "fail_todo_adapt_non_class";
  64. class StructAdapter {
  65. // CHECK:STDERR: fail_todo_adapt_non_class.carbon:[[@LINE+3]]:3: ERROR: Semantics TODO: `extending non-class type`.
  66. // CHECK:STDERR: extend adapt {.a: i32, .b: i32};
  67. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. extend adapt {.a: i32, .b: i32};
  69. }
  70. // CHECK:STDOUT: --- basic.carbon
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: constants {
  73. // CHECK:STDOUT: %SomeClassAdapter: type = class_type @SomeClassAdapter [template]
  74. // CHECK:STDOUT: %SomeClass: type = class_type @SomeClass [template]
  75. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  76. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  77. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  78. // CHECK:STDOUT: %.2: type = unbound_element_type %SomeClass, i32 [template]
  79. // CHECK:STDOUT: %StaticMemberFunction.type: type = fn_type @StaticMemberFunction [template]
  80. // CHECK:STDOUT: %StaticMemberFunction: %StaticMemberFunction.type = struct_value () [template]
  81. // CHECK:STDOUT: %AdapterMethod.type: type = fn_type @AdapterMethod [template]
  82. // CHECK:STDOUT: %AdapterMethod: %AdapterMethod.type = struct_value () [template]
  83. // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
  84. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  85. // CHECK:STDOUT: %TestStaticMemberFunction.type: type = fn_type @TestStaticMemberFunction [template]
  86. // CHECK:STDOUT: %TestStaticMemberFunction: %TestStaticMemberFunction.type = struct_value () [template]
  87. // CHECK:STDOUT: %TestAdapterMethod.type: type = fn_type @TestAdapterMethod [template]
  88. // CHECK:STDOUT: %TestAdapterMethod: %TestAdapterMethod.type = struct_value () [template]
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: file {
  92. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  93. // CHECK:STDOUT: .Core = %Core
  94. // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl.loc4
  95. // CHECK:STDOUT: .SomeClass = %SomeClass.decl
  96. // CHECK:STDOUT: .TestStaticMemberFunction = %TestStaticMemberFunction.decl
  97. // CHECK:STDOUT: .TestAdapterMethod = %TestAdapterMethod.decl
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  100. // CHECK:STDOUT: %SomeClassAdapter.decl.loc4: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {}
  101. // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {}
  102. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  103. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  104. // CHECK:STDOUT: %SomeClassAdapter.decl.loc15: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {}
  105. // CHECK:STDOUT: %TestStaticMemberFunction.decl: %TestStaticMemberFunction.type = fn_decl @TestStaticMemberFunction [template = constants.%TestStaticMemberFunction] {
  106. // CHECK:STDOUT: %SomeClassAdapter.ref.loc19: type = name_ref SomeClassAdapter, %SomeClassAdapter.decl.loc4 [template = constants.%SomeClassAdapter]
  107. // CHECK:STDOUT: %a.loc19_29.1: %SomeClassAdapter = param a
  108. // CHECK:STDOUT: @TestStaticMemberFunction.%a: %SomeClassAdapter = bind_name a, %a.loc19_29.1
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %TestAdapterMethod.decl: %TestAdapterMethod.type = fn_decl @TestAdapterMethod [template = constants.%TestAdapterMethod] {
  111. // CHECK:STDOUT: %SomeClassAdapter.ref.loc23: type = name_ref SomeClassAdapter, %SomeClassAdapter.decl.loc4 [template = constants.%SomeClassAdapter]
  112. // CHECK:STDOUT: %a.loc23_22.1: %SomeClassAdapter = param a
  113. // CHECK:STDOUT: @TestAdapterMethod.%a: %SomeClassAdapter = bind_name a, %a.loc23_22.1
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: class @SomeClassAdapter {
  118. // CHECK:STDOUT: %SomeClass.ref: type = name_ref SomeClass, file.%SomeClass.decl [template = constants.%SomeClass]
  119. // CHECK:STDOUT: adapt_decl %SomeClass
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: !members:
  122. // CHECK:STDOUT: .Self = constants.%SomeClassAdapter
  123. // CHECK:STDOUT: extend name_scope2
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: class @SomeClass {
  127. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  128. // CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  129. // CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32.loc7, %.loc7_10.1 [template = i32]
  130. // CHECK:STDOUT: %.loc7_8: %.2 = field_decl a, element0 [template]
  131. // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
  132. // CHECK:STDOUT: %.loc8_10.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
  133. // CHECK:STDOUT: %.loc8_10.2: type = converted %int.make_type_32.loc8, %.loc8_10.1 [template = i32]
  134. // CHECK:STDOUT: %.loc8_8: %.2 = field_decl b, element1 [template]
  135. // CHECK:STDOUT: %StaticMemberFunction.decl: %StaticMemberFunction.type = fn_decl @StaticMemberFunction [template = constants.%StaticMemberFunction] {}
  136. // CHECK:STDOUT: %AdapterMethod.decl: %AdapterMethod.type = fn_decl @AdapterMethod [template = constants.%AdapterMethod] {
  137. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, file.%SomeClassAdapter.decl.loc4 [template = constants.%SomeClassAdapter]
  138. // CHECK:STDOUT: %self.loc12_20.1: %SomeClassAdapter = param self
  139. // CHECK:STDOUT: %self.loc12_20.2: %SomeClassAdapter = bind_name self, %self.loc12_20.1
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: !members:
  143. // CHECK:STDOUT: .Self = constants.%SomeClass
  144. // CHECK:STDOUT: .a = %.loc7_8
  145. // CHECK:STDOUT: .b = %.loc8_8
  146. // CHECK:STDOUT: .StaticMemberFunction = %StaticMemberFunction.decl
  147. // CHECK:STDOUT: .AdapterMethod = %AdapterMethod.decl
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: fn @StaticMemberFunction();
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: fn @AdapterMethod[@SomeClass.%self.loc12_20.2: %SomeClassAdapter]();
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: fn @TestStaticMemberFunction(%a: %SomeClassAdapter) {
  157. // CHECK:STDOUT: !entry:
  158. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  159. // CHECK:STDOUT: %StaticMemberFunction.ref: %StaticMemberFunction.type = name_ref StaticMemberFunction, @SomeClass.%StaticMemberFunction.decl [template = constants.%StaticMemberFunction]
  160. // CHECK:STDOUT: %StaticMemberFunction.call: init %.1 = call %StaticMemberFunction.ref()
  161. // CHECK:STDOUT: return
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: fn @TestAdapterMethod(%a: %SomeClassAdapter) {
  165. // CHECK:STDOUT: !entry:
  166. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  167. // CHECK:STDOUT: %AdapterMethod.ref: %AdapterMethod.type = name_ref AdapterMethod, @SomeClass.%AdapterMethod.decl [template = constants.%AdapterMethod]
  168. // CHECK:STDOUT: %.loc24: <bound method> = bound_method %a.ref, %AdapterMethod.ref
  169. // CHECK:STDOUT: %AdapterMethod.call: init %.1 = call %.loc24(%a.ref)
  170. // CHECK:STDOUT: return
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: --- fail_todo_method_access.carbon
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: constants {
  176. // CHECK:STDOUT: %SomeClass: type = class_type @SomeClass [template]
  177. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  178. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  179. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  180. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  181. // CHECK:STDOUT: %SomeClassAdapter: type = class_type @SomeClassAdapter [template]
  182. // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
  183. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  184. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: file {
  188. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  189. // CHECK:STDOUT: .Core = %Core
  190. // CHECK:STDOUT: .SomeClass = %SomeClass.decl
  191. // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl
  192. // CHECK:STDOUT: .F = %F.decl
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  195. // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {}
  196. // CHECK:STDOUT: %SomeClassAdapter.decl: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {}
  197. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  198. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, %SomeClassAdapter.decl [template = constants.%SomeClassAdapter]
  199. // CHECK:STDOUT: %a.loc12_6.1: %SomeClassAdapter = param a
  200. // CHECK:STDOUT: @F.2.%a: %SomeClassAdapter = bind_name a, %a.loc12_6.1
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: class @SomeClass {
  205. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {
  206. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%SomeClass [template = constants.%SomeClass]
  207. // CHECK:STDOUT: %self.loc5_8.1: %SomeClass = param self
  208. // CHECK:STDOUT: %self.loc5_8.2: %SomeClass = bind_name self, %self.loc5_8.1
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: !members:
  212. // CHECK:STDOUT: .Self = constants.%SomeClass
  213. // CHECK:STDOUT: .F = %F.decl
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: class @SomeClassAdapter {
  217. // CHECK:STDOUT: %SomeClass.ref: type = name_ref SomeClass, file.%SomeClass.decl [template = constants.%SomeClass]
  218. // CHECK:STDOUT: adapt_decl %SomeClass
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: !members:
  221. // CHECK:STDOUT: .Self = constants.%SomeClassAdapter
  222. // CHECK:STDOUT: extend name_scope2
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: fn @F.1[@SomeClass.%self.loc5_8.2: %SomeClass]();
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: fn @F.2(%a: %SomeClassAdapter) {
  228. // CHECK:STDOUT: !entry:
  229. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  230. // CHECK:STDOUT: %F.ref: %F.type.1 = name_ref F, @SomeClass.%F.decl [template = constants.%F.1]
  231. // CHECK:STDOUT: %.loc20: <bound method> = bound_method %a.ref, %F.ref
  232. // CHECK:STDOUT: %F.call: init %.1 = call %.loc20(<invalid>) [template = <error>]
  233. // CHECK:STDOUT: return
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: --- fail_todo_field_access.carbon
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: constants {
  239. // CHECK:STDOUT: %SomeClass: type = class_type @SomeClass [template]
  240. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  241. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  242. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  243. // CHECK:STDOUT: %.2: type = unbound_element_type %SomeClass, i32 [template]
  244. // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
  245. // CHECK:STDOUT: %SomeClassAdapter: type = class_type @SomeClassAdapter [template]
  246. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  247. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  248. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: file {
  252. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  253. // CHECK:STDOUT: .Core = %Core
  254. // CHECK:STDOUT: .SomeClass = %SomeClass.decl
  255. // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl
  256. // CHECK:STDOUT: .F = %F.decl
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  259. // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {}
  260. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  261. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  262. // CHECK:STDOUT: %SomeClassAdapter.decl: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {}
  263. // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  264. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  265. // CHECK:STDOUT: %SomeClassAdapter.ref: type = name_ref SomeClassAdapter, %SomeClassAdapter.decl [template = constants.%SomeClassAdapter]
  266. // CHECK:STDOUT: %a.loc13_6.1: %SomeClassAdapter = param a
  267. // CHECK:STDOUT: @F.%a: %SomeClassAdapter = bind_name a, %a.loc13_6.1
  268. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  269. // CHECK:STDOUT: %.loc13_30.1: type = value_of_initializer %int.make_type_32 [template = i32]
  270. // CHECK:STDOUT: %.loc13_30.2: type = converted %int.make_type_32, %.loc13_30.1 [template = i32]
  271. // CHECK:STDOUT: @F.%return: ref i32 = var <return slot>
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: class @SomeClass {
  276. // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
  277. // CHECK:STDOUT: %.loc5_10.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
  278. // CHECK:STDOUT: %.loc5_10.2: type = converted %int.make_type_32.loc5, %.loc5_10.1 [template = i32]
  279. // CHECK:STDOUT: %.loc5_8: %.2 = field_decl a, element0 [template]
  280. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  281. // CHECK:STDOUT: %.loc6_10.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  282. // CHECK:STDOUT: %.loc6_10.2: type = converted %int.make_type_32.loc6, %.loc6_10.1 [template = i32]
  283. // CHECK:STDOUT: %.loc6_8: %.2 = field_decl b, element1 [template]
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: !members:
  286. // CHECK:STDOUT: .Self = constants.%SomeClass
  287. // CHECK:STDOUT: .a = %.loc5_8
  288. // CHECK:STDOUT: .b = %.loc6_8
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: class @SomeClassAdapter {
  292. // CHECK:STDOUT: %SomeClass.ref: type = name_ref SomeClass, file.%SomeClass.decl [template = constants.%SomeClass]
  293. // CHECK:STDOUT: adapt_decl %SomeClass
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: !members:
  296. // CHECK:STDOUT: .Self = constants.%SomeClassAdapter
  297. // CHECK:STDOUT: extend name_scope2
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: fn @F(%a: %SomeClassAdapter) -> i32 {
  303. // CHECK:STDOUT: !entry:
  304. // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a
  305. // CHECK:STDOUT: %b.ref: %.2 = name_ref b, @SomeClass.%.loc6_8 [template = @SomeClass.%.loc6_8]
  306. // CHECK:STDOUT: %.loc18: i32 = class_element_access <error>, element1 [template = <error>]
  307. // CHECK:STDOUT: return <error>
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: --- fail_todo_adapt_non_class.carbon
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: constants {
  313. // CHECK:STDOUT: %StructAdapter: type = class_type @StructAdapter [template]
  314. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  315. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  316. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  317. // CHECK:STDOUT: %.2: type = struct_type {.a: i32, .b: i32} [template]
  318. // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
  319. // CHECK:STDOUT: }
  320. // CHECK:STDOUT:
  321. // CHECK:STDOUT: file {
  322. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  323. // CHECK:STDOUT: .Core = %Core
  324. // CHECK:STDOUT: .StructAdapter = %StructAdapter.decl
  325. // CHECK:STDOUT: }
  326. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  327. // CHECK:STDOUT: %StructAdapter.decl: type = class_decl @StructAdapter [template = constants.%StructAdapter] {}
  328. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  329. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: class @StructAdapter {
  333. // CHECK:STDOUT: %int.make_type_32.loc8_21: init type = call constants.%Int32() [template = i32]
  334. // CHECK:STDOUT: %.loc8_21.1: type = value_of_initializer %int.make_type_32.loc8_21 [template = i32]
  335. // CHECK:STDOUT: %.loc8_21.2: type = converted %int.make_type_32.loc8_21, %.loc8_21.1 [template = i32]
  336. // CHECK:STDOUT: %int.make_type_32.loc8_30: init type = call constants.%Int32() [template = i32]
  337. // CHECK:STDOUT: %.loc8_30.1: type = value_of_initializer %int.make_type_32.loc8_30 [template = i32]
  338. // CHECK:STDOUT: %.loc8_30.2: type = converted %int.make_type_32.loc8_30, %.loc8_30.1 [template = i32]
  339. // CHECK:STDOUT: %.loc8_33: type = struct_type {.a: i32, .b: i32} [template = constants.%.2]
  340. // CHECK:STDOUT: adapt_decl %.2
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: !members:
  343. // CHECK:STDOUT: .Self = constants.%StructAdapter
  344. // CHECK:STDOUT: has_error
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  348. // CHECK:STDOUT: