virtual_modifiers.carbon 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  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. // --- todo_fail_later_base.carbon
  20. package FailLaterBase;
  21. import Modifiers;
  22. base class Derived {
  23. virtual fn F();
  24. extend base: Modifiers.Base;
  25. }
  26. // --- init.carbon
  27. package Init;
  28. import Modifiers;
  29. fn F() {
  30. var v: Modifiers.Base = {};
  31. }
  32. // --- impl_abstract.carbon
  33. package ImplAbstract;
  34. abstract class A1 {
  35. virtual fn F();
  36. }
  37. abstract class A2 {
  38. extend base: A1;
  39. impl fn F();
  40. }
  41. // --- impl_base.carbon
  42. package ImplBase;
  43. base class B1 {
  44. virtual fn F();
  45. }
  46. base class B2 {
  47. extend base: B1;
  48. impl fn F();
  49. }
  50. class C {
  51. extend base: B2;
  52. impl fn F();
  53. }
  54. // --- fail_modifiers.carbon
  55. package FailModifiers;
  56. class C {
  57. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:3: error: impl without base class [ImplWithoutBase]
  58. // CHECK:STDERR: impl fn F();
  59. // CHECK:STDERR: ^~~~~~~~~~~~
  60. impl fn F();
  61. }
  62. // --- init_members.carbon
  63. package InitMembers;
  64. base class Base {
  65. var m1: i32;
  66. var m2: i32;
  67. virtual fn F();
  68. }
  69. fn F() {
  70. var i: i32 = 3;
  71. // TODO: These should initialize element1 (.m), not element0 (the vptr)
  72. var b1: Base = {.m2 = i, .m1 = i};
  73. var b2: Base = {.m2 = 3, .m1 = 5};
  74. // This one is good, though.
  75. b1.m2 = 4;
  76. }
  77. // --- todo_fail_impl_without_base_declaration.carbon
  78. package ImplWithoutBaseDeclaration;
  79. base class Base {
  80. }
  81. class Derived {
  82. extend base: Base;
  83. impl fn F();
  84. }
  85. // CHECK:STDOUT: --- modifiers.carbon
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: constants {
  88. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  89. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  90. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  91. // CHECK:STDOUT: %ptr: type = ptr_type <vtable> [template]
  92. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr} [template]
  93. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  94. // CHECK:STDOUT: %Abstract: type = class_type @Abstract [template]
  95. // CHECK:STDOUT: %J.type: type = fn_type @J [template]
  96. // CHECK:STDOUT: %J: %J.type = struct_value () [template]
  97. // CHECK:STDOUT: %K.type: type = fn_type @K [template]
  98. // CHECK:STDOUT: %K: %K.type = struct_value () [template]
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: imports {
  102. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  103. // CHECK:STDOUT: import Core//prelude
  104. // CHECK:STDOUT: import Core//prelude/...
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: file {
  109. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  110. // CHECK:STDOUT: .Core = imports.%Core
  111. // CHECK:STDOUT: .Base = %Base.decl
  112. // CHECK:STDOUT: .Abstract = %Abstract.decl
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %Core.import = import Core
  115. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  116. // CHECK:STDOUT: %Abstract.decl: type = class_decl @Abstract [template = constants.%Abstract] {} {}
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: class @Base {
  120. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {} {}
  121. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  122. // CHECK:STDOUT: complete_type_witness = %complete_type
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: !members:
  125. // CHECK:STDOUT: .Self = constants.%Base
  126. // CHECK:STDOUT: .H = %H.decl
  127. // CHECK:STDOUT: }
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: class @Abstract {
  130. // CHECK:STDOUT: %J.decl: %J.type = fn_decl @J [template = constants.%J] {} {}
  131. // CHECK:STDOUT: %K.decl: %K.type = fn_decl @K [template = constants.%K] {} {}
  132. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  133. // CHECK:STDOUT: complete_type_witness = %complete_type
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: !members:
  136. // CHECK:STDOUT: .Self = constants.%Abstract
  137. // CHECK:STDOUT: .J = %J.decl
  138. // CHECK:STDOUT: .K = %K.decl
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: virtual fn @H();
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: abstract fn @J();
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: virtual fn @K();
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: --- todo_fail_later_base.carbon
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: constants {
  150. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  151. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  152. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  153. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  154. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  155. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  156. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  157. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  158. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [template]
  159. // CHECK:STDOUT: %complete_type.0e2: <witness> = complete_type_witness %struct_type.base [template]
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: imports {
  163. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  164. // CHECK:STDOUT: import Core//prelude
  165. // CHECK:STDOUT: import Core//prelude/...
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT: %Modifiers: <namespace> = namespace file.%Modifiers.import, [template] {
  168. // CHECK:STDOUT: .Base = %import_ref.917
  169. // CHECK:STDOUT: import Modifiers//default
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: %import_ref.917: type = import_ref Modifiers//default, Base, loaded [template = constants.%Base]
  172. // CHECK:STDOUT: %import_ref.05e: <witness> = import_ref Modifiers//default, loc6_1, loaded [template = constants.%complete_type.513]
  173. // CHECK:STDOUT: %import_ref.1f3 = import_ref Modifiers//default, inst16 [no loc], unloaded
  174. // CHECK:STDOUT: %import_ref.2cc = import_ref Modifiers//default, loc5_17, unloaded
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: file {
  178. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  179. // CHECK:STDOUT: .Core = imports.%Core
  180. // CHECK:STDOUT: .Modifiers = imports.%Modifiers
  181. // CHECK:STDOUT: .Derived = %Derived.decl
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT: %Core.import = import Core
  184. // CHECK:STDOUT: %Modifiers.import = import Modifiers
  185. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: class @Derived {
  189. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  190. // CHECK:STDOUT: %Modifiers.ref: <namespace> = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers]
  191. // CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%import_ref.917 [template = constants.%Base]
  192. // CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Base.ref, element0 [template]
  193. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.0e2]
  194. // CHECK:STDOUT: complete_type_witness = %complete_type
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: !members:
  197. // CHECK:STDOUT: .Self = constants.%Derived
  198. // CHECK:STDOUT: .F = %F.decl
  199. // CHECK:STDOUT: .base = %.loc8
  200. // CHECK:STDOUT: extend %Base.ref
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: class @Base [from "modifiers.carbon"] {
  204. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.05e
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: !members:
  207. // CHECK:STDOUT: .Self = imports.%import_ref.1f3
  208. // CHECK:STDOUT: .H = imports.%import_ref.2cc
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: virtual fn @F();
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: --- init.carbon
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: constants {
  216. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  217. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  218. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  219. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  220. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  221. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  222. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: imports {
  226. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  227. // CHECK:STDOUT: import Core//prelude
  228. // CHECK:STDOUT: import Core//prelude/...
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %Modifiers: <namespace> = namespace file.%Modifiers.import, [template] {
  231. // CHECK:STDOUT: .Base = %import_ref.917
  232. // CHECK:STDOUT: import Modifiers//default
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT: %import_ref.05e: <witness> = import_ref Modifiers//default, loc6_1, loaded [template = constants.%complete_type]
  235. // CHECK:STDOUT: %import_ref.1f3 = import_ref Modifiers//default, inst16 [no loc], unloaded
  236. // CHECK:STDOUT: %import_ref.2cc = import_ref Modifiers//default, loc5_17, unloaded
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: file {
  240. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  241. // CHECK:STDOUT: .Core = imports.%Core
  242. // CHECK:STDOUT: .Modifiers = imports.%Modifiers
  243. // CHECK:STDOUT: .F = %F.decl
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT: %Core.import = import Core
  246. // CHECK:STDOUT: %Modifiers.import = import Modifiers
  247. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: class @Base [from "modifiers.carbon"] {
  251. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.05e
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: !members:
  254. // CHECK:STDOUT: .Self = imports.%import_ref.1f3
  255. // CHECK:STDOUT: .H = imports.%import_ref.2cc
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: fn @F() {
  259. // CHECK:STDOUT: !entry:
  260. // CHECK:STDOUT: %v.var: ref %Base = var v
  261. // CHECK:STDOUT: %v: ref %Base = bind_name v, %v.var
  262. // CHECK:STDOUT: %.loc7_28.1: %empty_struct_type = struct_literal ()
  263. // CHECK:STDOUT: %.loc7_28.2: ref %ptr.454 = class_element_access %v.var, element0
  264. // CHECK:STDOUT: %.loc7_28.3: ref %ptr.454 = vtable_ptr
  265. // CHECK:STDOUT: %.loc7_28.4: init %ptr.454 = initialize_from %.loc7_28.3 to %.loc7_28.2
  266. // CHECK:STDOUT: %.loc7_28.5: init %Base = class_init (%.loc7_28.4), %v.var
  267. // CHECK:STDOUT: %.loc7_29: init %Base = converted %.loc7_28.1, %.loc7_28.5
  268. // CHECK:STDOUT: assign %v.var, %.loc7_29
  269. // CHECK:STDOUT: return
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: --- impl_abstract.carbon
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: constants {
  275. // CHECK:STDOUT: %A1: type = class_type @A1 [template]
  276. // CHECK:STDOUT: %F.type.13a: type = fn_type @F.1 [template]
  277. // CHECK:STDOUT: %F.df5: %F.type.13a = struct_value () [template]
  278. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  279. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  280. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  281. // CHECK:STDOUT: %A2: type = class_type @A2 [template]
  282. // CHECK:STDOUT: %A2.elem: type = unbound_element_type %A2, %A1 [template]
  283. // CHECK:STDOUT: %F.type.4ae: type = fn_type @F.2 [template]
  284. // CHECK:STDOUT: %F.1d5: %F.type.4ae = struct_value () [template]
  285. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %A1} [template]
  286. // CHECK:STDOUT: %complete_type.a6f: <witness> = complete_type_witness %struct_type.base [template]
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: imports {
  290. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  291. // CHECK:STDOUT: import Core//prelude
  292. // CHECK:STDOUT: import Core//prelude/...
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: file {
  297. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  298. // CHECK:STDOUT: .Core = imports.%Core
  299. // CHECK:STDOUT: .A1 = %A1.decl
  300. // CHECK:STDOUT: .A2 = %A2.decl
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT: %Core.import = import Core
  303. // CHECK:STDOUT: %A1.decl: type = class_decl @A1 [template = constants.%A1] {} {}
  304. // CHECK:STDOUT: %A2.decl: type = class_decl @A2 [template = constants.%A2] {} {}
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: class @A1 {
  308. // CHECK:STDOUT: %F.decl: %F.type.13a = fn_decl @F.1 [template = constants.%F.df5] {} {}
  309. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  310. // CHECK:STDOUT: complete_type_witness = %complete_type
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: !members:
  313. // CHECK:STDOUT: .Self = constants.%A1
  314. // CHECK:STDOUT: .F = %F.decl
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: class @A2 {
  318. // CHECK:STDOUT: %A1.ref: type = name_ref A1, file.%A1.decl [template = constants.%A1]
  319. // CHECK:STDOUT: %.loc9: %A2.elem = base_decl %A1.ref, element0 [template]
  320. // CHECK:STDOUT: %F.decl: %F.type.4ae = fn_decl @F.2 [template = constants.%F.1d5] {} {}
  321. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.a6f]
  322. // CHECK:STDOUT: complete_type_witness = %complete_type
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: !members:
  325. // CHECK:STDOUT: .Self = constants.%A2
  326. // CHECK:STDOUT: .base = %.loc9
  327. // CHECK:STDOUT: .F = %F.decl
  328. // CHECK:STDOUT: extend %A1.ref
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: virtual fn @F.1();
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: impl fn @F.2();
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: --- impl_base.carbon
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: constants {
  338. // CHECK:STDOUT: %B1: type = class_type @B1 [template]
  339. // CHECK:STDOUT: %F.type.e4c: type = fn_type @F.1 [template]
  340. // CHECK:STDOUT: %F.8f5: %F.type.e4c = struct_value () [template]
  341. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  342. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
  343. // CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
  344. // CHECK:STDOUT: %B2: type = class_type @B2 [template]
  345. // CHECK:STDOUT: %B2.elem: type = unbound_element_type %B2, %B1 [template]
  346. // CHECK:STDOUT: %F.type.b26: type = fn_type @F.2 [template]
  347. // CHECK:STDOUT: %F.d48: %F.type.b26 = struct_value () [template]
  348. // CHECK:STDOUT: %struct_type.base.508: type = struct_type {.base: %B1} [template]
  349. // CHECK:STDOUT: %complete_type.5ac: <witness> = complete_type_witness %struct_type.base.508 [template]
  350. // CHECK:STDOUT: %C: type = class_type @C [template]
  351. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %B2 [template]
  352. // CHECK:STDOUT: %F.type.c29: type = fn_type @F.3 [template]
  353. // CHECK:STDOUT: %F.437: %F.type.c29 = struct_value () [template]
  354. // CHECK:STDOUT: %struct_type.base.421: type = struct_type {.base: %B2} [template]
  355. // CHECK:STDOUT: %complete_type.066: <witness> = complete_type_witness %struct_type.base.421 [template]
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: imports {
  359. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  360. // CHECK:STDOUT: import Core//prelude
  361. // CHECK:STDOUT: import Core//prelude/...
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: file {
  366. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  367. // CHECK:STDOUT: .Core = imports.%Core
  368. // CHECK:STDOUT: .B1 = %B1.decl
  369. // CHECK:STDOUT: .B2 = %B2.decl
  370. // CHECK:STDOUT: .C = %C.decl
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT: %Core.import = import Core
  373. // CHECK:STDOUT: %B1.decl: type = class_decl @B1 [template = constants.%B1] {} {}
  374. // CHECK:STDOUT: %B2.decl: type = class_decl @B2 [template = constants.%B2] {} {}
  375. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: class @B1 {
  379. // CHECK:STDOUT: %F.decl: %F.type.e4c = fn_decl @F.1 [template = constants.%F.8f5] {} {}
  380. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
  381. // CHECK:STDOUT: complete_type_witness = %complete_type
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: !members:
  384. // CHECK:STDOUT: .Self = constants.%B1
  385. // CHECK:STDOUT: .F = %F.decl
  386. // CHECK:STDOUT: }
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: class @B2 {
  389. // CHECK:STDOUT: %B1.ref: type = name_ref B1, file.%B1.decl [template = constants.%B1]
  390. // CHECK:STDOUT: %.loc9: %B2.elem = base_decl %B1.ref, element0 [template]
  391. // CHECK:STDOUT: %F.decl: %F.type.b26 = fn_decl @F.2 [template = constants.%F.d48] {} {}
  392. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.508 [template = constants.%complete_type.5ac]
  393. // CHECK:STDOUT: complete_type_witness = %complete_type
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: !members:
  396. // CHECK:STDOUT: .Self = constants.%B2
  397. // CHECK:STDOUT: .base = %.loc9
  398. // CHECK:STDOUT: .F = %F.decl
  399. // CHECK:STDOUT: extend %B1.ref
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: class @C {
  403. // CHECK:STDOUT: %B2.ref: type = name_ref B2, file.%B2.decl [template = constants.%B2]
  404. // CHECK:STDOUT: %.loc14: %C.elem = base_decl %B2.ref, element0 [template]
  405. // CHECK:STDOUT: %F.decl: %F.type.c29 = fn_decl @F.3 [template = constants.%F.437] {} {}
  406. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.421 [template = constants.%complete_type.066]
  407. // CHECK:STDOUT: complete_type_witness = %complete_type
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: !members:
  410. // CHECK:STDOUT: .Self = constants.%C
  411. // CHECK:STDOUT: .base = %.loc14
  412. // CHECK:STDOUT: .F = %F.decl
  413. // CHECK:STDOUT: extend %B2.ref
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: virtual fn @F.1();
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: impl fn @F.2();
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: impl fn @F.3();
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: --- fail_modifiers.carbon
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: constants {
  425. // CHECK:STDOUT: %C: type = class_type @C [template]
  426. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  427. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  428. // CHECK:STDOUT: %ptr: type = ptr_type <vtable> [template]
  429. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr} [template]
  430. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: imports {
  434. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  435. // CHECK:STDOUT: import Core//prelude
  436. // CHECK:STDOUT: import Core//prelude/...
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: file {
  441. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  442. // CHECK:STDOUT: .Core = imports.%Core
  443. // CHECK:STDOUT: .C = %C.decl
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT: %Core.import = import Core
  446. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: class @C {
  450. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  451. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  452. // CHECK:STDOUT: complete_type_witness = %complete_type
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: !members:
  455. // CHECK:STDOUT: .Self = constants.%C
  456. // CHECK:STDOUT: .F = %F.decl
  457. // CHECK:STDOUT: }
  458. // CHECK:STDOUT:
  459. // CHECK:STDOUT: impl fn @F();
  460. // CHECK:STDOUT:
  461. // CHECK:STDOUT: --- init_members.carbon
  462. // CHECK:STDOUT:
  463. // CHECK:STDOUT: constants {
  464. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  465. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  466. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  467. // CHECK:STDOUT: %Base.elem: type = unbound_element_type %Base, %i32 [template]
  468. // CHECK:STDOUT: %F.type.7c6: type = fn_type @F.1 [template]
  469. // CHECK:STDOUT: %F.d17: %F.type.7c6 = struct_value () [template]
  470. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  471. // CHECK:STDOUT: %struct_type.vptr.m1.m2: type = struct_type {.<vptr>: %ptr.454, .m1: %i32, .m2: %i32} [template]
  472. // CHECK:STDOUT: %complete_type.cf7: <witness> = complete_type_witness %struct_type.vptr.m1.m2 [template]
  473. // CHECK:STDOUT: %F.type.b25: type = fn_type @F.2 [template]
  474. // CHECK:STDOUT: %F.c41: %F.type.b25 = struct_value () [template]
  475. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  476. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  477. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template]
  478. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  479. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  480. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [template]
  481. // CHECK:STDOUT: %Convert.specific_fn.b42: <specific function> = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template]
  482. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template]
  483. // CHECK:STDOUT: %struct_type.m2.m1.68c: type = struct_type {.m2: %i32, .m1: %i32} [template]
  484. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [template]
  485. // CHECK:STDOUT: %struct_type.m2.m1.5f2: type = struct_type {.m2: Core.IntLiteral, .m1: Core.IntLiteral} [template]
  486. // CHECK:STDOUT: %Convert.bound.4e6: <bound method> = bound_method %int_5.64b, %Convert.956 [template]
  487. // CHECK:STDOUT: %Convert.specific_fn.ba9: <specific function> = specific_function %Convert.bound.4e6, @Convert.2(%int_32) [template]
  488. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [template]
  489. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template]
  490. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [template]
  491. // CHECK:STDOUT: %Convert.specific_fn.450: <specific function> = specific_function %Convert.bound.ac3, @Convert.2(%int_32) [template]
  492. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [template]
  493. // CHECK:STDOUT: }
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: imports {
  496. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  497. // CHECK:STDOUT: .Int = %import_ref.485
  498. // CHECK:STDOUT: .ImplicitAs = %import_ref.d44
  499. // CHECK:STDOUT: import Core//prelude
  500. // CHECK:STDOUT: import Core//prelude/...
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT:
  504. // CHECK:STDOUT: file {
  505. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  506. // CHECK:STDOUT: .Core = imports.%Core
  507. // CHECK:STDOUT: .Base = %Base.decl
  508. // CHECK:STDOUT: .F = %F.decl
  509. // CHECK:STDOUT: }
  510. // CHECK:STDOUT: %Core.import = import Core
  511. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  512. // CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.2 [template = constants.%F.c41] {} {}
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: class @Base {
  516. // CHECK:STDOUT: %.loc5: %Base.elem = field_decl m1, element1 [template]
  517. // CHECK:STDOUT: %.loc6: %Base.elem = field_decl m2, element2 [template]
  518. // CHECK:STDOUT: %F.decl: %F.type.7c6 = fn_decl @F.1 [template = constants.%F.d17] {} {}
  519. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr.m1.m2 [template = constants.%complete_type.cf7]
  520. // CHECK:STDOUT: complete_type_witness = %complete_type
  521. // CHECK:STDOUT:
  522. // CHECK:STDOUT: !members:
  523. // CHECK:STDOUT: .Self = constants.%Base
  524. // CHECK:STDOUT: .m1 = %.loc5
  525. // CHECK:STDOUT: .m2 = %.loc6
  526. // CHECK:STDOUT: .F = %F.decl
  527. // CHECK:STDOUT: }
  528. // CHECK:STDOUT:
  529. // CHECK:STDOUT: virtual fn @F.1();
  530. // CHECK:STDOUT:
  531. // CHECK:STDOUT: fn @F.2() {
  532. // CHECK:STDOUT: !entry:
  533. // CHECK:STDOUT: %i.var: ref %i32 = var i
  534. // CHECK:STDOUT: %i: ref %i32 = bind_name i, %i.var
  535. // CHECK:STDOUT: %int_3.loc12: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  536. // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  537. // CHECK:STDOUT: %Convert.bound.loc12: <bound method> = bound_method %int_3.loc12, %impl.elem0.loc12 [template = constants.%Convert.bound.b30]
  538. // CHECK:STDOUT: %Convert.specific_fn.loc12: <specific function> = specific_function %Convert.bound.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42]
  539. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %Convert.specific_fn.loc12(%int_3.loc12) [template = constants.%int_3.822]
  540. // CHECK:STDOUT: %.loc12: init %i32 = converted %int_3.loc12, %int.convert_checked.loc12 [template = constants.%int_3.822]
  541. // CHECK:STDOUT: assign %i.var, %.loc12
  542. // CHECK:STDOUT: %b1.var: ref %Base = var b1
  543. // CHECK:STDOUT: %b1: ref %Base = bind_name b1, %b1.var
  544. // CHECK:STDOUT: %i.ref.loc14_25: ref %i32 = name_ref i, %i
  545. // CHECK:STDOUT: %i.ref.loc14_34: ref %i32 = name_ref i, %i
  546. // CHECK:STDOUT: %.loc14_35.1: %struct_type.m2.m1.68c = struct_literal (%i.ref.loc14_25, %i.ref.loc14_34)
  547. // CHECK:STDOUT: %.loc14_35.2: ref %ptr.454 = class_element_access %b1.var, element0
  548. // CHECK:STDOUT: %.loc14_35.3: ref %ptr.454 = vtable_ptr
  549. // CHECK:STDOUT: %.loc14_35.4: init %ptr.454 = initialize_from %.loc14_35.3 to %.loc14_35.2
  550. // CHECK:STDOUT: %.loc14_34: %i32 = bind_value %i.ref.loc14_34
  551. // CHECK:STDOUT: %.loc14_35.5: ref %i32 = class_element_access %b1.var, element2
  552. // CHECK:STDOUT: %.loc14_35.6: init %i32 = initialize_from %.loc14_34 to %.loc14_35.5
  553. // CHECK:STDOUT: %.loc14_25: %i32 = bind_value %i.ref.loc14_25
  554. // CHECK:STDOUT: %.loc14_35.7: ref %i32 = class_element_access %b1.var, element1
  555. // CHECK:STDOUT: %.loc14_35.8: init %i32 = initialize_from %.loc14_25 to %.loc14_35.7
  556. // CHECK:STDOUT: %.loc14_35.9: init %Base = class_init (%.loc14_35.4, %.loc14_35.6, %.loc14_35.8), %b1.var
  557. // CHECK:STDOUT: %.loc14_36: init %Base = converted %.loc14_35.1, %.loc14_35.9
  558. // CHECK:STDOUT: assign %b1.var, %.loc14_36
  559. // CHECK:STDOUT: %b2.var: ref %Base = var b2
  560. // CHECK:STDOUT: %b2: ref %Base = bind_name b2, %b2.var
  561. // CHECK:STDOUT: %int_3.loc15: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  562. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b]
  563. // CHECK:STDOUT: %.loc15_35.1: %struct_type.m2.m1.5f2 = struct_literal (%int_3.loc15, %int_5)
  564. // CHECK:STDOUT: %.loc15_35.2: ref %ptr.454 = class_element_access %b2.var, element0
  565. // CHECK:STDOUT: %.loc15_35.3: ref %ptr.454 = vtable_ptr
  566. // CHECK:STDOUT: %.loc15_35.4: init %ptr.454 = initialize_from %.loc15_35.3 to %.loc15_35.2
  567. // CHECK:STDOUT: %impl.elem0.loc15_35.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  568. // CHECK:STDOUT: %Convert.bound.loc15_35.1: <bound method> = bound_method %int_5, %impl.elem0.loc15_35.1 [template = constants.%Convert.bound.4e6]
  569. // CHECK:STDOUT: %Convert.specific_fn.loc15_35.1: <specific function> = specific_function %Convert.bound.loc15_35.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9]
  570. // CHECK:STDOUT: %int.convert_checked.loc15_35.1: init %i32 = call %Convert.specific_fn.loc15_35.1(%int_5) [template = constants.%int_5.0f6]
  571. // CHECK:STDOUT: %.loc15_35.5: init %i32 = converted %int_5, %int.convert_checked.loc15_35.1 [template = constants.%int_5.0f6]
  572. // CHECK:STDOUT: %.loc15_35.6: ref %i32 = class_element_access %b2.var, element2
  573. // CHECK:STDOUT: %.loc15_35.7: init %i32 = initialize_from %.loc15_35.5 to %.loc15_35.6 [template = constants.%int_5.0f6]
  574. // CHECK:STDOUT: %impl.elem0.loc15_35.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  575. // CHECK:STDOUT: %Convert.bound.loc15_35.2: <bound method> = bound_method %int_3.loc15, %impl.elem0.loc15_35.2 [template = constants.%Convert.bound.b30]
  576. // CHECK:STDOUT: %Convert.specific_fn.loc15_35.2: <specific function> = specific_function %Convert.bound.loc15_35.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42]
  577. // CHECK:STDOUT: %int.convert_checked.loc15_35.2: init %i32 = call %Convert.specific_fn.loc15_35.2(%int_3.loc15) [template = constants.%int_3.822]
  578. // CHECK:STDOUT: %.loc15_35.8: init %i32 = converted %int_3.loc15, %int.convert_checked.loc15_35.2 [template = constants.%int_3.822]
  579. // CHECK:STDOUT: %.loc15_35.9: ref %i32 = class_element_access %b2.var, element1
  580. // CHECK:STDOUT: %.loc15_35.10: init %i32 = initialize_from %.loc15_35.8 to %.loc15_35.9 [template = constants.%int_3.822]
  581. // CHECK:STDOUT: %.loc15_35.11: init %Base = class_init (%.loc15_35.4, %.loc15_35.7, %.loc15_35.10), %b2.var
  582. // CHECK:STDOUT: %.loc15_36: init %Base = converted %.loc15_35.1, %.loc15_35.11
  583. // CHECK:STDOUT: assign %b2.var, %.loc15_36
  584. // CHECK:STDOUT: %b1.ref: ref %Base = name_ref b1, %b1
  585. // CHECK:STDOUT: %m2.ref: %Base.elem = name_ref m2, @Base.%.loc6 [template = @Base.%.loc6]
  586. // CHECK:STDOUT: %.loc18_5: ref %i32 = class_element_access %b1.ref, element2
  587. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  588. // CHECK:STDOUT: %impl.elem0.loc18: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  589. // CHECK:STDOUT: %Convert.bound.loc18: <bound method> = bound_method %int_4, %impl.elem0.loc18 [template = constants.%Convert.bound.ac3]
  590. // CHECK:STDOUT: %Convert.specific_fn.loc18: <specific function> = specific_function %Convert.bound.loc18, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.450]
  591. // CHECK:STDOUT: %int.convert_checked.loc18: init %i32 = call %Convert.specific_fn.loc18(%int_4) [template = constants.%int_4.940]
  592. // CHECK:STDOUT: %.loc18_9: init %i32 = converted %int_4, %int.convert_checked.loc18 [template = constants.%int_4.940]
  593. // CHECK:STDOUT: assign %.loc18_5, %.loc18_9
  594. // CHECK:STDOUT: return
  595. // CHECK:STDOUT: }
  596. // CHECK:STDOUT:
  597. // CHECK:STDOUT: --- todo_fail_impl_without_base_declaration.carbon
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: constants {
  600. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  601. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  602. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  603. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  604. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  605. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  606. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  607. // CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
  608. // CHECK:STDOUT: %struct_type.vptr.base: type = struct_type {.<vptr>: %ptr.454, .base: %Base} [template]
  609. // CHECK:STDOUT: %complete_type.336: <witness> = complete_type_witness %struct_type.vptr.base [template]
  610. // CHECK:STDOUT: }
  611. // CHECK:STDOUT:
  612. // CHECK:STDOUT: imports {
  613. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  614. // CHECK:STDOUT: import Core//prelude
  615. // CHECK:STDOUT: import Core//prelude/...
  616. // CHECK:STDOUT: }
  617. // CHECK:STDOUT: }
  618. // CHECK:STDOUT:
  619. // CHECK:STDOUT: file {
  620. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  621. // CHECK:STDOUT: .Core = imports.%Core
  622. // CHECK:STDOUT: .Base = %Base.decl
  623. // CHECK:STDOUT: .Derived = %Derived.decl
  624. // CHECK:STDOUT: }
  625. // CHECK:STDOUT: %Core.import = import Core
  626. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  627. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  628. // CHECK:STDOUT: }
  629. // CHECK:STDOUT:
  630. // CHECK:STDOUT: class @Base {
  631. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  632. // CHECK:STDOUT: complete_type_witness = %complete_type
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: !members:
  635. // CHECK:STDOUT: .Self = constants.%Base
  636. // CHECK:STDOUT: }
  637. // CHECK:STDOUT:
  638. // CHECK:STDOUT: class @Derived {
  639. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  640. // CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Base.ref, element1 [template]
  641. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  642. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr.base [template = constants.%complete_type.336]
  643. // CHECK:STDOUT: complete_type_witness = %complete_type
  644. // CHECK:STDOUT:
  645. // CHECK:STDOUT: !members:
  646. // CHECK:STDOUT: .Self = constants.%Derived
  647. // CHECK:STDOUT: .base = %.loc8
  648. // CHECK:STDOUT: .F = %F.decl
  649. // CHECK:STDOUT: extend %Base.ref
  650. // CHECK:STDOUT: }
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: impl fn @F();
  653. // CHECK:STDOUT: