multiple_extend.carbon 42 KB

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