multiple_extend.carbon 39 KB

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