virtual_modifiers.carbon 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491
  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/virtual_modifiers.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/virtual_modifiers.carbon
  10. // --- modifiers.carbon
  11. package Modifiers;
  12. base class Base {
  13. virtual fn H();
  14. }
  15. abstract class Abstract {
  16. abstract fn J();
  17. virtual fn K();
  18. }
  19. // --- override_import.carbon
  20. library "[[@TEST_NAME]]";
  21. import Modifiers;
  22. class Derived {
  23. extend base: Modifiers.Base;
  24. impl fn H();
  25. }
  26. // --- todo_fail_later_base.carbon
  27. library "[[@TEST_NAME]]";
  28. import Modifiers;
  29. base class Derived {
  30. virtual fn F();
  31. extend base: Modifiers.Base;
  32. }
  33. // --- init.carbon
  34. library "[[@TEST_NAME]]";
  35. import Modifiers;
  36. fn F() {
  37. var v: Modifiers.Base = {};
  38. }
  39. // --- impl_abstract.carbon
  40. library "[[@TEST_NAME]]";
  41. abstract class A1 {
  42. virtual fn F();
  43. }
  44. abstract class A2 {
  45. extend base: A1;
  46. impl fn F();
  47. }
  48. // --- impl_base.carbon
  49. library "[[@TEST_NAME]]";
  50. base class B1 {
  51. virtual fn F();
  52. }
  53. base class B2 {
  54. extend base: B1;
  55. impl fn F();
  56. }
  57. class C {
  58. extend base: B2;
  59. impl fn F();
  60. }
  61. // --- fail_modifiers.carbon
  62. library "[[@TEST_NAME]]";
  63. class C {
  64. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:3: error: impl without base class [ImplWithoutBase]
  65. // CHECK:STDERR: impl fn F();
  66. // CHECK:STDERR: ^~~~~~~~~~~~
  67. // CHECK:STDERR:
  68. impl fn F();
  69. }
  70. // --- init_members.carbon
  71. library "[[@TEST_NAME]]";
  72. base class Base {
  73. var m1: i32;
  74. var m2: i32;
  75. virtual fn F();
  76. }
  77. fn F() {
  78. var i: i32 = 3;
  79. // TODO: These should initialize element1 (.m), not element0 (the vptr)
  80. var b1: Base = {.m2 = i, .m1 = i};
  81. var b2: Base = {.m2 = 3, .m1 = 5};
  82. // This one is good, though.
  83. b1.m2 = 4;
  84. }
  85. // --- todo_fail_impl_without_base_declaration.carbon
  86. library "[[@TEST_NAME]]";
  87. base class Base {
  88. }
  89. class Derived {
  90. extend base: Base;
  91. impl fn F();
  92. }
  93. // --- abstract_impl.carbon
  94. library "[[@TEST_NAME]]";
  95. abstract class AbstractBase {
  96. abstract fn F();
  97. }
  98. abstract class AbstractIntermediate {
  99. extend base: AbstractBase;
  100. }
  101. class Derived {
  102. extend base: AbstractIntermediate;
  103. impl fn F();
  104. }
  105. // --- virtual_impl.carbon
  106. library "[[@TEST_NAME]]";
  107. base class VirtualBase {
  108. virtual fn F();
  109. }
  110. base class VirtualIntermediate {
  111. extend base: VirtualBase;
  112. }
  113. class Derived {
  114. extend base: VirtualIntermediate;
  115. impl fn F();
  116. }
  117. // --- fail_impl_mismatch.carbon
  118. library "[[@TEST_NAME]]";
  119. base class Base {
  120. virtual fn F();
  121. }
  122. class Derived {
  123. extend base: Base;
  124. // CHECK:STDERR: fail_impl_mismatch.carbon:[[@LINE+7]]:3: error: redeclaration differs because of parameter count of 1 [RedeclParamCountDiffers]
  125. // CHECK:STDERR: impl fn F(v: i32);
  126. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  127. // CHECK:STDERR: fail_impl_mismatch.carbon:[[@LINE-8]]:3: note: previously declared with parameter count of 0 [RedeclParamCountPrevious]
  128. // CHECK:STDERR: virtual fn F();
  129. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  130. // CHECK:STDERR:
  131. impl fn F(v: i32);
  132. }
  133. // --- fail_todo_impl_conversion.carbon
  134. library "[[@TEST_NAME]]";
  135. class T1 {
  136. }
  137. class T2 {
  138. }
  139. impl T2 as Core.ImplicitAs(T1) {
  140. fn Convert[self: Self]() -> T1 {
  141. return {};
  142. }
  143. }
  144. base class Base {
  145. virtual fn F() -> T1;
  146. }
  147. class Derived {
  148. extend base: Base;
  149. // CHECK:STDERR: fail_todo_impl_conversion.carbon:[[@LINE+7]]:3: error: function redeclaration differs because return type is `T2` [FunctionRedeclReturnTypeDiffers]
  150. // CHECK:STDERR: impl fn F() -> T2;
  151. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  152. // CHECK:STDERR: fail_todo_impl_conversion.carbon:[[@LINE-8]]:3: note: previously declared with return type `T1` [FunctionRedeclReturnTypePrevious]
  153. // CHECK:STDERR: virtual fn F() -> T1;
  154. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  155. // CHECK:STDERR:
  156. impl fn F() -> T2;
  157. }
  158. // --- fail_todo_impl_generic_base.carbon
  159. library "[[@TEST_NAME]]";
  160. class T1 {
  161. }
  162. base class Base(T:! type) {
  163. virtual fn F(t: T);
  164. }
  165. class Derived {
  166. extend base: Base(T1);
  167. // CHECK:STDERR: fail_todo_impl_generic_base.carbon:[[@LINE+7]]:13: error: type `T1` of parameter 1 in redeclaration differs from previous parameter type `T` [RedeclParamDiffersType]
  168. // CHECK:STDERR: impl fn F(t: T1);
  169. // CHECK:STDERR: ^~~~~
  170. // CHECK:STDERR: fail_todo_impl_generic_base.carbon:[[@LINE-8]]:16: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
  171. // CHECK:STDERR: virtual fn F(t: T);
  172. // CHECK:STDERR: ^~~~
  173. // CHECK:STDERR:
  174. impl fn F(t: T1);
  175. }
  176. // CHECK:STDOUT: --- modifiers.carbon
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: constants {
  179. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  180. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  181. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  182. // CHECK:STDOUT: %ptr: type = ptr_type <vtable> [template]
  183. // CHECK:STDOUT: %.c3d: <vtable> = vtable (%H) [template]
  184. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr} [template]
  185. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  186. // CHECK:STDOUT: %Abstract: type = class_type @Abstract [template]
  187. // CHECK:STDOUT: %J.type: type = fn_type @J [template]
  188. // CHECK:STDOUT: %J: %J.type = struct_value () [template]
  189. // CHECK:STDOUT: %K.type: type = fn_type @K [template]
  190. // CHECK:STDOUT: %K: %K.type = struct_value () [template]
  191. // CHECK:STDOUT: %.2b2: <vtable> = vtable (%J, %K) [template]
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: imports {
  195. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  196. // CHECK:STDOUT: import Core//prelude
  197. // CHECK:STDOUT: import Core//prelude/...
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: file {
  202. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  203. // CHECK:STDOUT: .Core = imports.%Core
  204. // CHECK:STDOUT: .Base = %Base.decl
  205. // CHECK:STDOUT: .Abstract = %Abstract.decl
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT: %Core.import = import Core
  208. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  209. // CHECK:STDOUT: %Abstract.decl: type = class_decl @Abstract [template = constants.%Abstract] {} {}
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: class @Base {
  213. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {} {}
  214. // CHECK:STDOUT: %.loc6: <vtable> = vtable (%H.decl) [template = constants.%.c3d]
  215. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  216. // CHECK:STDOUT: complete_type_witness = %complete_type
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: !members:
  219. // CHECK:STDOUT: .Self = constants.%Base
  220. // CHECK:STDOUT: .H = %H.decl
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: class @Abstract {
  224. // CHECK:STDOUT: %J.decl: %J.type = fn_decl @J [template = constants.%J] {} {}
  225. // CHECK:STDOUT: %K.decl: %K.type = fn_decl @K [template = constants.%K] {} {}
  226. // CHECK:STDOUT: %.loc12: <vtable> = vtable (%J.decl, %K.decl) [template = constants.%.2b2]
  227. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  228. // CHECK:STDOUT: complete_type_witness = %complete_type
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: !members:
  231. // CHECK:STDOUT: .Self = constants.%Abstract
  232. // CHECK:STDOUT: .J = %J.decl
  233. // CHECK:STDOUT: .K = %K.decl
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: virtual fn @H();
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: abstract fn @J();
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: virtual fn @K();
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: --- override_import.carbon
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: constants {
  245. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  246. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  247. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  248. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  249. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  250. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  251. // CHECK:STDOUT: %H.type.dba: type = fn_type @H.1 [template]
  252. // CHECK:STDOUT: %H.bce: %H.type.dba = struct_value () [template]
  253. // CHECK:STDOUT: %.dce: <vtable> = vtable (%H.bce) [template]
  254. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [template]
  255. // CHECK:STDOUT: %complete_type.0e2: <witness> = complete_type_witness %struct_type.base [template]
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: imports {
  259. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  260. // CHECK:STDOUT: import Core//prelude
  261. // CHECK:STDOUT: import Core//prelude/...
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT: %Modifiers: <namespace> = namespace file.%Modifiers.import, [template] {
  264. // CHECK:STDOUT: .Base = %Modifiers.Base
  265. // CHECK:STDOUT: import Modifiers//default
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT: %Modifiers.Base: type = import_ref Modifiers//default, Base, loaded [template = constants.%Base]
  268. // CHECK:STDOUT: %Modifiers.import_ref.05e: <witness> = import_ref Modifiers//default, loc6_1, loaded [template = constants.%complete_type.513]
  269. // CHECK:STDOUT: %Modifiers.import_ref.1f3 = import_ref Modifiers//default, inst16 [no loc], unloaded
  270. // CHECK:STDOUT: %Modifiers.import_ref.2cc = import_ref Modifiers//default, loc5_17, unloaded
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: file {
  274. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  275. // CHECK:STDOUT: .Core = imports.%Core
  276. // CHECK:STDOUT: .Modifiers = imports.%Modifiers
  277. // CHECK:STDOUT: .Derived = %Derived.decl
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %Core.import = import Core
  280. // CHECK:STDOUT: %Modifiers.import = import Modifiers
  281. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: class @Derived {
  285. // CHECK:STDOUT: %Modifiers.ref: <namespace> = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers]
  286. // CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%Modifiers.Base [template = constants.%Base]
  287. // CHECK:STDOUT: %.loc7: %Derived.elem = base_decl %Base.ref, element0 [template]
  288. // CHECK:STDOUT: %H.decl: %H.type.dba = fn_decl @H.1 [template = constants.%H.bce] {} {}
  289. // CHECK:STDOUT: %.loc9: <vtable> = vtable (%H.decl) [template = constants.%.dce]
  290. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.0e2]
  291. // CHECK:STDOUT: complete_type_witness = %complete_type
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: !members:
  294. // CHECK:STDOUT: .Self = constants.%Derived
  295. // CHECK:STDOUT: .base = %.loc7
  296. // CHECK:STDOUT: .H = %H.decl
  297. // CHECK:STDOUT: extend %Base.ref
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: class @Base [from "modifiers.carbon"] {
  301. // CHECK:STDOUT: complete_type_witness = imports.%Modifiers.import_ref.05e
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: !members:
  304. // CHECK:STDOUT: .Self = imports.%Modifiers.import_ref.1f3
  305. // CHECK:STDOUT: .H = imports.%Modifiers.import_ref.2cc
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: impl fn @H.1();
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: fn @H.2() [from "modifiers.carbon"];
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: --- todo_fail_later_base.carbon
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: constants {
  315. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  316. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  317. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  318. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  319. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  320. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  321. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  322. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  323. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  324. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  325. // CHECK:STDOUT: %.02f: <vtable> = vtable (%H, %F) [template]
  326. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [template]
  327. // CHECK:STDOUT: %complete_type.0e2: <witness> = complete_type_witness %struct_type.base [template]
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: imports {
  331. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  332. // CHECK:STDOUT: import Core//prelude
  333. // CHECK:STDOUT: import Core//prelude/...
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT: %Modifiers: <namespace> = namespace file.%Modifiers.import, [template] {
  336. // CHECK:STDOUT: .Base = %Modifiers.Base
  337. // CHECK:STDOUT: import Modifiers//default
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT: %Modifiers.Base: type = import_ref Modifiers//default, Base, loaded [template = constants.%Base]
  340. // CHECK:STDOUT: %Modifiers.import_ref.05e: <witness> = import_ref Modifiers//default, loc6_1, loaded [template = constants.%complete_type.513]
  341. // CHECK:STDOUT: %Modifiers.import_ref.1f3 = import_ref Modifiers//default, inst16 [no loc], unloaded
  342. // CHECK:STDOUT: %Modifiers.import_ref.2cc = import_ref Modifiers//default, loc5_17, unloaded
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: file {
  346. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  347. // CHECK:STDOUT: .Core = imports.%Core
  348. // CHECK:STDOUT: .Modifiers = imports.%Modifiers
  349. // CHECK:STDOUT: .Derived = %Derived.decl
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT: %Core.import = import Core
  352. // CHECK:STDOUT: %Modifiers.import = import Modifiers
  353. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: class @Derived {
  357. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  358. // CHECK:STDOUT: %Modifiers.ref: <namespace> = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers]
  359. // CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%Modifiers.Base [template = constants.%Base]
  360. // CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Base.ref, element0 [template]
  361. // CHECK:STDOUT: %.loc9: <vtable> = vtable (constants.%H, %F.decl) [template = constants.%.02f]
  362. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.0e2]
  363. // CHECK:STDOUT: complete_type_witness = %complete_type
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: !members:
  366. // CHECK:STDOUT: .Self = constants.%Derived
  367. // CHECK:STDOUT: .F = %F.decl
  368. // CHECK:STDOUT: .base = %.loc8
  369. // CHECK:STDOUT: extend %Base.ref
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: class @Base [from "modifiers.carbon"] {
  373. // CHECK:STDOUT: complete_type_witness = imports.%Modifiers.import_ref.05e
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: !members:
  376. // CHECK:STDOUT: .Self = imports.%Modifiers.import_ref.1f3
  377. // CHECK:STDOUT: .H = imports.%Modifiers.import_ref.2cc
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: virtual fn @F();
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: fn @H() [from "modifiers.carbon"];
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: --- init.carbon
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: constants {
  387. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  388. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  389. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  390. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  391. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  392. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  393. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: imports {
  397. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  398. // CHECK:STDOUT: import Core//prelude
  399. // CHECK:STDOUT: import Core//prelude/...
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT: %Modifiers: <namespace> = namespace file.%Modifiers.import, [template] {
  402. // CHECK:STDOUT: .Base = %Modifiers.Base
  403. // CHECK:STDOUT: import Modifiers//default
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT: %Modifiers.Base: type = import_ref Modifiers//default, Base, loaded [template = constants.%Base]
  406. // CHECK:STDOUT: %Modifiers.import_ref.05e: <witness> = import_ref Modifiers//default, loc6_1, loaded [template = constants.%complete_type]
  407. // CHECK:STDOUT: %Modifiers.import_ref.1f3 = import_ref Modifiers//default, inst16 [no loc], unloaded
  408. // CHECK:STDOUT: %Modifiers.import_ref.2cc = import_ref Modifiers//default, loc5_17, unloaded
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: file {
  412. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  413. // CHECK:STDOUT: .Core = imports.%Core
  414. // CHECK:STDOUT: .Modifiers = imports.%Modifiers
  415. // CHECK:STDOUT: .F = %F.decl
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT: %Core.import = import Core
  418. // CHECK:STDOUT: %Modifiers.import = import Modifiers
  419. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: class @Base [from "modifiers.carbon"] {
  423. // CHECK:STDOUT: complete_type_witness = imports.%Modifiers.import_ref.05e
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: !members:
  426. // CHECK:STDOUT: .Self = imports.%Modifiers.import_ref.1f3
  427. // CHECK:STDOUT: .H = imports.%Modifiers.import_ref.2cc
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: fn @F() {
  431. // CHECK:STDOUT: !entry:
  432. // CHECK:STDOUT: name_binding_decl {
  433. // CHECK:STDOUT: %v.patt: %Base = binding_pattern v
  434. // CHECK:STDOUT: %.loc7_3.1: %Base = var_pattern %v.patt
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT: %v.var: ref %Base = var v
  437. // CHECK:STDOUT: %.loc7_28.1: %empty_struct_type = struct_literal ()
  438. // CHECK:STDOUT: %.loc7_28.2: ref %ptr.454 = class_element_access %v.var, element0
  439. // CHECK:STDOUT: %.loc7_28.3: ref %ptr.454 = vtable_ptr
  440. // CHECK:STDOUT: %.loc7_28.4: init %ptr.454 = initialize_from %.loc7_28.3 to %.loc7_28.2
  441. // CHECK:STDOUT: %.loc7_28.5: init %Base = class_init (%.loc7_28.4), %v.var
  442. // CHECK:STDOUT: %.loc7_3.2: init %Base = converted %.loc7_28.1, %.loc7_28.5
  443. // CHECK:STDOUT: assign %v.var, %.loc7_3.2
  444. // CHECK:STDOUT: %.loc7_19: type = splice_block %Base.ref [template = constants.%Base] {
  445. // CHECK:STDOUT: %Modifiers.ref: <namespace> = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers]
  446. // CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%Modifiers.Base [template = constants.%Base]
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT: %v: ref %Base = bind_name v, %v.var
  449. // CHECK:STDOUT: return
  450. // CHECK:STDOUT: }
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: --- impl_abstract.carbon
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: constants {
  455. // CHECK:STDOUT: %A1: type = class_type @A1 [template]
  456. // CHECK:STDOUT: %F.type.13a: type = fn_type @F.1 [template]
  457. // CHECK:STDOUT: %F.df5: %F.type.13a = struct_value () [template]
  458. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  459. // CHECK:STDOUT: %.593: <vtable> = vtable (%F.df5) [template]
  460. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  461. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  462. // CHECK:STDOUT: %A2: type = class_type @A2 [template]
  463. // CHECK:STDOUT: %A2.elem: type = unbound_element_type %A2, %A1 [template]
  464. // CHECK:STDOUT: %F.type.4ae: type = fn_type @F.2 [template]
  465. // CHECK:STDOUT: %F.1d5: %F.type.4ae = struct_value () [template]
  466. // CHECK:STDOUT: %.943: <vtable> = vtable (%F.1d5) [template]
  467. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %A1} [template]
  468. // CHECK:STDOUT: %complete_type.a6f: <witness> = complete_type_witness %struct_type.base [template]
  469. // CHECK:STDOUT: }
  470. // CHECK:STDOUT:
  471. // CHECK:STDOUT: imports {
  472. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  473. // CHECK:STDOUT: import Core//prelude
  474. // CHECK:STDOUT: import Core//prelude/...
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT:
  478. // CHECK:STDOUT: file {
  479. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  480. // CHECK:STDOUT: .Core = imports.%Core
  481. // CHECK:STDOUT: .A1 = %A1.decl
  482. // CHECK:STDOUT: .A2 = %A2.decl
  483. // CHECK:STDOUT: }
  484. // CHECK:STDOUT: %Core.import = import Core
  485. // CHECK:STDOUT: %A1.decl: type = class_decl @A1 [template = constants.%A1] {} {}
  486. // CHECK:STDOUT: %A2.decl: type = class_decl @A2 [template = constants.%A2] {} {}
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT:
  489. // CHECK:STDOUT: class @A1 {
  490. // CHECK:STDOUT: %F.decl: %F.type.13a = fn_decl @F.1 [template = constants.%F.df5] {} {}
  491. // CHECK:STDOUT: %.loc6: <vtable> = vtable (%F.decl) [template = constants.%.593]
  492. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  493. // CHECK:STDOUT: complete_type_witness = %complete_type
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: !members:
  496. // CHECK:STDOUT: .Self = constants.%A1
  497. // CHECK:STDOUT: .F = %F.decl
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: class @A2 {
  501. // CHECK:STDOUT: %A1.ref: type = name_ref A1, file.%A1.decl [template = constants.%A1]
  502. // CHECK:STDOUT: %.loc9: %A2.elem = base_decl %A1.ref, element0 [template]
  503. // CHECK:STDOUT: %F.decl: %F.type.4ae = fn_decl @F.2 [template = constants.%F.1d5] {} {}
  504. // CHECK:STDOUT: %.loc11: <vtable> = vtable (%F.decl) [template = constants.%.943]
  505. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.a6f]
  506. // CHECK:STDOUT: complete_type_witness = %complete_type
  507. // CHECK:STDOUT:
  508. // CHECK:STDOUT: !members:
  509. // CHECK:STDOUT: .Self = constants.%A2
  510. // CHECK:STDOUT: .base = %.loc9
  511. // CHECK:STDOUT: .F = %F.decl
  512. // CHECK:STDOUT: extend %A1.ref
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: virtual fn @F.1();
  516. // CHECK:STDOUT:
  517. // CHECK:STDOUT: impl fn @F.2();
  518. // CHECK:STDOUT:
  519. // CHECK:STDOUT: --- impl_base.carbon
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: constants {
  522. // CHECK:STDOUT: %B1: type = class_type @B1 [template]
  523. // CHECK:STDOUT: %F.type.e4c: type = fn_type @F.1 [template]
  524. // CHECK:STDOUT: %F.8f5: %F.type.e4c = struct_value () [template]
  525. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  526. // CHECK:STDOUT: %.bc5: <vtable> = vtable (%F.8f5) [template]
  527. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  528. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  529. // CHECK:STDOUT: %B2: type = class_type @B2 [template]
  530. // CHECK:STDOUT: %B2.elem: type = unbound_element_type %B2, %B1 [template]
  531. // CHECK:STDOUT: %F.type.b26: type = fn_type @F.2 [template]
  532. // CHECK:STDOUT: %F.d48: %F.type.b26 = struct_value () [template]
  533. // CHECK:STDOUT: %.579: <vtable> = vtable (%F.d48) [template]
  534. // CHECK:STDOUT: %struct_type.base.508: type = struct_type {.base: %B1} [template]
  535. // CHECK:STDOUT: %complete_type.5ac: <witness> = complete_type_witness %struct_type.base.508 [template]
  536. // CHECK:STDOUT: %C: type = class_type @C [template]
  537. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %B2 [template]
  538. // CHECK:STDOUT: %F.type.c29: type = fn_type @F.3 [template]
  539. // CHECK:STDOUT: %F.437: %F.type.c29 = struct_value () [template]
  540. // CHECK:STDOUT: %.5f6: <vtable> = vtable (%F.437) [template]
  541. // CHECK:STDOUT: %struct_type.base.421: type = struct_type {.base: %B2} [template]
  542. // CHECK:STDOUT: %complete_type.066: <witness> = complete_type_witness %struct_type.base.421 [template]
  543. // CHECK:STDOUT: }
  544. // CHECK:STDOUT:
  545. // CHECK:STDOUT: imports {
  546. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  547. // CHECK:STDOUT: import Core//prelude
  548. // CHECK:STDOUT: import Core//prelude/...
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT: }
  551. // CHECK:STDOUT:
  552. // CHECK:STDOUT: file {
  553. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  554. // CHECK:STDOUT: .Core = imports.%Core
  555. // CHECK:STDOUT: .B1 = %B1.decl
  556. // CHECK:STDOUT: .B2 = %B2.decl
  557. // CHECK:STDOUT: .C = %C.decl
  558. // CHECK:STDOUT: }
  559. // CHECK:STDOUT: %Core.import = import Core
  560. // CHECK:STDOUT: %B1.decl: type = class_decl @B1 [template = constants.%B1] {} {}
  561. // CHECK:STDOUT: %B2.decl: type = class_decl @B2 [template = constants.%B2] {} {}
  562. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  563. // CHECK:STDOUT: }
  564. // CHECK:STDOUT:
  565. // CHECK:STDOUT: class @B1 {
  566. // CHECK:STDOUT: %F.decl: %F.type.e4c = fn_decl @F.1 [template = constants.%F.8f5] {} {}
  567. // CHECK:STDOUT: %.loc6: <vtable> = vtable (%F.decl) [template = constants.%.bc5]
  568. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  569. // CHECK:STDOUT: complete_type_witness = %complete_type
  570. // CHECK:STDOUT:
  571. // CHECK:STDOUT: !members:
  572. // CHECK:STDOUT: .Self = constants.%B1
  573. // CHECK:STDOUT: .F = %F.decl
  574. // CHECK:STDOUT: }
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: class @B2 {
  577. // CHECK:STDOUT: %B1.ref: type = name_ref B1, file.%B1.decl [template = constants.%B1]
  578. // CHECK:STDOUT: %.loc9: %B2.elem = base_decl %B1.ref, element0 [template]
  579. // CHECK:STDOUT: %F.decl: %F.type.b26 = fn_decl @F.2 [template = constants.%F.d48] {} {}
  580. // CHECK:STDOUT: %.loc11: <vtable> = vtable (%F.decl) [template = constants.%.579]
  581. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.508 [template = constants.%complete_type.5ac]
  582. // CHECK:STDOUT: complete_type_witness = %complete_type
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: !members:
  585. // CHECK:STDOUT: .Self = constants.%B2
  586. // CHECK:STDOUT: .base = %.loc9
  587. // CHECK:STDOUT: .F = %F.decl
  588. // CHECK:STDOUT: extend %B1.ref
  589. // CHECK:STDOUT: }
  590. // CHECK:STDOUT:
  591. // CHECK:STDOUT: class @C {
  592. // CHECK:STDOUT: %B2.ref: type = name_ref B2, file.%B2.decl [template = constants.%B2]
  593. // CHECK:STDOUT: %.loc14: %C.elem = base_decl %B2.ref, element0 [template]
  594. // CHECK:STDOUT: %F.decl: %F.type.c29 = fn_decl @F.3 [template = constants.%F.437] {} {}
  595. // CHECK:STDOUT: %.loc16: <vtable> = vtable (%F.decl) [template = constants.%.5f6]
  596. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.421 [template = constants.%complete_type.066]
  597. // CHECK:STDOUT: complete_type_witness = %complete_type
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: !members:
  600. // CHECK:STDOUT: .Self = constants.%C
  601. // CHECK:STDOUT: .base = %.loc14
  602. // CHECK:STDOUT: .F = %F.decl
  603. // CHECK:STDOUT: extend %B2.ref
  604. // CHECK:STDOUT: }
  605. // CHECK:STDOUT:
  606. // CHECK:STDOUT: virtual fn @F.1();
  607. // CHECK:STDOUT:
  608. // CHECK:STDOUT: impl fn @F.2();
  609. // CHECK:STDOUT:
  610. // CHECK:STDOUT: impl fn @F.3();
  611. // CHECK:STDOUT:
  612. // CHECK:STDOUT: --- fail_modifiers.carbon
  613. // CHECK:STDOUT:
  614. // CHECK:STDOUT: constants {
  615. // CHECK:STDOUT: %C: type = class_type @C [template]
  616. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  617. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  618. // CHECK:STDOUT: %ptr: type = ptr_type <vtable> [template]
  619. // CHECK:STDOUT: %.f2b: <vtable> = vtable () [template]
  620. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr} [template]
  621. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT:
  624. // CHECK:STDOUT: imports {
  625. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  626. // CHECK:STDOUT: import Core//prelude
  627. // CHECK:STDOUT: import Core//prelude/...
  628. // CHECK:STDOUT: }
  629. // CHECK:STDOUT: }
  630. // CHECK:STDOUT:
  631. // CHECK:STDOUT: file {
  632. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  633. // CHECK:STDOUT: .Core = imports.%Core
  634. // CHECK:STDOUT: .C = %C.decl
  635. // CHECK:STDOUT: }
  636. // CHECK:STDOUT: %Core.import = import Core
  637. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  638. // CHECK:STDOUT: }
  639. // CHECK:STDOUT:
  640. // CHECK:STDOUT: class @C {
  641. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  642. // CHECK:STDOUT: %.loc10: <vtable> = vtable () [template = constants.%.f2b]
  643. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  644. // CHECK:STDOUT: complete_type_witness = %complete_type
  645. // CHECK:STDOUT:
  646. // CHECK:STDOUT: !members:
  647. // CHECK:STDOUT: .Self = constants.%C
  648. // CHECK:STDOUT: .F = %F.decl
  649. // CHECK:STDOUT: }
  650. // CHECK:STDOUT:
  651. // CHECK:STDOUT: impl fn @F();
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: --- init_members.carbon
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: constants {
  656. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  657. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  658. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  659. // CHECK:STDOUT: %Base.elem: type = unbound_element_type %Base, %i32 [template]
  660. // CHECK:STDOUT: %F.type.7c6: type = fn_type @F.1 [template]
  661. // CHECK:STDOUT: %F.d17: %F.type.7c6 = struct_value () [template]
  662. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  663. // CHECK:STDOUT: %.5ee: <vtable> = vtable (%F.d17) [template]
  664. // CHECK:STDOUT: %struct_type.vptr.m1.m2: type = struct_type {.<vptr>: %ptr.454, .m1: %i32, .m2: %i32} [template]
  665. // CHECK:STDOUT: %complete_type.cf7: <witness> = complete_type_witness %struct_type.vptr.m1.m2 [template]
  666. // CHECK:STDOUT: %F.type.b25: type = fn_type @F.2 [template]
  667. // CHECK:STDOUT: %F.c41: %F.type.b25 = struct_value () [template]
  668. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  669. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  670. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  671. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  672. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  673. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  674. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  675. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  676. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [template]
  677. // CHECK:STDOUT: %Convert.specific_fn.b42: <specific function> = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template]
  678. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template]
  679. // CHECK:STDOUT: %struct_type.m2.m1.68c: type = struct_type {.m2: %i32, .m1: %i32} [template]
  680. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [template]
  681. // CHECK:STDOUT: %struct_type.m2.m1.5f2: type = struct_type {.m2: Core.IntLiteral, .m1: Core.IntLiteral} [template]
  682. // CHECK:STDOUT: %Convert.bound.4e6: <bound method> = bound_method %int_5.64b, %Convert.956 [template]
  683. // CHECK:STDOUT: %Convert.specific_fn.ba9: <specific function> = specific_function %Convert.bound.4e6, @Convert.2(%int_32) [template]
  684. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [template]
  685. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template]
  686. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [template]
  687. // CHECK:STDOUT: %Convert.specific_fn.450: <specific function> = specific_function %Convert.bound.ac3, @Convert.2(%int_32) [template]
  688. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [template]
  689. // CHECK:STDOUT: }
  690. // CHECK:STDOUT:
  691. // CHECK:STDOUT: imports {
  692. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  693. // CHECK:STDOUT: .Int = %Core.Int
  694. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  695. // CHECK:STDOUT: import Core//prelude
  696. // CHECK:STDOUT: import Core//prelude/...
  697. // CHECK:STDOUT: }
  698. // CHECK:STDOUT: }
  699. // CHECK:STDOUT:
  700. // CHECK:STDOUT: file {
  701. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  702. // CHECK:STDOUT: .Core = imports.%Core
  703. // CHECK:STDOUT: .Base = %Base.decl
  704. // CHECK:STDOUT: .F = %F.decl
  705. // CHECK:STDOUT: }
  706. // CHECK:STDOUT: %Core.import = import Core
  707. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  708. // CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.2 [template = constants.%F.c41] {} {}
  709. // CHECK:STDOUT: }
  710. // CHECK:STDOUT:
  711. // CHECK:STDOUT: class @Base {
  712. // CHECK:STDOUT: %.loc5_9: %Base.elem = field_decl m1, element1 [template]
  713. // CHECK:STDOUT: name_binding_decl {
  714. // CHECK:STDOUT: %.loc5_3: %Base.elem = var_pattern %.loc5_9
  715. // CHECK:STDOUT: }
  716. // CHECK:STDOUT: %.var.loc5: ref %Base.elem = var <none>
  717. // CHECK:STDOUT: %.loc6_9: %Base.elem = field_decl m2, element2 [template]
  718. // CHECK:STDOUT: name_binding_decl {
  719. // CHECK:STDOUT: %.loc6_3: %Base.elem = var_pattern %.loc6_9
  720. // CHECK:STDOUT: }
  721. // CHECK:STDOUT: %.var.loc6: ref %Base.elem = var <none>
  722. // CHECK:STDOUT: %F.decl: %F.type.7c6 = fn_decl @F.1 [template = constants.%F.d17] {} {}
  723. // CHECK:STDOUT: %.loc9: <vtable> = vtable (%F.decl) [template = constants.%.5ee]
  724. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr.m1.m2 [template = constants.%complete_type.cf7]
  725. // CHECK:STDOUT: complete_type_witness = %complete_type
  726. // CHECK:STDOUT:
  727. // CHECK:STDOUT: !members:
  728. // CHECK:STDOUT: .Self = constants.%Base
  729. // CHECK:STDOUT: .m1 = %.loc5_9
  730. // CHECK:STDOUT: .m2 = %.loc6_9
  731. // CHECK:STDOUT: .F = %F.decl
  732. // CHECK:STDOUT: }
  733. // CHECK:STDOUT:
  734. // CHECK:STDOUT: virtual fn @F.1();
  735. // CHECK:STDOUT:
  736. // CHECK:STDOUT: fn @F.2() {
  737. // CHECK:STDOUT: !entry:
  738. // CHECK:STDOUT: name_binding_decl {
  739. // CHECK:STDOUT: %i.patt: %i32 = binding_pattern i
  740. // CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %i.patt
  741. // CHECK:STDOUT: }
  742. // CHECK:STDOUT: %i.var: ref %i32 = var i
  743. // CHECK:STDOUT: %int_3.loc12: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  744. // CHECK:STDOUT: %impl.elem0.loc12: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  745. // CHECK:STDOUT: %bound_method.loc12: <bound method> = bound_method %int_3.loc12, %impl.elem0.loc12 [template = constants.%Convert.bound.b30]
  746. // CHECK:STDOUT: %specific_fn.loc12: <specific function> = specific_function %bound_method.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42]
  747. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %specific_fn.loc12(%int_3.loc12) [template = constants.%int_3.822]
  748. // CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_3.loc12, %int.convert_checked.loc12 [template = constants.%int_3.822]
  749. // CHECK:STDOUT: assign %i.var, %.loc12_3.2
  750. // CHECK:STDOUT: %.loc12_10: type = splice_block %i32 [template = constants.%i32] {
  751. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  752. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  753. // CHECK:STDOUT: }
  754. // CHECK:STDOUT: %i: ref %i32 = bind_name i, %i.var
  755. // CHECK:STDOUT: name_binding_decl {
  756. // CHECK:STDOUT: %b1.patt: %Base = binding_pattern b1
  757. // CHECK:STDOUT: %.loc14_3.1: %Base = var_pattern %b1.patt
  758. // CHECK:STDOUT: }
  759. // CHECK:STDOUT: %b1.var: ref %Base = var b1
  760. // CHECK:STDOUT: %i.ref.loc14_25: ref %i32 = name_ref i, %i
  761. // CHECK:STDOUT: %i.ref.loc14_34: ref %i32 = name_ref i, %i
  762. // CHECK:STDOUT: %.loc14_35.1: %struct_type.m2.m1.68c = struct_literal (%i.ref.loc14_25, %i.ref.loc14_34)
  763. // CHECK:STDOUT: %.loc14_35.2: ref %ptr.454 = class_element_access %b1.var, element0
  764. // CHECK:STDOUT: %.loc14_35.3: ref %ptr.454 = vtable_ptr
  765. // CHECK:STDOUT: %.loc14_35.4: init %ptr.454 = initialize_from %.loc14_35.3 to %.loc14_35.2
  766. // CHECK:STDOUT: %.loc14_34: %i32 = bind_value %i.ref.loc14_34
  767. // CHECK:STDOUT: %.loc14_35.5: ref %i32 = class_element_access %b1.var, element2
  768. // CHECK:STDOUT: %.loc14_35.6: init %i32 = initialize_from %.loc14_34 to %.loc14_35.5
  769. // CHECK:STDOUT: %.loc14_25: %i32 = bind_value %i.ref.loc14_25
  770. // CHECK:STDOUT: %.loc14_35.7: ref %i32 = class_element_access %b1.var, element1
  771. // CHECK:STDOUT: %.loc14_35.8: init %i32 = initialize_from %.loc14_25 to %.loc14_35.7
  772. // CHECK:STDOUT: %.loc14_35.9: init %Base = class_init (%.loc14_35.4, %.loc14_35.6, %.loc14_35.8), %b1.var
  773. // CHECK:STDOUT: %.loc14_3.2: init %Base = converted %.loc14_35.1, %.loc14_35.9
  774. // CHECK:STDOUT: assign %b1.var, %.loc14_3.2
  775. // CHECK:STDOUT: %Base.ref.loc14: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  776. // CHECK:STDOUT: %b1: ref %Base = bind_name b1, %b1.var
  777. // CHECK:STDOUT: name_binding_decl {
  778. // CHECK:STDOUT: %b2.patt: %Base = binding_pattern b2
  779. // CHECK:STDOUT: %.loc15_3.1: %Base = var_pattern %b2.patt
  780. // CHECK:STDOUT: }
  781. // CHECK:STDOUT: %b2.var: ref %Base = var b2
  782. // CHECK:STDOUT: %int_3.loc15: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  783. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b]
  784. // CHECK:STDOUT: %.loc15_35.1: %struct_type.m2.m1.5f2 = struct_literal (%int_3.loc15, %int_5)
  785. // CHECK:STDOUT: %.loc15_35.2: ref %ptr.454 = class_element_access %b2.var, element0
  786. // CHECK:STDOUT: %.loc15_35.3: ref %ptr.454 = vtable_ptr
  787. // CHECK:STDOUT: %.loc15_35.4: init %ptr.454 = initialize_from %.loc15_35.3 to %.loc15_35.2
  788. // CHECK:STDOUT: %impl.elem0.loc15_35.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  789. // CHECK:STDOUT: %bound_method.loc15_35.1: <bound method> = bound_method %int_5, %impl.elem0.loc15_35.1 [template = constants.%Convert.bound.4e6]
  790. // CHECK:STDOUT: %specific_fn.loc15_35.1: <specific function> = specific_function %bound_method.loc15_35.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9]
  791. // CHECK:STDOUT: %int.convert_checked.loc15_35.1: init %i32 = call %specific_fn.loc15_35.1(%int_5) [template = constants.%int_5.0f6]
  792. // CHECK:STDOUT: %.loc15_35.5: init %i32 = converted %int_5, %int.convert_checked.loc15_35.1 [template = constants.%int_5.0f6]
  793. // CHECK:STDOUT: %.loc15_35.6: ref %i32 = class_element_access %b2.var, element2
  794. // CHECK:STDOUT: %.loc15_35.7: init %i32 = initialize_from %.loc15_35.5 to %.loc15_35.6 [template = constants.%int_5.0f6]
  795. // CHECK:STDOUT: %impl.elem0.loc15_35.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  796. // CHECK:STDOUT: %bound_method.loc15_35.2: <bound method> = bound_method %int_3.loc15, %impl.elem0.loc15_35.2 [template = constants.%Convert.bound.b30]
  797. // CHECK:STDOUT: %specific_fn.loc15_35.2: <specific function> = specific_function %bound_method.loc15_35.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42]
  798. // CHECK:STDOUT: %int.convert_checked.loc15_35.2: init %i32 = call %specific_fn.loc15_35.2(%int_3.loc15) [template = constants.%int_3.822]
  799. // CHECK:STDOUT: %.loc15_35.8: init %i32 = converted %int_3.loc15, %int.convert_checked.loc15_35.2 [template = constants.%int_3.822]
  800. // CHECK:STDOUT: %.loc15_35.9: ref %i32 = class_element_access %b2.var, element1
  801. // CHECK:STDOUT: %.loc15_35.10: init %i32 = initialize_from %.loc15_35.8 to %.loc15_35.9 [template = constants.%int_3.822]
  802. // CHECK:STDOUT: %.loc15_35.11: init %Base = class_init (%.loc15_35.4, %.loc15_35.7, %.loc15_35.10), %b2.var
  803. // CHECK:STDOUT: %.loc15_3.2: init %Base = converted %.loc15_35.1, %.loc15_35.11
  804. // CHECK:STDOUT: assign %b2.var, %.loc15_3.2
  805. // CHECK:STDOUT: %Base.ref.loc15: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  806. // CHECK:STDOUT: %b2: ref %Base = bind_name b2, %b2.var
  807. // CHECK:STDOUT: %b1.ref: ref %Base = name_ref b1, %b1
  808. // CHECK:STDOUT: %m2.ref: %Base.elem = name_ref m2, @Base.%.loc6_9 [template = @Base.%.loc6_9]
  809. // CHECK:STDOUT: %.loc18_5: ref %i32 = class_element_access %b1.ref, element2
  810. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  811. // CHECK:STDOUT: %impl.elem0.loc18: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  812. // CHECK:STDOUT: %bound_method.loc18: <bound method> = bound_method %int_4, %impl.elem0.loc18 [template = constants.%Convert.bound.ac3]
  813. // CHECK:STDOUT: %specific_fn.loc18: <specific function> = specific_function %bound_method.loc18, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.450]
  814. // CHECK:STDOUT: %int.convert_checked.loc18: init %i32 = call %specific_fn.loc18(%int_4) [template = constants.%int_4.940]
  815. // CHECK:STDOUT: %.loc18_9: init %i32 = converted %int_4, %int.convert_checked.loc18 [template = constants.%int_4.940]
  816. // CHECK:STDOUT: assign %.loc18_5, %.loc18_9
  817. // CHECK:STDOUT: return
  818. // CHECK:STDOUT: }
  819. // CHECK:STDOUT:
  820. // CHECK:STDOUT: --- todo_fail_impl_without_base_declaration.carbon
  821. // CHECK:STDOUT:
  822. // CHECK:STDOUT: constants {
  823. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  824. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  825. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  826. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  827. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  828. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  829. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  830. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  831. // CHECK:STDOUT: %.f2b: <vtable> = vtable () [template]
  832. // CHECK:STDOUT: %struct_type.vptr.base: type = struct_type {.<vptr>: %ptr.454, .base: %Base} [template]
  833. // CHECK:STDOUT: %complete_type.336: <witness> = complete_type_witness %struct_type.vptr.base [template]
  834. // CHECK:STDOUT: }
  835. // CHECK:STDOUT:
  836. // CHECK:STDOUT: imports {
  837. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  838. // CHECK:STDOUT: import Core//prelude
  839. // CHECK:STDOUT: import Core//prelude/...
  840. // CHECK:STDOUT: }
  841. // CHECK:STDOUT: }
  842. // CHECK:STDOUT:
  843. // CHECK:STDOUT: file {
  844. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  845. // CHECK:STDOUT: .Core = imports.%Core
  846. // CHECK:STDOUT: .Base = %Base.decl
  847. // CHECK:STDOUT: .Derived = %Derived.decl
  848. // CHECK:STDOUT: }
  849. // CHECK:STDOUT: %Core.import = import Core
  850. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  851. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  852. // CHECK:STDOUT: }
  853. // CHECK:STDOUT:
  854. // CHECK:STDOUT: class @Base {
  855. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  856. // CHECK:STDOUT: complete_type_witness = %complete_type
  857. // CHECK:STDOUT:
  858. // CHECK:STDOUT: !members:
  859. // CHECK:STDOUT: .Self = constants.%Base
  860. // CHECK:STDOUT: }
  861. // CHECK:STDOUT:
  862. // CHECK:STDOUT: class @Derived {
  863. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  864. // CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Base.ref, element1 [template]
  865. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  866. // CHECK:STDOUT: %.loc10: <vtable> = vtable () [template = constants.%.f2b]
  867. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr.base [template = constants.%complete_type.336]
  868. // CHECK:STDOUT: complete_type_witness = %complete_type
  869. // CHECK:STDOUT:
  870. // CHECK:STDOUT: !members:
  871. // CHECK:STDOUT: .Self = constants.%Derived
  872. // CHECK:STDOUT: .base = %.loc8
  873. // CHECK:STDOUT: .F = %F.decl
  874. // CHECK:STDOUT: extend %Base.ref
  875. // CHECK:STDOUT: }
  876. // CHECK:STDOUT:
  877. // CHECK:STDOUT: impl fn @F();
  878. // CHECK:STDOUT:
  879. // CHECK:STDOUT: --- abstract_impl.carbon
  880. // CHECK:STDOUT:
  881. // CHECK:STDOUT: constants {
  882. // CHECK:STDOUT: %AbstractBase: type = class_type @AbstractBase [template]
  883. // CHECK:STDOUT: %F.type.85b: type = fn_type @F.1 [template]
  884. // CHECK:STDOUT: %F.6e9: %F.type.85b = struct_value () [template]
  885. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  886. // CHECK:STDOUT: %.6ec: <vtable> = vtable (%F.6e9) [template]
  887. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  888. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  889. // CHECK:STDOUT: %AbstractIntermediate: type = class_type @AbstractIntermediate [template]
  890. // CHECK:STDOUT: %AbstractIntermediate.elem: type = unbound_element_type %AbstractIntermediate, %AbstractBase [template]
  891. // CHECK:STDOUT: %struct_type.base.efd: type = struct_type {.base: %AbstractBase} [template]
  892. // CHECK:STDOUT: %complete_type.2d3: <witness> = complete_type_witness %struct_type.base.efd [template]
  893. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  894. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %AbstractIntermediate [template]
  895. // CHECK:STDOUT: %F.type.5da: type = fn_type @F.2 [template]
  896. // CHECK:STDOUT: %F.fa3: %F.type.5da = struct_value () [template]
  897. // CHECK:STDOUT: %.88d: <vtable> = vtable (%F.fa3) [template]
  898. // CHECK:STDOUT: %struct_type.base.da5: type = struct_type {.base: %AbstractIntermediate} [template]
  899. // CHECK:STDOUT: %complete_type.f8c: <witness> = complete_type_witness %struct_type.base.da5 [template]
  900. // CHECK:STDOUT: }
  901. // CHECK:STDOUT:
  902. // CHECK:STDOUT: imports {
  903. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  904. // CHECK:STDOUT: import Core//prelude
  905. // CHECK:STDOUT: import Core//prelude/...
  906. // CHECK:STDOUT: }
  907. // CHECK:STDOUT: }
  908. // CHECK:STDOUT:
  909. // CHECK:STDOUT: file {
  910. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  911. // CHECK:STDOUT: .Core = imports.%Core
  912. // CHECK:STDOUT: .AbstractBase = %AbstractBase.decl
  913. // CHECK:STDOUT: .AbstractIntermediate = %AbstractIntermediate.decl
  914. // CHECK:STDOUT: .Derived = %Derived.decl
  915. // CHECK:STDOUT: }
  916. // CHECK:STDOUT: %Core.import = import Core
  917. // CHECK:STDOUT: %AbstractBase.decl: type = class_decl @AbstractBase [template = constants.%AbstractBase] {} {}
  918. // CHECK:STDOUT: %AbstractIntermediate.decl: type = class_decl @AbstractIntermediate [template = constants.%AbstractIntermediate] {} {}
  919. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  920. // CHECK:STDOUT: }
  921. // CHECK:STDOUT:
  922. // CHECK:STDOUT: class @AbstractBase {
  923. // CHECK:STDOUT: %F.decl: %F.type.85b = fn_decl @F.1 [template = constants.%F.6e9] {} {}
  924. // CHECK:STDOUT: %.loc6: <vtable> = vtable (%F.decl) [template = constants.%.6ec]
  925. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  926. // CHECK:STDOUT: complete_type_witness = %complete_type
  927. // CHECK:STDOUT:
  928. // CHECK:STDOUT: !members:
  929. // CHECK:STDOUT: .Self = constants.%AbstractBase
  930. // CHECK:STDOUT: .F = %F.decl
  931. // CHECK:STDOUT: }
  932. // CHECK:STDOUT:
  933. // CHECK:STDOUT: class @AbstractIntermediate {
  934. // CHECK:STDOUT: %AbstractBase.ref: type = name_ref AbstractBase, file.%AbstractBase.decl [template = constants.%AbstractBase]
  935. // CHECK:STDOUT: %.loc9: %AbstractIntermediate.elem = base_decl %AbstractBase.ref, element0 [template]
  936. // CHECK:STDOUT: %.loc10: <vtable> = vtable (constants.%F.6e9) [template = constants.%.6ec]
  937. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.efd [template = constants.%complete_type.2d3]
  938. // CHECK:STDOUT: complete_type_witness = %complete_type
  939. // CHECK:STDOUT:
  940. // CHECK:STDOUT: !members:
  941. // CHECK:STDOUT: .Self = constants.%AbstractIntermediate
  942. // CHECK:STDOUT: .base = %.loc9
  943. // CHECK:STDOUT: extend %AbstractBase.ref
  944. // CHECK:STDOUT: }
  945. // CHECK:STDOUT:
  946. // CHECK:STDOUT: class @Derived {
  947. // CHECK:STDOUT: %AbstractIntermediate.ref: type = name_ref AbstractIntermediate, file.%AbstractIntermediate.decl [template = constants.%AbstractIntermediate]
  948. // CHECK:STDOUT: %.loc13: %Derived.elem = base_decl %AbstractIntermediate.ref, element0 [template]
  949. // CHECK:STDOUT: %F.decl: %F.type.5da = fn_decl @F.2 [template = constants.%F.fa3] {} {}
  950. // CHECK:STDOUT: %.loc15: <vtable> = vtable (%F.decl) [template = constants.%.88d]
  951. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.da5 [template = constants.%complete_type.f8c]
  952. // CHECK:STDOUT: complete_type_witness = %complete_type
  953. // CHECK:STDOUT:
  954. // CHECK:STDOUT: !members:
  955. // CHECK:STDOUT: .Self = constants.%Derived
  956. // CHECK:STDOUT: .base = %.loc13
  957. // CHECK:STDOUT: .F = %F.decl
  958. // CHECK:STDOUT: extend %AbstractIntermediate.ref
  959. // CHECK:STDOUT: }
  960. // CHECK:STDOUT:
  961. // CHECK:STDOUT: abstract fn @F.1();
  962. // CHECK:STDOUT:
  963. // CHECK:STDOUT: impl fn @F.2();
  964. // CHECK:STDOUT:
  965. // CHECK:STDOUT: --- virtual_impl.carbon
  966. // CHECK:STDOUT:
  967. // CHECK:STDOUT: constants {
  968. // CHECK:STDOUT: %VirtualBase: type = class_type @VirtualBase [template]
  969. // CHECK:STDOUT: %F.type.e62: type = fn_type @F.1 [template]
  970. // CHECK:STDOUT: %F.3e7: %F.type.e62 = struct_value () [template]
  971. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  972. // CHECK:STDOUT: %.def: <vtable> = vtable (%F.3e7) [template]
  973. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  974. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  975. // CHECK:STDOUT: %VirtualIntermediate: type = class_type @VirtualIntermediate [template]
  976. // CHECK:STDOUT: %VirtualIntermediate.elem: type = unbound_element_type %VirtualIntermediate, %VirtualBase [template]
  977. // CHECK:STDOUT: %struct_type.base.61e: type = struct_type {.base: %VirtualBase} [template]
  978. // CHECK:STDOUT: %complete_type.f09: <witness> = complete_type_witness %struct_type.base.61e [template]
  979. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  980. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %VirtualIntermediate [template]
  981. // CHECK:STDOUT: %F.type.5da: type = fn_type @F.2 [template]
  982. // CHECK:STDOUT: %F.fa3: %F.type.5da = struct_value () [template]
  983. // CHECK:STDOUT: %.88d: <vtable> = vtable (%F.fa3) [template]
  984. // CHECK:STDOUT: %struct_type.base.43c: type = struct_type {.base: %VirtualIntermediate} [template]
  985. // CHECK:STDOUT: %complete_type.fa6: <witness> = complete_type_witness %struct_type.base.43c [template]
  986. // CHECK:STDOUT: }
  987. // CHECK:STDOUT:
  988. // CHECK:STDOUT: imports {
  989. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  990. // CHECK:STDOUT: import Core//prelude
  991. // CHECK:STDOUT: import Core//prelude/...
  992. // CHECK:STDOUT: }
  993. // CHECK:STDOUT: }
  994. // CHECK:STDOUT:
  995. // CHECK:STDOUT: file {
  996. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  997. // CHECK:STDOUT: .Core = imports.%Core
  998. // CHECK:STDOUT: .VirtualBase = %VirtualBase.decl
  999. // CHECK:STDOUT: .VirtualIntermediate = %VirtualIntermediate.decl
  1000. // CHECK:STDOUT: .Derived = %Derived.decl
  1001. // CHECK:STDOUT: }
  1002. // CHECK:STDOUT: %Core.import = import Core
  1003. // CHECK:STDOUT: %VirtualBase.decl: type = class_decl @VirtualBase [template = constants.%VirtualBase] {} {}
  1004. // CHECK:STDOUT: %VirtualIntermediate.decl: type = class_decl @VirtualIntermediate [template = constants.%VirtualIntermediate] {} {}
  1005. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  1006. // CHECK:STDOUT: }
  1007. // CHECK:STDOUT:
  1008. // CHECK:STDOUT: class @VirtualBase {
  1009. // CHECK:STDOUT: %F.decl: %F.type.e62 = fn_decl @F.1 [template = constants.%F.3e7] {} {}
  1010. // CHECK:STDOUT: %.loc6: <vtable> = vtable (%F.decl) [template = constants.%.def]
  1011. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  1012. // CHECK:STDOUT: complete_type_witness = %complete_type
  1013. // CHECK:STDOUT:
  1014. // CHECK:STDOUT: !members:
  1015. // CHECK:STDOUT: .Self = constants.%VirtualBase
  1016. // CHECK:STDOUT: .F = %F.decl
  1017. // CHECK:STDOUT: }
  1018. // CHECK:STDOUT:
  1019. // CHECK:STDOUT: class @VirtualIntermediate {
  1020. // CHECK:STDOUT: %VirtualBase.ref: type = name_ref VirtualBase, file.%VirtualBase.decl [template = constants.%VirtualBase]
  1021. // CHECK:STDOUT: %.loc9: %VirtualIntermediate.elem = base_decl %VirtualBase.ref, element0 [template]
  1022. // CHECK:STDOUT: %.loc10: <vtable> = vtable (constants.%F.3e7) [template = constants.%.def]
  1023. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.61e [template = constants.%complete_type.f09]
  1024. // CHECK:STDOUT: complete_type_witness = %complete_type
  1025. // CHECK:STDOUT:
  1026. // CHECK:STDOUT: !members:
  1027. // CHECK:STDOUT: .Self = constants.%VirtualIntermediate
  1028. // CHECK:STDOUT: .base = %.loc9
  1029. // CHECK:STDOUT: extend %VirtualBase.ref
  1030. // CHECK:STDOUT: }
  1031. // CHECK:STDOUT:
  1032. // CHECK:STDOUT: class @Derived {
  1033. // CHECK:STDOUT: %VirtualIntermediate.ref: type = name_ref VirtualIntermediate, file.%VirtualIntermediate.decl [template = constants.%VirtualIntermediate]
  1034. // CHECK:STDOUT: %.loc13: %Derived.elem = base_decl %VirtualIntermediate.ref, element0 [template]
  1035. // CHECK:STDOUT: %F.decl: %F.type.5da = fn_decl @F.2 [template = constants.%F.fa3] {} {}
  1036. // CHECK:STDOUT: %.loc15: <vtable> = vtable (%F.decl) [template = constants.%.88d]
  1037. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.43c [template = constants.%complete_type.fa6]
  1038. // CHECK:STDOUT: complete_type_witness = %complete_type
  1039. // CHECK:STDOUT:
  1040. // CHECK:STDOUT: !members:
  1041. // CHECK:STDOUT: .Self = constants.%Derived
  1042. // CHECK:STDOUT: .base = %.loc13
  1043. // CHECK:STDOUT: .F = %F.decl
  1044. // CHECK:STDOUT: extend %VirtualIntermediate.ref
  1045. // CHECK:STDOUT: }
  1046. // CHECK:STDOUT:
  1047. // CHECK:STDOUT: virtual fn @F.1();
  1048. // CHECK:STDOUT:
  1049. // CHECK:STDOUT: impl fn @F.2();
  1050. // CHECK:STDOUT:
  1051. // CHECK:STDOUT: --- fail_impl_mismatch.carbon
  1052. // CHECK:STDOUT:
  1053. // CHECK:STDOUT: constants {
  1054. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  1055. // CHECK:STDOUT: %F.type.7c6: type = fn_type @F.1 [template]
  1056. // CHECK:STDOUT: %F.d17: %F.type.7c6 = struct_value () [template]
  1057. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  1058. // CHECK:STDOUT: %.5ee: <vtable> = vtable (%F.d17) [template]
  1059. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  1060. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  1061. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  1062. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  1063. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  1064. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  1065. // CHECK:STDOUT: %F.type.5da: type = fn_type @F.2 [template]
  1066. // CHECK:STDOUT: %F.fa3: %F.type.5da = struct_value () [template]
  1067. // CHECK:STDOUT: %.88d: <vtable> = vtable (%F.fa3) [template]
  1068. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [template]
  1069. // CHECK:STDOUT: %complete_type.15c: <witness> = complete_type_witness %struct_type.base [template]
  1070. // CHECK:STDOUT: }
  1071. // CHECK:STDOUT:
  1072. // CHECK:STDOUT: imports {
  1073. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1074. // CHECK:STDOUT: .Int = %Core.Int
  1075. // CHECK:STDOUT: import Core//prelude
  1076. // CHECK:STDOUT: import Core//prelude/...
  1077. // CHECK:STDOUT: }
  1078. // CHECK:STDOUT: }
  1079. // CHECK:STDOUT:
  1080. // CHECK:STDOUT: file {
  1081. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1082. // CHECK:STDOUT: .Core = imports.%Core
  1083. // CHECK:STDOUT: .Base = %Base.decl
  1084. // CHECK:STDOUT: .Derived = %Derived.decl
  1085. // CHECK:STDOUT: }
  1086. // CHECK:STDOUT: %Core.import = import Core
  1087. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  1088. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  1089. // CHECK:STDOUT: }
  1090. // CHECK:STDOUT:
  1091. // CHECK:STDOUT: class @Base {
  1092. // CHECK:STDOUT: %F.decl: %F.type.7c6 = fn_decl @F.1 [template = constants.%F.d17] {} {}
  1093. // CHECK:STDOUT: %.loc6: <vtable> = vtable (%F.decl) [template = constants.%.5ee]
  1094. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  1095. // CHECK:STDOUT: complete_type_witness = %complete_type
  1096. // CHECK:STDOUT:
  1097. // CHECK:STDOUT: !members:
  1098. // CHECK:STDOUT: .Self = constants.%Base
  1099. // CHECK:STDOUT: .F = %F.decl
  1100. // CHECK:STDOUT: }
  1101. // CHECK:STDOUT:
  1102. // CHECK:STDOUT: class @Derived {
  1103. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  1104. // CHECK:STDOUT: %.loc9: %Derived.elem = base_decl %Base.ref, element0 [template]
  1105. // CHECK:STDOUT: %F.decl: %F.type.5da = fn_decl @F.2 [template = constants.%F.fa3] {
  1106. // CHECK:STDOUT: %v.patt: %i32 = binding_pattern v
  1107. // CHECK:STDOUT: %v.param_patt: %i32 = value_param_pattern %v.patt, runtime_param0
  1108. // CHECK:STDOUT: } {
  1109. // CHECK:STDOUT: %v.param: %i32 = value_param runtime_param0
  1110. // CHECK:STDOUT: %.loc17: type = splice_block %i32 [template = constants.%i32] {
  1111. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1112. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1113. // CHECK:STDOUT: }
  1114. // CHECK:STDOUT: %v: %i32 = bind_name v, %v.param
  1115. // CHECK:STDOUT: }
  1116. // CHECK:STDOUT: %.loc18: <vtable> = vtable (%F.decl) [template = constants.%.88d]
  1117. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.15c]
  1118. // CHECK:STDOUT: complete_type_witness = %complete_type
  1119. // CHECK:STDOUT:
  1120. // CHECK:STDOUT: !members:
  1121. // CHECK:STDOUT: .Self = constants.%Derived
  1122. // CHECK:STDOUT: .base = %.loc9
  1123. // CHECK:STDOUT: .F = %F.decl
  1124. // CHECK:STDOUT: extend %Base.ref
  1125. // CHECK:STDOUT: }
  1126. // CHECK:STDOUT:
  1127. // CHECK:STDOUT: virtual fn @F.1();
  1128. // CHECK:STDOUT:
  1129. // CHECK:STDOUT: impl fn @F.2(%v.param_patt: %i32);
  1130. // CHECK:STDOUT:
  1131. // CHECK:STDOUT: --- fail_todo_impl_conversion.carbon
  1132. // CHECK:STDOUT:
  1133. // CHECK:STDOUT: constants {
  1134. // CHECK:STDOUT: %T1: type = class_type @T1 [template]
  1135. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  1136. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  1137. // CHECK:STDOUT: %T2: type = class_type @T2 [template]
  1138. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [template]
  1139. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [template]
  1140. // CHECK:STDOUT: %ImplicitAs.type.e40: type = facet_type <@ImplicitAs, @ImplicitAs(%T1)> [template]
  1141. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Convert.decl) [template]
  1142. // CHECK:STDOUT: %Convert.type.c41: type = fn_type @Convert.2 [template]
  1143. // CHECK:STDOUT: %Convert.f35: %Convert.type.c41 = struct_value () [template]
  1144. // CHECK:STDOUT: %T1.val: %T1 = struct_value () [template]
  1145. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  1146. // CHECK:STDOUT: %F.type.7c6: type = fn_type @F.1 [template]
  1147. // CHECK:STDOUT: %F.d17: %F.type.7c6 = struct_value () [template]
  1148. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  1149. // CHECK:STDOUT: %.5ee: <vtable> = vtable (%F.d17) [template]
  1150. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  1151. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  1152. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  1153. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  1154. // CHECK:STDOUT: %F.type.5da: type = fn_type @F.2 [template]
  1155. // CHECK:STDOUT: %F.fa3: %F.type.5da = struct_value () [template]
  1156. // CHECK:STDOUT: %.88d: <vtable> = vtable (%F.fa3) [template]
  1157. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [template]
  1158. // CHECK:STDOUT: %complete_type.15c: <witness> = complete_type_witness %struct_type.base [template]
  1159. // CHECK:STDOUT: }
  1160. // CHECK:STDOUT:
  1161. // CHECK:STDOUT: imports {
  1162. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1163. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1164. // CHECK:STDOUT: import Core//prelude
  1165. // CHECK:STDOUT: import Core//prelude/...
  1166. // CHECK:STDOUT: }
  1167. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [template = constants.%ImplicitAs.generic]
  1168. // CHECK:STDOUT: }
  1169. // CHECK:STDOUT:
  1170. // CHECK:STDOUT: file {
  1171. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1172. // CHECK:STDOUT: .Core = imports.%Core
  1173. // CHECK:STDOUT: .T1 = %T1.decl
  1174. // CHECK:STDOUT: .T2 = %T2.decl
  1175. // CHECK:STDOUT: .Base = %Base.decl
  1176. // CHECK:STDOUT: .Derived = %Derived.decl
  1177. // CHECK:STDOUT: }
  1178. // CHECK:STDOUT: %Core.import = import Core
  1179. // CHECK:STDOUT: %T1.decl: type = class_decl @T1 [template = constants.%T1] {} {}
  1180. // CHECK:STDOUT: %T2.decl: type = class_decl @T2 [template = constants.%T2] {} {}
  1181. // CHECK:STDOUT: impl_decl @impl [template] {} {
  1182. // CHECK:STDOUT: %T2.ref: type = name_ref T2, file.%T2.decl [template = constants.%T2]
  1183. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  1184. // CHECK:STDOUT: %ImplicitAs.ref: %ImplicitAs.type.cc7 = name_ref ImplicitAs, imports.%Core.ImplicitAs [template = constants.%ImplicitAs.generic]
  1185. // CHECK:STDOUT: %T1.ref: type = name_ref T1, file.%T1.decl [template = constants.%T1]
  1186. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%T1)> [template = constants.%ImplicitAs.type.e40]
  1187. // CHECK:STDOUT: }
  1188. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Convert.decl) [template = constants.%impl_witness]
  1189. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  1190. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  1191. // CHECK:STDOUT: }
  1192. // CHECK:STDOUT:
  1193. // CHECK:STDOUT: impl @impl: %T2.ref as %ImplicitAs.type {
  1194. // CHECK:STDOUT: %Convert.decl: %Convert.type.c41 = fn_decl @Convert.2 [template = constants.%Convert.f35] {
  1195. // CHECK:STDOUT: %self.patt: %T2 = binding_pattern self
  1196. // CHECK:STDOUT: %self.param_patt: %T2 = value_param_pattern %self.patt, runtime_param0
  1197. // CHECK:STDOUT: %return.patt: %T1 = return_slot_pattern
  1198. // CHECK:STDOUT: %return.param_patt: %T1 = out_param_pattern %return.patt, runtime_param1
  1199. // CHECK:STDOUT: } {
  1200. // CHECK:STDOUT: %T1.ref: type = name_ref T1, file.%T1.decl [template = constants.%T1]
  1201. // CHECK:STDOUT: %self.param: %T2 = value_param runtime_param0
  1202. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%T2.ref [template = constants.%T2]
  1203. // CHECK:STDOUT: %self: %T2 = bind_name self, %self.param
  1204. // CHECK:STDOUT: %return.param: ref %T1 = out_param runtime_param1
  1205. // CHECK:STDOUT: %return: ref %T1 = return_slot %return.param
  1206. // CHECK:STDOUT: }
  1207. // CHECK:STDOUT:
  1208. // CHECK:STDOUT: !members:
  1209. // CHECK:STDOUT: .Convert = %Convert.decl
  1210. // CHECK:STDOUT: witness = file.%impl_witness
  1211. // CHECK:STDOUT: }
  1212. // CHECK:STDOUT:
  1213. // CHECK:STDOUT: class @T1 {
  1214. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  1215. // CHECK:STDOUT: complete_type_witness = %complete_type
  1216. // CHECK:STDOUT:
  1217. // CHECK:STDOUT: !members:
  1218. // CHECK:STDOUT: .Self = constants.%T1
  1219. // CHECK:STDOUT: }
  1220. // CHECK:STDOUT:
  1221. // CHECK:STDOUT: class @T2 {
  1222. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  1223. // CHECK:STDOUT: complete_type_witness = %complete_type
  1224. // CHECK:STDOUT:
  1225. // CHECK:STDOUT: !members:
  1226. // CHECK:STDOUT: .Self = constants.%T2
  1227. // CHECK:STDOUT: }
  1228. // CHECK:STDOUT:
  1229. // CHECK:STDOUT: class @Base {
  1230. // CHECK:STDOUT: %F.decl: %F.type.7c6 = fn_decl @F.1 [template = constants.%F.d17] {
  1231. // CHECK:STDOUT: %return.patt: %T1 = return_slot_pattern
  1232. // CHECK:STDOUT: %return.param_patt: %T1 = out_param_pattern %return.patt, runtime_param0
  1233. // CHECK:STDOUT: } {
  1234. // CHECK:STDOUT: %T1.ref: type = name_ref T1, file.%T1.decl [template = constants.%T1]
  1235. // CHECK:STDOUT: %return.param: ref %T1 = out_param runtime_param0
  1236. // CHECK:STDOUT: %return: ref %T1 = return_slot %return.param
  1237. // CHECK:STDOUT: }
  1238. // CHECK:STDOUT: %.loc18: <vtable> = vtable (%F.decl) [template = constants.%.5ee]
  1239. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  1240. // CHECK:STDOUT: complete_type_witness = %complete_type
  1241. // CHECK:STDOUT:
  1242. // CHECK:STDOUT: !members:
  1243. // CHECK:STDOUT: .Self = constants.%Base
  1244. // CHECK:STDOUT: .F = %F.decl
  1245. // CHECK:STDOUT: }
  1246. // CHECK:STDOUT:
  1247. // CHECK:STDOUT: class @Derived {
  1248. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  1249. // CHECK:STDOUT: %.loc21: %Derived.elem = base_decl %Base.ref, element0 [template]
  1250. // CHECK:STDOUT: %F.decl: %F.type.5da = fn_decl @F.2 [template = constants.%F.fa3] {
  1251. // CHECK:STDOUT: %return.patt: %T2 = return_slot_pattern
  1252. // CHECK:STDOUT: %return.param_patt: %T2 = out_param_pattern %return.patt, runtime_param0
  1253. // CHECK:STDOUT: } {
  1254. // CHECK:STDOUT: %T2.ref: type = name_ref T2, file.%T2.decl [template = constants.%T2]
  1255. // CHECK:STDOUT: %return.param: ref %T2 = out_param runtime_param0
  1256. // CHECK:STDOUT: %return: ref %T2 = return_slot %return.param
  1257. // CHECK:STDOUT: }
  1258. // CHECK:STDOUT: %.loc30: <vtable> = vtable (%F.decl) [template = constants.%.88d]
  1259. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.15c]
  1260. // CHECK:STDOUT: complete_type_witness = %complete_type
  1261. // CHECK:STDOUT:
  1262. // CHECK:STDOUT: !members:
  1263. // CHECK:STDOUT: .Self = constants.%Derived
  1264. // CHECK:STDOUT: .base = %.loc21
  1265. // CHECK:STDOUT: .F = %F.decl
  1266. // CHECK:STDOUT: extend %Base.ref
  1267. // CHECK:STDOUT: }
  1268. // CHECK:STDOUT:
  1269. // CHECK:STDOUT: fn @Convert.2[%self.param_patt: %T2]() -> %return.param_patt: %T1 {
  1270. // CHECK:STDOUT: !entry:
  1271. // CHECK:STDOUT: %.loc12_13.1: %empty_struct_type = struct_literal ()
  1272. // CHECK:STDOUT: %.loc12_13.2: init %T1 = class_init (), %return [template = constants.%T1.val]
  1273. // CHECK:STDOUT: %.loc12_14: init %T1 = converted %.loc12_13.1, %.loc12_13.2 [template = constants.%T1.val]
  1274. // CHECK:STDOUT: return %.loc12_14 to %return
  1275. // CHECK:STDOUT: }
  1276. // CHECK:STDOUT:
  1277. // CHECK:STDOUT: virtual fn @F.1() -> %T1;
  1278. // CHECK:STDOUT:
  1279. // CHECK:STDOUT: impl fn @F.2() -> %T2;
  1280. // CHECK:STDOUT:
  1281. // CHECK:STDOUT: --- fail_todo_impl_generic_base.carbon
  1282. // CHECK:STDOUT:
  1283. // CHECK:STDOUT: constants {
  1284. // CHECK:STDOUT: %T1: type = class_type @T1 [template]
  1285. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  1286. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  1287. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  1288. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  1289. // CHECK:STDOUT: %Base.type: type = generic_class_type @Base [template]
  1290. // CHECK:STDOUT: %Base.generic: %Base.type = struct_value () [template]
  1291. // CHECK:STDOUT: %Base.370: type = class_type @Base, @Base(%T) [symbolic]
  1292. // CHECK:STDOUT: %F.type.f17: type = fn_type @F.1, @Base(%T) [symbolic]
  1293. // CHECK:STDOUT: %F.e26: %F.type.f17 = struct_value () [symbolic]
  1294. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  1295. // CHECK:STDOUT: %.f89: <vtable> = vtable (%F.e26) [symbolic]
  1296. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  1297. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  1298. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  1299. // CHECK:STDOUT: %Base.ea5: type = class_type @Base, @Base(%T1) [template]
  1300. // CHECK:STDOUT: %F.type.d82: type = fn_type @F.1, @Base(%T1) [template]
  1301. // CHECK:STDOUT: %F.d25: %F.type.d82 = struct_value () [template]
  1302. // CHECK:STDOUT: %.611: <vtable> = vtable (%F.d25) [template]
  1303. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base.ea5 [template]
  1304. // CHECK:STDOUT: %F.type.5da: type = fn_type @F.2 [template]
  1305. // CHECK:STDOUT: %F.fa3: %F.type.5da = struct_value () [template]
  1306. // CHECK:STDOUT: %.88d: <vtable> = vtable (%F.fa3) [template]
  1307. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base.ea5} [template]
  1308. // CHECK:STDOUT: %complete_type.65a: <witness> = complete_type_witness %struct_type.base [template]
  1309. // CHECK:STDOUT: }
  1310. // CHECK:STDOUT:
  1311. // CHECK:STDOUT: imports {
  1312. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1313. // CHECK:STDOUT: import Core//prelude
  1314. // CHECK:STDOUT: import Core//prelude/...
  1315. // CHECK:STDOUT: }
  1316. // CHECK:STDOUT: }
  1317. // CHECK:STDOUT:
  1318. // CHECK:STDOUT: file {
  1319. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1320. // CHECK:STDOUT: .Core = imports.%Core
  1321. // CHECK:STDOUT: .T1 = %T1.decl
  1322. // CHECK:STDOUT: .Base = %Base.decl
  1323. // CHECK:STDOUT: .Derived = %Derived.decl
  1324. // CHECK:STDOUT: }
  1325. // CHECK:STDOUT: %Core.import = import Core
  1326. // CHECK:STDOUT: %T1.decl: type = class_decl @T1 [template = constants.%T1] {} {}
  1327. // CHECK:STDOUT: %Base.decl: %Base.type = class_decl @Base [template = constants.%Base.generic] {
  1328. // CHECK:STDOUT: %T.patt.loc7_17.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_17.2 (constants.%T.patt)]
  1329. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc7_17.1, runtime_param<none> [symbolic = %T.patt.loc7_17.2 (constants.%T.patt)]
  1330. // CHECK:STDOUT: } {
  1331. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  1332. // CHECK:STDOUT: %T.loc7_17.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc7_17.2 (constants.%T)]
  1333. // CHECK:STDOUT: }
  1334. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  1335. // CHECK:STDOUT: }
  1336. // CHECK:STDOUT:
  1337. // CHECK:STDOUT: class @T1 {
  1338. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  1339. // CHECK:STDOUT: complete_type_witness = %complete_type
  1340. // CHECK:STDOUT:
  1341. // CHECK:STDOUT: !members:
  1342. // CHECK:STDOUT: .Self = constants.%T1
  1343. // CHECK:STDOUT: }
  1344. // CHECK:STDOUT:
  1345. // CHECK:STDOUT: generic class @Base(%T.loc7_17.1: type) {
  1346. // CHECK:STDOUT: %T.loc7_17.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc7_17.2 (constants.%T)]
  1347. // CHECK:STDOUT: %T.patt.loc7_17.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_17.2 (constants.%T.patt)]
  1348. // CHECK:STDOUT:
  1349. // CHECK:STDOUT: !definition:
  1350. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @Base(%T.loc7_17.2) [symbolic = %F.type (constants.%F.type.f17)]
  1351. // CHECK:STDOUT: %F: @Base.%F.type (%F.type.f17) = struct_value () [symbolic = %F (constants.%F.e26)]
  1352. // CHECK:STDOUT: %.loc9_1.2: <vtable> = vtable (%F) [symbolic = %.loc9_1.2 (constants.%.f89)]
  1353. // CHECK:STDOUT:
  1354. // CHECK:STDOUT: class {
  1355. // CHECK:STDOUT: %F.decl: @Base.%F.type (%F.type.f17) = fn_decl @F.1 [symbolic = @Base.%F (constants.%F.e26)] {
  1356. // CHECK:STDOUT: %t.patt: @F.1.%T (%T) = binding_pattern t
  1357. // CHECK:STDOUT: %t.param_patt: @F.1.%T (%T) = value_param_pattern %t.patt, runtime_param0
  1358. // CHECK:STDOUT: } {
  1359. // CHECK:STDOUT: %t.param: @F.1.%T (%T) = value_param runtime_param0
  1360. // CHECK:STDOUT: %T.ref: type = name_ref T, @Base.%T.loc7_17.1 [symbolic = %T (constants.%T)]
  1361. // CHECK:STDOUT: %t: @F.1.%T (%T) = bind_name t, %t.param
  1362. // CHECK:STDOUT: }
  1363. // CHECK:STDOUT: %.loc9_1.1: <vtable> = vtable (%F.decl) [symbolic = %.loc9_1.2 (constants.%.f89)]
  1364. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  1365. // CHECK:STDOUT: complete_type_witness = %complete_type
  1366. // CHECK:STDOUT:
  1367. // CHECK:STDOUT: !members:
  1368. // CHECK:STDOUT: .Self = constants.%Base.370
  1369. // CHECK:STDOUT: .F = %F.decl
  1370. // CHECK:STDOUT: }
  1371. // CHECK:STDOUT: }
  1372. // CHECK:STDOUT:
  1373. // CHECK:STDOUT: class @Derived {
  1374. // CHECK:STDOUT: %Base.ref: %Base.type = name_ref Base, file.%Base.decl [template = constants.%Base.generic]
  1375. // CHECK:STDOUT: %T1.ref: type = name_ref T1, file.%T1.decl [template = constants.%T1]
  1376. // CHECK:STDOUT: %Base: type = class_type @Base, @Base(constants.%T1) [template = constants.%Base.ea5]
  1377. // CHECK:STDOUT: %.loc12: %Derived.elem = base_decl %Base, element0 [template]
  1378. // CHECK:STDOUT: %F.decl: %F.type.5da = fn_decl @F.2 [template = constants.%F.fa3] {
  1379. // CHECK:STDOUT: %t.patt: %T1 = binding_pattern t
  1380. // CHECK:STDOUT: %t.param_patt: %T1 = value_param_pattern %t.patt, runtime_param0
  1381. // CHECK:STDOUT: } {
  1382. // CHECK:STDOUT: %t.param: %T1 = value_param runtime_param0
  1383. // CHECK:STDOUT: %T1.ref: type = name_ref T1, file.%T1.decl [template = constants.%T1]
  1384. // CHECK:STDOUT: %t: %T1 = bind_name t, %t.param
  1385. // CHECK:STDOUT: }
  1386. // CHECK:STDOUT: %.loc21: <vtable> = vtable (%F.decl) [template = constants.%.88d]
  1387. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.65a]
  1388. // CHECK:STDOUT: complete_type_witness = %complete_type
  1389. // CHECK:STDOUT:
  1390. // CHECK:STDOUT: !members:
  1391. // CHECK:STDOUT: .Self = constants.%Derived
  1392. // CHECK:STDOUT: .base = %.loc12
  1393. // CHECK:STDOUT: .F = %F.decl
  1394. // CHECK:STDOUT: extend %Base
  1395. // CHECK:STDOUT: }
  1396. // CHECK:STDOUT:
  1397. // CHECK:STDOUT: generic virtual fn @F.1(@Base.%T.loc7_17.1: type) {
  1398. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  1399. // CHECK:STDOUT:
  1400. // CHECK:STDOUT: virtual fn(%t.param_patt: @F.1.%T (%T));
  1401. // CHECK:STDOUT: }
  1402. // CHECK:STDOUT:
  1403. // CHECK:STDOUT: impl fn @F.2(%t.param_patt: %T1);
  1404. // CHECK:STDOUT:
  1405. // CHECK:STDOUT: specific @Base(constants.%T) {
  1406. // CHECK:STDOUT: %T.loc7_17.2 => constants.%T
  1407. // CHECK:STDOUT: %T.patt.loc7_17.2 => constants.%T
  1408. // CHECK:STDOUT: }
  1409. // CHECK:STDOUT:
  1410. // CHECK:STDOUT: specific @F.1(constants.%T) {
  1411. // CHECK:STDOUT: %T => constants.%T
  1412. // CHECK:STDOUT: }
  1413. // CHECK:STDOUT:
  1414. // CHECK:STDOUT: specific @Base(%T.loc7_17.2) {}
  1415. // CHECK:STDOUT:
  1416. // CHECK:STDOUT: specific @Base(constants.%T1) {
  1417. // CHECK:STDOUT: %T.loc7_17.2 => constants.%T1
  1418. // CHECK:STDOUT: %T.patt.loc7_17.2 => constants.%T1
  1419. // CHECK:STDOUT:
  1420. // CHECK:STDOUT: !definition:
  1421. // CHECK:STDOUT: %F.type => constants.%F.type.d82
  1422. // CHECK:STDOUT: %F => constants.%F.d25
  1423. // CHECK:STDOUT: %.loc9_1.2 => constants.%.611
  1424. // CHECK:STDOUT: }
  1425. // CHECK:STDOUT: