multiple_extend.carbon 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  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/impl/multiple_extend.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/multiple_extend.carbon
  10. // --- different_impl_member_names.carbon
  11. library "[[@TEST_NAME]]";
  12. interface HasF {
  13. fn F();
  14. }
  15. interface HasG {
  16. fn G();
  17. }
  18. class C {
  19. extend impl as HasF {
  20. fn F() {}
  21. }
  22. extend impl as HasG {
  23. fn G() {}
  24. }
  25. }
  26. fn H(c: C) {
  27. C.F();
  28. c.F();
  29. C.G();
  30. c.G();
  31. }
  32. // --- fail_ambiguous_impls.carbon
  33. library "[[@TEST_NAME]]";
  34. interface HasA1 {
  35. fn A();
  36. }
  37. interface HasA2 {
  38. fn A();
  39. }
  40. class D {
  41. extend impl as HasA1 {
  42. fn A() {}
  43. }
  44. extend impl as HasA2 {
  45. fn A() {}
  46. }
  47. }
  48. fn B(d: D) {
  49. // CHECK:STDERR: fail_ambiguous_impls.carbon:[[@LINE+4]]:3: error: ambiguous use of name `A` found in multiple extended scopes [NameAmbiguousDueToExtend]
  50. // CHECK:STDERR: D.A();
  51. // CHECK:STDERR: ^~~
  52. // CHECK:STDERR:
  53. D.A();
  54. // CHECK:STDERR: fail_ambiguous_impls.carbon:[[@LINE+4]]:3: error: ambiguous use of name `A` found in multiple extended scopes [NameAmbiguousDueToExtend]
  55. // CHECK:STDERR: d.A();
  56. // CHECK:STDERR: ^~~
  57. // CHECK:STDERR:
  58. d.A();
  59. }
  60. // --- different_impl_and_base.carbon
  61. library "[[@TEST_NAME]]";
  62. interface HasI {
  63. fn I();
  64. }
  65. base class B {
  66. fn J() {}
  67. }
  68. class E {
  69. extend base: B;
  70. extend impl as HasI {
  71. fn I() {}
  72. }
  73. }
  74. fn H(e: E) {
  75. E.I();
  76. e.I();
  77. E.J();
  78. e.J();
  79. }
  80. // --- fail_ambiguous_impl_and_base.carbon
  81. library "[[@TEST_NAME]]";
  82. base class Base {
  83. fn K() {}
  84. }
  85. interface HasK {
  86. fn K();
  87. }
  88. class L {
  89. extend base: Base;
  90. extend impl as HasK {
  91. fn K() {}
  92. }
  93. }
  94. fn M(l: L) {
  95. // CHECK:STDERR: fail_ambiguous_impl_and_base.carbon:[[@LINE+4]]:4: error: ambiguous use of name `K` found in multiple extended scopes [NameAmbiguousDueToExtend]
  96. // CHECK:STDERR: L.K();
  97. // CHECK:STDERR: ^~~
  98. // CHECK:STDERR:
  99. L.K();
  100. // CHECK:STDERR: fail_ambiguous_impl_and_base.carbon:[[@LINE+3]]:4: error: ambiguous use of name `K` found in multiple extended scopes [NameAmbiguousDueToExtend]
  101. // CHECK:STDERR: l.K();
  102. // CHECK:STDERR: ^~~
  103. l.K();
  104. }
  105. // --- ambiguity_hidden.carbon
  106. library "[[@TEST_NAME]]";
  107. base class NBase {
  108. fn N() {}
  109. }
  110. interface HasN1 {
  111. fn N();
  112. }
  113. interface HasN2 {
  114. fn N();
  115. }
  116. class O {
  117. extend base: NBase;
  118. extend impl as HasN1 {
  119. fn N() {}
  120. }
  121. extend impl as HasN2 {
  122. fn N() {}
  123. }
  124. fn N();
  125. }
  126. fn P(o: O) {
  127. O.N();
  128. o.N();
  129. }
  130. // CHECK:STDOUT: --- different_impl_member_names.carbon
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: constants {
  133. // CHECK:STDOUT: %HasF.type: type = interface_type @HasF [template]
  134. // CHECK:STDOUT: %Self.1: %HasF.type = bind_symbolic_name Self, 0 [symbolic]
  135. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  136. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  137. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  138. // CHECK:STDOUT: %.2: type = assoc_entity_type %HasF.type, %F.type.1 [template]
  139. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @HasF.%F.decl [template]
  140. // CHECK:STDOUT: %HasG.type: type = interface_type @HasG [template]
  141. // CHECK:STDOUT: %Self.2: %HasG.type = bind_symbolic_name Self, 0 [symbolic]
  142. // CHECK:STDOUT: %G.type.1: type = fn_type @G.1 [template]
  143. // CHECK:STDOUT: %G.1: %G.type.1 = struct_value () [template]
  144. // CHECK:STDOUT: %.4: type = assoc_entity_type %HasG.type, %G.type.1 [template]
  145. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, @HasG.%G.decl [template]
  146. // CHECK:STDOUT: %C: type = class_type @C [template]
  147. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  148. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  149. // CHECK:STDOUT: %.6: <witness> = interface_witness (%F.2) [template]
  150. // CHECK:STDOUT: %G.type.2: type = fn_type @G.2 [template]
  151. // CHECK:STDOUT: %G.2: %G.type.2 = struct_value () [template]
  152. // CHECK:STDOUT: %.7: <witness> = interface_witness (%G.2) [template]
  153. // CHECK:STDOUT: %.8: type = struct_type {} [template]
  154. // CHECK:STDOUT: %.9: <witness> = complete_type_witness %.8 [template]
  155. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  156. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  157. // CHECK:STDOUT: %.10: type = ptr_type %.8 [template]
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: imports {
  161. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  162. // CHECK:STDOUT: import Core//prelude
  163. // CHECK:STDOUT: import Core//prelude/...
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: file {
  168. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  169. // CHECK:STDOUT: .Core = imports.%Core
  170. // CHECK:STDOUT: .HasF = %HasF.decl
  171. // CHECK:STDOUT: .HasG = %HasG.decl
  172. // CHECK:STDOUT: .C = %C.decl
  173. // CHECK:STDOUT: .H = %H.decl
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT: %Core.import = import Core
  176. // CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%HasF.type] {} {}
  177. // CHECK:STDOUT: %HasG.decl: type = interface_decl @HasG [template = constants.%HasG.type] {} {}
  178. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  179. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {
  180. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  181. // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, runtime_param0
  182. // CHECK:STDOUT: } {
  183. // CHECK:STDOUT: %C.ref.loc21: type = name_ref C, file.%C.decl [template = constants.%C]
  184. // CHECK:STDOUT: %c.param: %C = value_param runtime_param0
  185. // CHECK:STDOUT: %c: %C = bind_name c, %c.param
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: interface @HasF {
  190. // CHECK:STDOUT: %Self: %HasF.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  191. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  192. // CHECK:STDOUT: %.loc5: %.2 = assoc_entity element0, %F.decl [template = constants.%.3]
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: !members:
  195. // CHECK:STDOUT: .Self = %Self
  196. // CHECK:STDOUT: .F = %.loc5
  197. // CHECK:STDOUT: witness = (%F.decl)
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: interface @HasG {
  201. // CHECK:STDOUT: %Self: %HasG.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
  202. // CHECK:STDOUT: %G.decl: %G.type.1 = fn_decl @G.1 [template = constants.%G.1] {} {}
  203. // CHECK:STDOUT: %.loc9: %.4 = assoc_entity element0, %G.decl [template = constants.%.5]
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: !members:
  206. // CHECK:STDOUT: .Self = %Self
  207. // CHECK:STDOUT: .G = %.loc9
  208. // CHECK:STDOUT: witness = (%G.decl)
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: impl @impl.1: %Self.ref as %HasF.ref {
  212. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
  213. // CHECK:STDOUT: %.loc13: <witness> = interface_witness (%F.decl) [template = constants.%.6]
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: !members:
  216. // CHECK:STDOUT: .F = %F.decl
  217. // CHECK:STDOUT: witness = %.loc13
  218. // CHECK:STDOUT: }
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: impl @impl.2: %Self.ref as %HasG.ref {
  221. // CHECK:STDOUT: %G.decl: %G.type.2 = fn_decl @G.2 [template = constants.%G.2] {} {}
  222. // CHECK:STDOUT: %.loc16: <witness> = interface_witness (%G.decl) [template = constants.%.7]
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: !members:
  225. // CHECK:STDOUT: .G = %G.decl
  226. // CHECK:STDOUT: witness = %.loc16
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: class @C {
  230. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  231. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C]
  232. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%HasF.decl [template = constants.%HasF.type]
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  235. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C]
  236. // CHECK:STDOUT: %HasG.ref: type = name_ref HasG, file.%HasG.decl [template = constants.%HasG.type]
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT: %.loc19: <witness> = complete_type_witness %.8 [template = constants.%.9]
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: !members:
  241. // CHECK:STDOUT: .Self = constants.%C
  242. // CHECK:STDOUT: extend name_scope2
  243. // CHECK:STDOUT: extend name_scope3
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: generic fn @F.1(@HasF.%Self: %HasF.type) {
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: fn();
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: generic fn @G.1(@HasG.%Self: %HasG.type) {
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: fn();
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: fn @F.2() {
  257. // CHECK:STDOUT: !entry:
  258. // CHECK:STDOUT: return
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: fn @G.2() {
  262. // CHECK:STDOUT: !entry:
  263. // CHECK:STDOUT: return
  264. // CHECK:STDOUT: }
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: fn @H(%c.param_patt: %C) {
  267. // CHECK:STDOUT: !entry:
  268. // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, file.%C.decl [template = constants.%C]
  269. // CHECK:STDOUT: %F.ref.loc22: %.2 = name_ref F, @HasF.%.loc5 [template = constants.%.3]
  270. // CHECK:STDOUT: %.loc22: %F.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%F.2]
  271. // CHECK:STDOUT: %F.call.loc22: init %.1 = call %.loc22()
  272. // CHECK:STDOUT: %c.ref.loc23: %C = name_ref c, %c
  273. // CHECK:STDOUT: %F.ref.loc23: %.2 = name_ref F, @HasF.%.loc5 [template = constants.%.3]
  274. // CHECK:STDOUT: %.loc23: %F.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%F.2]
  275. // CHECK:STDOUT: %F.call.loc23: init %.1 = call %.loc23()
  276. // CHECK:STDOUT: %C.ref.loc24: type = name_ref C, file.%C.decl [template = constants.%C]
  277. // CHECK:STDOUT: %G.ref.loc24: %.4 = name_ref G, @HasG.%.loc9 [template = constants.%.5]
  278. // CHECK:STDOUT: %.loc24: %G.type.1 = interface_witness_access constants.%.7, element0 [template = constants.%G.2]
  279. // CHECK:STDOUT: %G.call.loc24: init %.1 = call %.loc24()
  280. // CHECK:STDOUT: %c.ref.loc25: %C = name_ref c, %c
  281. // CHECK:STDOUT: %G.ref.loc25: %.4 = name_ref G, @HasG.%.loc9 [template = constants.%.5]
  282. // CHECK:STDOUT: %.loc25: %G.type.1 = interface_witness_access constants.%.7, element0 [template = constants.%G.2]
  283. // CHECK:STDOUT: %G.call.loc25: init %.1 = call %.loc25()
  284. // CHECK:STDOUT: return
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: specific @F.1(constants.%Self.1) {}
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: specific @G.1(constants.%Self.2) {}
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: specific @F.1(constants.%C) {}
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: specific @G.1(constants.%C) {}
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: --- fail_ambiguous_impls.carbon
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: constants {
  298. // CHECK:STDOUT: %HasA1.type: type = interface_type @HasA1 [template]
  299. // CHECK:STDOUT: %Self.1: %HasA1.type = bind_symbolic_name Self, 0 [symbolic]
  300. // CHECK:STDOUT: %A.type.1: type = fn_type @A.1 [template]
  301. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  302. // CHECK:STDOUT: %A.1: %A.type.1 = struct_value () [template]
  303. // CHECK:STDOUT: %.2: type = assoc_entity_type %HasA1.type, %A.type.1 [template]
  304. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @HasA1.%A.decl [template]
  305. // CHECK:STDOUT: %HasA2.type: type = interface_type @HasA2 [template]
  306. // CHECK:STDOUT: %Self.2: %HasA2.type = bind_symbolic_name Self, 0 [symbolic]
  307. // CHECK:STDOUT: %A.type.2: type = fn_type @A.2 [template]
  308. // CHECK:STDOUT: %A.2: %A.type.2 = struct_value () [template]
  309. // CHECK:STDOUT: %.4: type = assoc_entity_type %HasA2.type, %A.type.2 [template]
  310. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, @HasA2.%A.decl [template]
  311. // CHECK:STDOUT: %D: type = class_type @D [template]
  312. // CHECK:STDOUT: %A.type.3: type = fn_type @A.3 [template]
  313. // CHECK:STDOUT: %A.3: %A.type.3 = struct_value () [template]
  314. // CHECK:STDOUT: %.6: <witness> = interface_witness (%A.3) [template]
  315. // CHECK:STDOUT: %A.type.4: type = fn_type @A.4 [template]
  316. // CHECK:STDOUT: %A.4: %A.type.4 = struct_value () [template]
  317. // CHECK:STDOUT: %.7: <witness> = interface_witness (%A.4) [template]
  318. // CHECK:STDOUT: %.8: type = struct_type {} [template]
  319. // CHECK:STDOUT: %.9: <witness> = complete_type_witness %.8 [template]
  320. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  321. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  322. // CHECK:STDOUT: %.10: type = ptr_type %.8 [template]
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: imports {
  326. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  327. // CHECK:STDOUT: import Core//prelude
  328. // CHECK:STDOUT: import Core//prelude/...
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: file {
  333. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  334. // CHECK:STDOUT: .Core = imports.%Core
  335. // CHECK:STDOUT: .HasA1 = %HasA1.decl
  336. // CHECK:STDOUT: .HasA2 = %HasA2.decl
  337. // CHECK:STDOUT: .D = %D.decl
  338. // CHECK:STDOUT: .B = %B.decl
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT: %Core.import = import Core
  341. // CHECK:STDOUT: %HasA1.decl: type = interface_decl @HasA1 [template = constants.%HasA1.type] {} {}
  342. // CHECK:STDOUT: %HasA2.decl: type = interface_decl @HasA2 [template = constants.%HasA2.type] {} {}
  343. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  344. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  345. // CHECK:STDOUT: %d.patt: %D = binding_pattern d
  346. // CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, runtime_param0
  347. // CHECK:STDOUT: } {
  348. // CHECK:STDOUT: %D.ref.loc21: type = name_ref D, file.%D.decl [template = constants.%D]
  349. // CHECK:STDOUT: %d.param: %D = value_param runtime_param0
  350. // CHECK:STDOUT: %d: %D = bind_name d, %d.param
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: interface @HasA1 {
  355. // CHECK:STDOUT: %Self: %HasA1.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  356. // CHECK:STDOUT: %A.decl: %A.type.1 = fn_decl @A.1 [template = constants.%A.1] {} {}
  357. // CHECK:STDOUT: %.loc5: %.2 = assoc_entity element0, %A.decl [template = constants.%.3]
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: !members:
  360. // CHECK:STDOUT: .Self = %Self
  361. // CHECK:STDOUT: .A = %.loc5
  362. // CHECK:STDOUT: witness = (%A.decl)
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: interface @HasA2 {
  366. // CHECK:STDOUT: %Self: %HasA2.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
  367. // CHECK:STDOUT: %A.decl: %A.type.2 = fn_decl @A.2 [template = constants.%A.2] {} {}
  368. // CHECK:STDOUT: %.loc9: %.4 = assoc_entity element0, %A.decl [template = constants.%.5]
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: !members:
  371. // CHECK:STDOUT: .Self = %Self
  372. // CHECK:STDOUT: .A = %.loc9
  373. // CHECK:STDOUT: witness = (%A.decl)
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: impl @impl.1: %Self.ref as %HasA1.ref {
  377. // CHECK:STDOUT: %A.decl: %A.type.3 = fn_decl @A.3 [template = constants.%A.3] {} {}
  378. // CHECK:STDOUT: %.loc13: <witness> = interface_witness (%A.decl) [template = constants.%.6]
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: !members:
  381. // CHECK:STDOUT: .A = %A.decl
  382. // CHECK:STDOUT: witness = %.loc13
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: impl @impl.2: %Self.ref as %HasA2.ref {
  386. // CHECK:STDOUT: %A.decl: %A.type.4 = fn_decl @A.4 [template = constants.%A.4] {} {}
  387. // CHECK:STDOUT: %.loc16: <witness> = interface_witness (%A.decl) [template = constants.%.7]
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: !members:
  390. // CHECK:STDOUT: .A = %A.decl
  391. // CHECK:STDOUT: witness = %.loc16
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: class @D {
  395. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  396. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%D [template = constants.%D]
  397. // CHECK:STDOUT: %HasA1.ref: type = name_ref HasA1, file.%HasA1.decl [template = constants.%HasA1.type]
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  400. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%D [template = constants.%D]
  401. // CHECK:STDOUT: %HasA2.ref: type = name_ref HasA2, file.%HasA2.decl [template = constants.%HasA2.type]
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT: %.loc19: <witness> = complete_type_witness %.8 [template = constants.%.9]
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: !members:
  406. // CHECK:STDOUT: .Self = constants.%D
  407. // CHECK:STDOUT: extend name_scope2
  408. // CHECK:STDOUT: extend name_scope3
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: generic fn @A.1(@HasA1.%Self: %HasA1.type) {
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: fn();
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: generic fn @A.2(@HasA2.%Self: %HasA2.type) {
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: fn();
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: fn @A.3() {
  422. // CHECK:STDOUT: !entry:
  423. // CHECK:STDOUT: return
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: fn @A.4() {
  427. // CHECK:STDOUT: !entry:
  428. // CHECK:STDOUT: return
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: fn @B(%d.param_patt: %D) {
  432. // CHECK:STDOUT: !entry:
  433. // CHECK:STDOUT: %D.ref.loc26: type = name_ref D, file.%D.decl [template = constants.%D]
  434. // CHECK:STDOUT: %A.ref.loc26: <error> = name_ref A, <error> [template = <error>]
  435. // CHECK:STDOUT: %d.ref: %D = name_ref d, %d
  436. // CHECK:STDOUT: %A.ref.loc31: <error> = name_ref A, <error> [template = <error>]
  437. // CHECK:STDOUT: return
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: specific @A.1(constants.%Self.1) {}
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: specific @A.2(constants.%Self.2) {}
  443. // CHECK:STDOUT:
  444. // CHECK:STDOUT: specific @A.1(constants.%D) {}
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: specific @A.2(constants.%D) {}
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: --- different_impl_and_base.carbon
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: constants {
  451. // CHECK:STDOUT: %HasI.type: type = interface_type @HasI [template]
  452. // CHECK:STDOUT: %Self: %HasI.type = bind_symbolic_name Self, 0 [symbolic]
  453. // CHECK:STDOUT: %I.type.1: type = fn_type @I.1 [template]
  454. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  455. // CHECK:STDOUT: %I.1: %I.type.1 = struct_value () [template]
  456. // CHECK:STDOUT: %.2: type = assoc_entity_type %HasI.type, %I.type.1 [template]
  457. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @HasI.%I.decl [template]
  458. // CHECK:STDOUT: %B: type = class_type @B [template]
  459. // CHECK:STDOUT: %J.type: type = fn_type @J [template]
  460. // CHECK:STDOUT: %J: %J.type = struct_value () [template]
  461. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  462. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  463. // CHECK:STDOUT: %E: type = class_type @E [template]
  464. // CHECK:STDOUT: %.6: type = ptr_type %.4 [template]
  465. // CHECK:STDOUT: %.7: type = unbound_element_type %E, %B [template]
  466. // CHECK:STDOUT: %I.type.2: type = fn_type @I.2 [template]
  467. // CHECK:STDOUT: %I.2: %I.type.2 = struct_value () [template]
  468. // CHECK:STDOUT: %.8: <witness> = interface_witness (%I.2) [template]
  469. // CHECK:STDOUT: %.9: type = struct_type {.base: %B} [template]
  470. // CHECK:STDOUT: %.10: <witness> = complete_type_witness %.9 [template]
  471. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  472. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  473. // CHECK:STDOUT: %.11: type = struct_type {.base: %.6} [template]
  474. // CHECK:STDOUT: %.12: type = ptr_type %.9 [template]
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT:
  477. // CHECK:STDOUT: imports {
  478. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  479. // CHECK:STDOUT: import Core//prelude
  480. // CHECK:STDOUT: import Core//prelude/...
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: file {
  485. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  486. // CHECK:STDOUT: .Core = imports.%Core
  487. // CHECK:STDOUT: .HasI = %HasI.decl
  488. // CHECK:STDOUT: .B = %B.decl
  489. // CHECK:STDOUT: .E = %E.decl
  490. // CHECK:STDOUT: .H = %H.decl
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT: %Core.import = import Core
  493. // CHECK:STDOUT: %HasI.decl: type = interface_decl @HasI [template = constants.%HasI.type] {} {}
  494. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  495. // CHECK:STDOUT: %E.decl: type = class_decl @E [template = constants.%E] {} {}
  496. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {
  497. // CHECK:STDOUT: %e.patt: %E = binding_pattern e
  498. // CHECK:STDOUT: %e.param_patt: %E = value_param_pattern %e.patt, runtime_param0
  499. // CHECK:STDOUT: } {
  500. // CHECK:STDOUT: %E.ref.loc19: type = name_ref E, file.%E.decl [template = constants.%E]
  501. // CHECK:STDOUT: %e.param: %E = value_param runtime_param0
  502. // CHECK:STDOUT: %e: %E = bind_name e, %e.param
  503. // CHECK:STDOUT: }
  504. // CHECK:STDOUT: }
  505. // CHECK:STDOUT:
  506. // CHECK:STDOUT: interface @HasI {
  507. // CHECK:STDOUT: %Self: %HasI.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  508. // CHECK:STDOUT: %I.decl: %I.type.1 = fn_decl @I.1 [template = constants.%I.1] {} {}
  509. // CHECK:STDOUT: %.loc5: %.2 = assoc_entity element0, %I.decl [template = constants.%.3]
  510. // CHECK:STDOUT:
  511. // CHECK:STDOUT: !members:
  512. // CHECK:STDOUT: .Self = %Self
  513. // CHECK:STDOUT: .I = %.loc5
  514. // CHECK:STDOUT: witness = (%I.decl)
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT:
  517. // CHECK:STDOUT: impl @impl: %Self.ref as %HasI.ref {
  518. // CHECK:STDOUT: %I.decl: %I.type.2 = fn_decl @I.2 [template = constants.%I.2] {} {}
  519. // CHECK:STDOUT: %.loc14: <witness> = interface_witness (%I.decl) [template = constants.%.8]
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: !members:
  522. // CHECK:STDOUT: .I = %I.decl
  523. // CHECK:STDOUT: witness = %.loc14
  524. // CHECK:STDOUT: }
  525. // CHECK:STDOUT:
  526. // CHECK:STDOUT: class @B {
  527. // CHECK:STDOUT: %J.decl: %J.type = fn_decl @J [template = constants.%J] {} {}
  528. // CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %.4 [template = constants.%.5]
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: !members:
  531. // CHECK:STDOUT: .Self = constants.%B
  532. // CHECK:STDOUT: .J = %J.decl
  533. // CHECK:STDOUT: }
  534. // CHECK:STDOUT:
  535. // CHECK:STDOUT: class @E {
  536. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  537. // CHECK:STDOUT: %.loc13: %.7 = base_decl %B, element0 [template]
  538. // CHECK:STDOUT: impl_decl @impl [template] {} {
  539. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%E [template = constants.%E]
  540. // CHECK:STDOUT: %HasI.ref: type = name_ref HasI, file.%HasI.decl [template = constants.%HasI.type]
  541. // CHECK:STDOUT: }
  542. // CHECK:STDOUT: %.loc17: <witness> = complete_type_witness %.9 [template = constants.%.10]
  543. // CHECK:STDOUT:
  544. // CHECK:STDOUT: !members:
  545. // CHECK:STDOUT: .Self = constants.%E
  546. // CHECK:STDOUT: .base = %.loc13
  547. // CHECK:STDOUT: extend name_scope3
  548. // CHECK:STDOUT: extend name_scope2
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: generic fn @I.1(@HasI.%Self: %HasI.type) {
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: fn();
  554. // CHECK:STDOUT: }
  555. // CHECK:STDOUT:
  556. // CHECK:STDOUT: fn @J() {
  557. // CHECK:STDOUT: !entry:
  558. // CHECK:STDOUT: return
  559. // CHECK:STDOUT: }
  560. // CHECK:STDOUT:
  561. // CHECK:STDOUT: fn @I.2() {
  562. // CHECK:STDOUT: !entry:
  563. // CHECK:STDOUT: return
  564. // CHECK:STDOUT: }
  565. // CHECK:STDOUT:
  566. // CHECK:STDOUT: fn @H(%e.param_patt: %E) {
  567. // CHECK:STDOUT: !entry:
  568. // CHECK:STDOUT: %E.ref.loc20: type = name_ref E, file.%E.decl [template = constants.%E]
  569. // CHECK:STDOUT: %I.ref.loc20: %.2 = name_ref I, @HasI.%.loc5 [template = constants.%.3]
  570. // CHECK:STDOUT: %.loc20: %I.type.1 = interface_witness_access constants.%.8, element0 [template = constants.%I.2]
  571. // CHECK:STDOUT: %I.call.loc20: init %.1 = call %.loc20()
  572. // CHECK:STDOUT: %e.ref.loc21: %E = name_ref e, %e
  573. // CHECK:STDOUT: %I.ref.loc21: %.2 = name_ref I, @HasI.%.loc5 [template = constants.%.3]
  574. // CHECK:STDOUT: %.loc21: %I.type.1 = interface_witness_access constants.%.8, element0 [template = constants.%I.2]
  575. // CHECK:STDOUT: %I.call.loc21: init %.1 = call %.loc21()
  576. // CHECK:STDOUT: %E.ref.loc22: type = name_ref E, file.%E.decl [template = constants.%E]
  577. // CHECK:STDOUT: %J.ref.loc22: %J.type = name_ref J, @B.%J.decl [template = constants.%J]
  578. // CHECK:STDOUT: %J.call.loc22: init %.1 = call %J.ref.loc22()
  579. // CHECK:STDOUT: %e.ref.loc23: %E = name_ref e, %e
  580. // CHECK:STDOUT: %J.ref.loc23: %J.type = name_ref J, @B.%J.decl [template = constants.%J]
  581. // CHECK:STDOUT: %J.call.loc23: init %.1 = call %J.ref.loc23()
  582. // CHECK:STDOUT: return
  583. // CHECK:STDOUT: }
  584. // CHECK:STDOUT:
  585. // CHECK:STDOUT: specific @I.1(constants.%Self) {}
  586. // CHECK:STDOUT:
  587. // CHECK:STDOUT: specific @I.1(constants.%E) {}
  588. // CHECK:STDOUT:
  589. // CHECK:STDOUT: --- fail_ambiguous_impl_and_base.carbon
  590. // CHECK:STDOUT:
  591. // CHECK:STDOUT: constants {
  592. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  593. // CHECK:STDOUT: %K.type.1: type = fn_type @K.1 [template]
  594. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  595. // CHECK:STDOUT: %K.1: %K.type.1 = struct_value () [template]
  596. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  597. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  598. // CHECK:STDOUT: %HasK.type: type = interface_type @HasK [template]
  599. // CHECK:STDOUT: %Self: %HasK.type = bind_symbolic_name Self, 0 [symbolic]
  600. // CHECK:STDOUT: %K.type.2: type = fn_type @K.2 [template]
  601. // CHECK:STDOUT: %K.2: %K.type.2 = struct_value () [template]
  602. // CHECK:STDOUT: %.4: type = assoc_entity_type %HasK.type, %K.type.2 [template]
  603. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, @HasK.%K.decl [template]
  604. // CHECK:STDOUT: %L: type = class_type @L [template]
  605. // CHECK:STDOUT: %.6: type = ptr_type %.2 [template]
  606. // CHECK:STDOUT: %.7: type = unbound_element_type %L, %Base [template]
  607. // CHECK:STDOUT: %K.type.3: type = fn_type @K.3 [template]
  608. // CHECK:STDOUT: %K.3: %K.type.3 = struct_value () [template]
  609. // CHECK:STDOUT: %.8: <witness> = interface_witness (%K.3) [template]
  610. // CHECK:STDOUT: %.9: type = struct_type {.base: %Base} [template]
  611. // CHECK:STDOUT: %.10: <witness> = complete_type_witness %.9 [template]
  612. // CHECK:STDOUT: %M.type: type = fn_type @M [template]
  613. // CHECK:STDOUT: %M: %M.type = struct_value () [template]
  614. // CHECK:STDOUT: %.11: type = struct_type {.base: %.6} [template]
  615. // CHECK:STDOUT: %.12: type = ptr_type %.9 [template]
  616. // CHECK:STDOUT: }
  617. // CHECK:STDOUT:
  618. // CHECK:STDOUT: imports {
  619. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  620. // CHECK:STDOUT: import Core//prelude
  621. // CHECK:STDOUT: import Core//prelude/...
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT: }
  624. // CHECK:STDOUT:
  625. // CHECK:STDOUT: file {
  626. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  627. // CHECK:STDOUT: .Core = imports.%Core
  628. // CHECK:STDOUT: .Base = %Base.decl
  629. // CHECK:STDOUT: .HasK = %HasK.decl
  630. // CHECK:STDOUT: .L = %L.decl
  631. // CHECK:STDOUT: .M = %M.decl
  632. // CHECK:STDOUT: }
  633. // CHECK:STDOUT: %Core.import = import Core
  634. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  635. // CHECK:STDOUT: %HasK.decl: type = interface_decl @HasK [template = constants.%HasK.type] {} {}
  636. // CHECK:STDOUT: %L.decl: type = class_decl @L [template = constants.%L] {} {}
  637. // CHECK:STDOUT: %M.decl: %M.type = fn_decl @M [template = constants.%M] {
  638. // CHECK:STDOUT: %l.patt: %L = binding_pattern l
  639. // CHECK:STDOUT: %l.param_patt: %L = value_param_pattern %l.patt, runtime_param0
  640. // CHECK:STDOUT: } {
  641. // CHECK:STDOUT: %L.ref.loc19: type = name_ref L, file.%L.decl [template = constants.%L]
  642. // CHECK:STDOUT: %l.param: %L = value_param runtime_param0
  643. // CHECK:STDOUT: %l: %L = bind_name l, %l.param
  644. // CHECK:STDOUT: }
  645. // CHECK:STDOUT: }
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: interface @HasK {
  648. // CHECK:STDOUT: %Self: %HasK.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  649. // CHECK:STDOUT: %K.decl: %K.type.2 = fn_decl @K.2 [template = constants.%K.2] {} {}
  650. // CHECK:STDOUT: %.loc9: %.4 = assoc_entity element0, %K.decl [template = constants.%.5]
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: !members:
  653. // CHECK:STDOUT: .Self = %Self
  654. // CHECK:STDOUT: .K = %.loc9
  655. // CHECK:STDOUT: witness = (%K.decl)
  656. // CHECK:STDOUT: }
  657. // CHECK:STDOUT:
  658. // CHECK:STDOUT: impl @impl: %Self.ref as %HasK.ref {
  659. // CHECK:STDOUT: %K.decl: %K.type.3 = fn_decl @K.3 [template = constants.%K.3] {} {}
  660. // CHECK:STDOUT: %.loc14: <witness> = interface_witness (%K.decl) [template = constants.%.8]
  661. // CHECK:STDOUT:
  662. // CHECK:STDOUT: !members:
  663. // CHECK:STDOUT: .K = %K.decl
  664. // CHECK:STDOUT: witness = %.loc14
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT:
  667. // CHECK:STDOUT: class @Base {
  668. // CHECK:STDOUT: %K.decl: %K.type.1 = fn_decl @K.1 [template = constants.%K.1] {} {}
  669. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.2 [template = constants.%.3]
  670. // CHECK:STDOUT:
  671. // CHECK:STDOUT: !members:
  672. // CHECK:STDOUT: .Self = constants.%Base
  673. // CHECK:STDOUT: .K = %K.decl
  674. // CHECK:STDOUT: }
  675. // CHECK:STDOUT:
  676. // CHECK:STDOUT: class @L {
  677. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  678. // CHECK:STDOUT: %.loc13: %.7 = base_decl %Base, element0 [template]
  679. // CHECK:STDOUT: impl_decl @impl [template] {} {
  680. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%L [template = constants.%L]
  681. // CHECK:STDOUT: %HasK.ref: type = name_ref HasK, file.%HasK.decl [template = constants.%HasK.type]
  682. // CHECK:STDOUT: }
  683. // CHECK:STDOUT: %.loc17: <witness> = complete_type_witness %.9 [template = constants.%.10]
  684. // CHECK:STDOUT:
  685. // CHECK:STDOUT: !members:
  686. // CHECK:STDOUT: .Self = constants.%L
  687. // CHECK:STDOUT: .base = %.loc13
  688. // CHECK:STDOUT: extend name_scope2
  689. // CHECK:STDOUT: extend name_scope3
  690. // CHECK:STDOUT: }
  691. // CHECK:STDOUT:
  692. // CHECK:STDOUT: fn @K.1() {
  693. // CHECK:STDOUT: !entry:
  694. // CHECK:STDOUT: return
  695. // CHECK:STDOUT: }
  696. // CHECK:STDOUT:
  697. // CHECK:STDOUT: generic fn @K.2(@HasK.%Self: %HasK.type) {
  698. // CHECK:STDOUT:
  699. // CHECK:STDOUT: fn();
  700. // CHECK:STDOUT: }
  701. // CHECK:STDOUT:
  702. // CHECK:STDOUT: fn @K.3() {
  703. // CHECK:STDOUT: !entry:
  704. // CHECK:STDOUT: return
  705. // CHECK:STDOUT: }
  706. // CHECK:STDOUT:
  707. // CHECK:STDOUT: fn @M(%l.param_patt: %L) {
  708. // CHECK:STDOUT: !entry:
  709. // CHECK:STDOUT: %L.ref.loc24: type = name_ref L, file.%L.decl [template = constants.%L]
  710. // CHECK:STDOUT: %K.ref.loc24: <error> = name_ref K, <error> [template = <error>]
  711. // CHECK:STDOUT: %l.ref: %L = name_ref l, %l
  712. // CHECK:STDOUT: %K.ref.loc28: <error> = name_ref K, <error> [template = <error>]
  713. // CHECK:STDOUT: return
  714. // CHECK:STDOUT: }
  715. // CHECK:STDOUT:
  716. // CHECK:STDOUT: specific @K.2(constants.%Self) {}
  717. // CHECK:STDOUT:
  718. // CHECK:STDOUT: specific @K.2(constants.%L) {}
  719. // CHECK:STDOUT:
  720. // CHECK:STDOUT: --- ambiguity_hidden.carbon
  721. // CHECK:STDOUT:
  722. // CHECK:STDOUT: constants {
  723. // CHECK:STDOUT: %NBase: type = class_type @NBase [template]
  724. // CHECK:STDOUT: %N.type.1: type = fn_type @N.1 [template]
  725. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  726. // CHECK:STDOUT: %N.1: %N.type.1 = struct_value () [template]
  727. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  728. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  729. // CHECK:STDOUT: %HasN1.type: type = interface_type @HasN1 [template]
  730. // CHECK:STDOUT: %Self.1: %HasN1.type = bind_symbolic_name Self, 0 [symbolic]
  731. // CHECK:STDOUT: %N.type.2: type = fn_type @N.2 [template]
  732. // CHECK:STDOUT: %N.2: %N.type.2 = struct_value () [template]
  733. // CHECK:STDOUT: %.4: type = assoc_entity_type %HasN1.type, %N.type.2 [template]
  734. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, @HasN1.%N.decl [template]
  735. // CHECK:STDOUT: %HasN2.type: type = interface_type @HasN2 [template]
  736. // CHECK:STDOUT: %Self.2: %HasN2.type = bind_symbolic_name Self, 0 [symbolic]
  737. // CHECK:STDOUT: %N.type.3: type = fn_type @N.3 [template]
  738. // CHECK:STDOUT: %N.3: %N.type.3 = struct_value () [template]
  739. // CHECK:STDOUT: %.6: type = assoc_entity_type %HasN2.type, %N.type.3 [template]
  740. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, @HasN2.%N.decl [template]
  741. // CHECK:STDOUT: %O: type = class_type @O [template]
  742. // CHECK:STDOUT: %.8: type = ptr_type %.2 [template]
  743. // CHECK:STDOUT: %.9: type = unbound_element_type %O, %NBase [template]
  744. // CHECK:STDOUT: %N.type.4: type = fn_type @N.4 [template]
  745. // CHECK:STDOUT: %N.4: %N.type.4 = struct_value () [template]
  746. // CHECK:STDOUT: %.10: <witness> = interface_witness (%N.4) [template]
  747. // CHECK:STDOUT: %N.type.5: type = fn_type @N.5 [template]
  748. // CHECK:STDOUT: %N.5: %N.type.5 = struct_value () [template]
  749. // CHECK:STDOUT: %.11: <witness> = interface_witness (%N.5) [template]
  750. // CHECK:STDOUT: %N.type.6: type = fn_type @N.6 [template]
  751. // CHECK:STDOUT: %N.6: %N.type.6 = struct_value () [template]
  752. // CHECK:STDOUT: %.12: type = struct_type {.base: %NBase} [template]
  753. // CHECK:STDOUT: %.13: <witness> = complete_type_witness %.12 [template]
  754. // CHECK:STDOUT: %P.type: type = fn_type @P [template]
  755. // CHECK:STDOUT: %P: %P.type = struct_value () [template]
  756. // CHECK:STDOUT: %.14: type = struct_type {.base: %.8} [template]
  757. // CHECK:STDOUT: %.15: type = ptr_type %.12 [template]
  758. // CHECK:STDOUT: }
  759. // CHECK:STDOUT:
  760. // CHECK:STDOUT: imports {
  761. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  762. // CHECK:STDOUT: import Core//prelude
  763. // CHECK:STDOUT: import Core//prelude/...
  764. // CHECK:STDOUT: }
  765. // CHECK:STDOUT: }
  766. // CHECK:STDOUT:
  767. // CHECK:STDOUT: file {
  768. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  769. // CHECK:STDOUT: .Core = imports.%Core
  770. // CHECK:STDOUT: .NBase = %NBase.decl
  771. // CHECK:STDOUT: .HasN1 = %HasN1.decl
  772. // CHECK:STDOUT: .HasN2 = %HasN2.decl
  773. // CHECK:STDOUT: .O = %O.decl
  774. // CHECK:STDOUT: .P = %P.decl
  775. // CHECK:STDOUT: }
  776. // CHECK:STDOUT: %Core.import = import Core
  777. // CHECK:STDOUT: %NBase.decl: type = class_decl @NBase [template = constants.%NBase] {} {}
  778. // CHECK:STDOUT: %HasN1.decl: type = interface_decl @HasN1 [template = constants.%HasN1.type] {} {}
  779. // CHECK:STDOUT: %HasN2.decl: type = interface_decl @HasN2 [template = constants.%HasN2.type] {} {}
  780. // CHECK:STDOUT: %O.decl: type = class_decl @O [template = constants.%O] {} {}
  781. // CHECK:STDOUT: %P.decl: %P.type = fn_decl @P [template = constants.%P] {
  782. // CHECK:STDOUT: %o.patt: %O = binding_pattern o
  783. // CHECK:STDOUT: %o.param_patt: %O = value_param_pattern %o.patt, runtime_param0
  784. // CHECK:STDOUT: } {
  785. // CHECK:STDOUT: %O.ref.loc27: type = name_ref O, file.%O.decl [template = constants.%O]
  786. // CHECK:STDOUT: %o.param: %O = value_param runtime_param0
  787. // CHECK:STDOUT: %o: %O = bind_name o, %o.param
  788. // CHECK:STDOUT: }
  789. // CHECK:STDOUT: }
  790. // CHECK:STDOUT:
  791. // CHECK:STDOUT: interface @HasN1 {
  792. // CHECK:STDOUT: %Self: %HasN1.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  793. // CHECK:STDOUT: %N.decl: %N.type.2 = fn_decl @N.2 [template = constants.%N.2] {} {}
  794. // CHECK:STDOUT: %.loc9: %.4 = assoc_entity element0, %N.decl [template = constants.%.5]
  795. // CHECK:STDOUT:
  796. // CHECK:STDOUT: !members:
  797. // CHECK:STDOUT: .Self = %Self
  798. // CHECK:STDOUT: .N = %.loc9
  799. // CHECK:STDOUT: witness = (%N.decl)
  800. // CHECK:STDOUT: }
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: interface @HasN2 {
  803. // CHECK:STDOUT: %Self: %HasN2.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
  804. // CHECK:STDOUT: %N.decl: %N.type.3 = fn_decl @N.3 [template = constants.%N.3] {} {}
  805. // CHECK:STDOUT: %.loc13: %.6 = assoc_entity element0, %N.decl [template = constants.%.7]
  806. // CHECK:STDOUT:
  807. // CHECK:STDOUT: !members:
  808. // CHECK:STDOUT: .Self = %Self
  809. // CHECK:STDOUT: .N = %.loc13
  810. // CHECK:STDOUT: witness = (%N.decl)
  811. // CHECK:STDOUT: }
  812. // CHECK:STDOUT:
  813. // CHECK:STDOUT: impl @impl.1: %Self.ref as %HasN1.ref {
  814. // CHECK:STDOUT: %N.decl: %N.type.4 = fn_decl @N.4 [template = constants.%N.4] {} {}
  815. // CHECK:STDOUT: %.loc18: <witness> = interface_witness (%N.decl) [template = constants.%.10]
  816. // CHECK:STDOUT:
  817. // CHECK:STDOUT: !members:
  818. // CHECK:STDOUT: .N = %N.decl
  819. // CHECK:STDOUT: witness = %.loc18
  820. // CHECK:STDOUT: }
  821. // CHECK:STDOUT:
  822. // CHECK:STDOUT: impl @impl.2: %Self.ref as %HasN2.ref {
  823. // CHECK:STDOUT: %N.decl: %N.type.5 = fn_decl @N.5 [template = constants.%N.5] {} {}
  824. // CHECK:STDOUT: %.loc21: <witness> = interface_witness (%N.decl) [template = constants.%.11]
  825. // CHECK:STDOUT:
  826. // CHECK:STDOUT: !members:
  827. // CHECK:STDOUT: .N = %N.decl
  828. // CHECK:STDOUT: witness = %.loc21
  829. // CHECK:STDOUT: }
  830. // CHECK:STDOUT:
  831. // CHECK:STDOUT: class @NBase {
  832. // CHECK:STDOUT: %N.decl: %N.type.1 = fn_decl @N.1 [template = constants.%N.1] {} {}
  833. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.2 [template = constants.%.3]
  834. // CHECK:STDOUT:
  835. // CHECK:STDOUT: !members:
  836. // CHECK:STDOUT: .Self = constants.%NBase
  837. // CHECK:STDOUT: .N = %N.decl
  838. // CHECK:STDOUT: }
  839. // CHECK:STDOUT:
  840. // CHECK:STDOUT: class @O {
  841. // CHECK:STDOUT: %NBase.ref: type = name_ref NBase, file.%NBase.decl [template = constants.%NBase]
  842. // CHECK:STDOUT: %.loc17: %.9 = base_decl %NBase, element0 [template]
  843. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  844. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%O [template = constants.%O]
  845. // CHECK:STDOUT: %HasN1.ref: type = name_ref HasN1, file.%HasN1.decl [template = constants.%HasN1.type]
  846. // CHECK:STDOUT: }
  847. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  848. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%O [template = constants.%O]
  849. // CHECK:STDOUT: %HasN2.ref: type = name_ref HasN2, file.%HasN2.decl [template = constants.%HasN2.type]
  850. // CHECK:STDOUT: }
  851. // CHECK:STDOUT: %N.decl: %N.type.6 = fn_decl @N.6 [template = constants.%N.6] {} {}
  852. // CHECK:STDOUT: %.loc25: <witness> = complete_type_witness %.12 [template = constants.%.13]
  853. // CHECK:STDOUT:
  854. // CHECK:STDOUT: !members:
  855. // CHECK:STDOUT: .Self = constants.%O
  856. // CHECK:STDOUT: .base = %.loc17
  857. // CHECK:STDOUT: .N = %N.decl
  858. // CHECK:STDOUT: extend name_scope2
  859. // CHECK:STDOUT: extend name_scope3
  860. // CHECK:STDOUT: extend name_scope4
  861. // CHECK:STDOUT: }
  862. // CHECK:STDOUT:
  863. // CHECK:STDOUT: fn @N.1() {
  864. // CHECK:STDOUT: !entry:
  865. // CHECK:STDOUT: return
  866. // CHECK:STDOUT: }
  867. // CHECK:STDOUT:
  868. // CHECK:STDOUT: generic fn @N.2(@HasN1.%Self: %HasN1.type) {
  869. // CHECK:STDOUT:
  870. // CHECK:STDOUT: fn();
  871. // CHECK:STDOUT: }
  872. // CHECK:STDOUT:
  873. // CHECK:STDOUT: generic fn @N.3(@HasN2.%Self: %HasN2.type) {
  874. // CHECK:STDOUT:
  875. // CHECK:STDOUT: fn();
  876. // CHECK:STDOUT: }
  877. // CHECK:STDOUT:
  878. // CHECK:STDOUT: fn @N.4() {
  879. // CHECK:STDOUT: !entry:
  880. // CHECK:STDOUT: return
  881. // CHECK:STDOUT: }
  882. // CHECK:STDOUT:
  883. // CHECK:STDOUT: fn @N.5() {
  884. // CHECK:STDOUT: !entry:
  885. // CHECK:STDOUT: return
  886. // CHECK:STDOUT: }
  887. // CHECK:STDOUT:
  888. // CHECK:STDOUT: fn @N.6();
  889. // CHECK:STDOUT:
  890. // CHECK:STDOUT: fn @P(%o.param_patt: %O) {
  891. // CHECK:STDOUT: !entry:
  892. // CHECK:STDOUT: %O.ref.loc28: type = name_ref O, file.%O.decl [template = constants.%O]
  893. // CHECK:STDOUT: %N.ref.loc28: %N.type.6 = name_ref N, @O.%N.decl [template = constants.%N.6]
  894. // CHECK:STDOUT: %N.call.loc28: init %.1 = call %N.ref.loc28()
  895. // CHECK:STDOUT: %o.ref: %O = name_ref o, %o
  896. // CHECK:STDOUT: %N.ref.loc29: %N.type.6 = name_ref N, @O.%N.decl [template = constants.%N.6]
  897. // CHECK:STDOUT: %N.call.loc29: init %.1 = call %N.ref.loc29()
  898. // CHECK:STDOUT: return
  899. // CHECK:STDOUT: }
  900. // CHECK:STDOUT:
  901. // CHECK:STDOUT: specific @N.2(constants.%Self.1) {}
  902. // CHECK:STDOUT:
  903. // CHECK:STDOUT: specific @N.3(constants.%Self.2) {}
  904. // CHECK:STDOUT:
  905. // CHECK:STDOUT: specific @N.2(constants.%O) {}
  906. // CHECK:STDOUT:
  907. // CHECK:STDOUT: specific @N.3(constants.%O) {}
  908. // CHECK:STDOUT: