canonical_query_self.carbon 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/canonical_query_self.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/canonical_query_self.carbon
  14. interface I {
  15. fn II[self: Self]();
  16. }
  17. interface J {
  18. fn JJ[self: Self]();
  19. }
  20. fn F(T:! I & J, t: T) {
  21. // Nesting FacetValue and FacetAccessTypes, the `lookup_impl_witness`
  22. // instructions should remain canonical, pointing symbolically to `T`, and not
  23. // include these conversions.
  24. (t as (((((((T as I) as type) as J) as type) as I) as type) as J)).JJ();
  25. }
  26. fn G() {
  27. class C {
  28. extend impl as I {
  29. fn II[self: Self]() {}
  30. }
  31. extend impl as J {
  32. fn JJ[self: Self]() {}
  33. }
  34. }
  35. // Nesting FacetValue and FacetAccessTypes, the impl lookup for `JJ` resolves
  36. // to a canonical `impl_witness` for the `impl C as J`.
  37. (({} as C) as (((((((C as I) as type) as J) as type) as I) as type) as J)).JJ();
  38. // Produces a specific for `F` with a `FacetValue` to replace the
  39. // `SymbolicBinding` parameter `T` when evaluated. The `lookup_impl_witness`
  40. // instructions should be replaced in the specific with concrete
  41. // `impl_witness` instructions for `impl C as I` and `impl C as J`.
  42. F(C, {} as C);
  43. }
  44. // CHECK:STDOUT: --- canonical_query_self.carbon
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: constants {
  47. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  48. // CHECK:STDOUT: %Self.ab9: %I.type = symbolic_binding Self, 0 [symbolic]
  49. // CHECK:STDOUT: %Self.binding.as_type.d31: type = symbolic_binding_type Self, 0, %Self.ab9 [symbolic]
  50. // CHECK:STDOUT: %pattern_type.fa0: type = pattern_type %Self.binding.as_type.d31 [symbolic]
  51. // CHECK:STDOUT: %I.II.type: type = fn_type @I.II [concrete]
  52. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  53. // CHECK:STDOUT: %I.II: %I.II.type = struct_value () [concrete]
  54. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  55. // CHECK:STDOUT: %assoc0.b30: %I.assoc_type = assoc_entity element0, @I.%I.II.decl [concrete]
  56. // CHECK:STDOUT: %J.type: type = facet_type <@J> [concrete]
  57. // CHECK:STDOUT: %Self.8a1: %J.type = symbolic_binding Self, 0 [symbolic]
  58. // CHECK:STDOUT: %Self.binding.as_type.ed8: type = symbolic_binding_type Self, 0, %Self.8a1 [symbolic]
  59. // CHECK:STDOUT: %pattern_type.832: type = pattern_type %Self.binding.as_type.ed8 [symbolic]
  60. // CHECK:STDOUT: %J.JJ.type: type = fn_type @J.JJ [concrete]
  61. // CHECK:STDOUT: %J.JJ: %J.JJ.type = struct_value () [concrete]
  62. // CHECK:STDOUT: %J.assoc_type: type = assoc_entity_type @J [concrete]
  63. // CHECK:STDOUT: %assoc0.d13: %J.assoc_type = assoc_entity element0, @J.%J.JJ.decl [concrete]
  64. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  65. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  66. // CHECK:STDOUT: %BitAndWith.type.f2e: type = generic_interface_type @BitAndWith [concrete]
  67. // CHECK:STDOUT: %BitAndWith.generic: %BitAndWith.type.f2e = struct_value () [concrete]
  68. // CHECK:STDOUT: %BitAndWith.type.b10: type = facet_type <@BitAndWith, @BitAndWith(type)> [concrete]
  69. // CHECK:STDOUT: %BitAndWith.Op.type.9a3: type = fn_type @BitAndWith.Op, @BitAndWith(type) [concrete]
  70. // CHECK:STDOUT: %BitAndWith.impl_witness: <witness> = impl_witness imports.%BitAndWith.impl_witness_table [concrete]
  71. // CHECK:STDOUT: %BitAndWith.facet: %BitAndWith.type.b10 = facet_value type, (%BitAndWith.impl_witness) [concrete]
  72. // CHECK:STDOUT: %.890: type = fn_type_with_self_type %BitAndWith.Op.type.9a3, %BitAndWith.facet [concrete]
  73. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.type: type = fn_type @type.as.BitAndWith.impl.Op [concrete]
  74. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op: %type.as.BitAndWith.impl.Op.type = struct_value () [concrete]
  75. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.bound: <bound method> = bound_method %I.type, %type.as.BitAndWith.impl.Op [concrete]
  76. // CHECK:STDOUT: %facet_type: type = facet_type <@I & @J> [concrete]
  77. // CHECK:STDOUT: %T: %facet_type = symbolic_binding T, 0 [symbolic]
  78. // CHECK:STDOUT: %pattern_type.840: type = pattern_type %facet_type [concrete]
  79. // CHECK:STDOUT: %T.binding.as_type: type = symbolic_binding_type T, 0, %T [symbolic]
  80. // CHECK:STDOUT: %pattern_type.bd7: type = pattern_type %T.binding.as_type [symbolic]
  81. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  82. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  83. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.binding.as_type [symbolic]
  84. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  85. // CHECK:STDOUT: %I.facet.990: %I.type = facet_value %T.binding.as_type, (%I.lookup_impl_witness) [symbolic]
  86. // CHECK:STDOUT: %J.lookup_impl_witness: <witness> = lookup_impl_witness %T, @J [symbolic]
  87. // CHECK:STDOUT: %J.facet.a3a: %J.type = facet_value %T.binding.as_type, (%J.lookup_impl_witness) [symbolic]
  88. // CHECK:STDOUT: %.7eb: type = fn_type_with_self_type %J.JJ.type, %J.facet.a3a [symbolic]
  89. // CHECK:STDOUT: %impl.elem0: %.7eb = impl_witness_access %J.lookup_impl_witness, element0 [symbolic]
  90. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @J.JJ(%J.facet.a3a) [symbolic]
  91. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  92. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  93. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  94. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @C.as.I.impl.%I.impl_witness_table [concrete]
  95. // CHECK:STDOUT: %pattern_type.893: type = pattern_type %C [concrete]
  96. // CHECK:STDOUT: %C.as.I.impl.II.type: type = fn_type @C.as.I.impl.II [concrete]
  97. // CHECK:STDOUT: %C.as.I.impl.II: %C.as.I.impl.II.type = struct_value () [concrete]
  98. // CHECK:STDOUT: %I.facet.cbf: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  99. // CHECK:STDOUT: %J.impl_witness: <witness> = impl_witness @C.as.J.impl.%J.impl_witness_table [concrete]
  100. // CHECK:STDOUT: %C.as.J.impl.JJ.type: type = fn_type @C.as.J.impl.JJ [concrete]
  101. // CHECK:STDOUT: %C.as.J.impl.JJ: %C.as.J.impl.JJ.type = struct_value () [concrete]
  102. // CHECK:STDOUT: %J.facet.fc3: %J.type = facet_value %C, (%J.impl_witness) [concrete]
  103. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  104. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  105. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  106. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  107. // CHECK:STDOUT: %.322: type = fn_type_with_self_type %J.JJ.type, %J.facet.fc3 [concrete]
  108. // CHECK:STDOUT: %facet_value: %facet_type = facet_value %C, (%I.impl_witness, %J.impl_witness) [concrete]
  109. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%facet_value) [concrete]
  110. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  111. // CHECK:STDOUT: %DestroyOp.type: type = fn_type @DestroyOp [concrete]
  112. // CHECK:STDOUT: %DestroyOp: %DestroyOp.type = struct_value () [concrete]
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: imports {
  116. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  117. // CHECK:STDOUT: .BitAndWith = %Core.BitAndWith
  118. // CHECK:STDOUT: .Destroy = %Core.Destroy
  119. // CHECK:STDOUT: import Core//prelude
  120. // CHECK:STDOUT: import Core//prelude/...
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT: %Core.BitAndWith: %BitAndWith.type.f2e = import_ref Core//prelude/parts/as, BitAndWith, loaded [concrete = constants.%BitAndWith.generic]
  123. // CHECK:STDOUT: %Core.import_ref.8d3: %type.as.BitAndWith.impl.Op.type = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, loaded [concrete = constants.%type.as.BitAndWith.impl.Op]
  124. // CHECK:STDOUT: %BitAndWith.impl_witness_table = impl_witness_table (%Core.import_ref.8d3), @type.as.BitAndWith.impl [concrete]
  125. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: file {
  129. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  130. // CHECK:STDOUT: .Core = imports.%Core
  131. // CHECK:STDOUT: .I = %I.decl
  132. // CHECK:STDOUT: .J = %J.decl
  133. // CHECK:STDOUT: .F = %F.decl
  134. // CHECK:STDOUT: .G = %G.decl
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT: %Core.import = import Core
  137. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  138. // CHECK:STDOUT: %J.decl: type = interface_decl @J [concrete = constants.%J.type] {} {}
  139. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  140. // CHECK:STDOUT: %T.patt: %pattern_type.840 = symbolic_binding_pattern T, 0 [concrete]
  141. // CHECK:STDOUT: %t.patt: @F.%pattern_type (%pattern_type.bd7) = value_binding_pattern t [concrete]
  142. // CHECK:STDOUT: %t.param_patt: @F.%pattern_type (%pattern_type.bd7) = value_param_pattern %t.patt, call_param0 [concrete]
  143. // CHECK:STDOUT: } {
  144. // CHECK:STDOUT: %.loc22_12.1: type = splice_block %.loc22_12.3 [concrete = constants.%facet_type] {
  145. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  146. // CHECK:STDOUT: %I.ref.loc22: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  147. // CHECK:STDOUT: %J.ref.loc22: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  148. // CHECK:STDOUT: %impl.elem0.loc22: %.890 = impl_witness_access constants.%BitAndWith.impl_witness, element0 [concrete = constants.%type.as.BitAndWith.impl.Op]
  149. // CHECK:STDOUT: %bound_method.loc22: <bound method> = bound_method %I.ref.loc22, %impl.elem0.loc22 [concrete = constants.%type.as.BitAndWith.impl.Op.bound]
  150. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.call: init type = call %bound_method.loc22(%I.ref.loc22, %J.ref.loc22) [concrete = constants.%facet_type]
  151. // CHECK:STDOUT: %.loc22_12.2: type = value_of_initializer %type.as.BitAndWith.impl.Op.call [concrete = constants.%facet_type]
  152. // CHECK:STDOUT: %.loc22_12.3: type = converted %type.as.BitAndWith.impl.Op.call, %.loc22_12.2 [concrete = constants.%facet_type]
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT: %T.loc22_6.2: %facet_type = symbolic_binding T, 0 [symbolic = %T.loc22_6.1 (constants.%T)]
  155. // CHECK:STDOUT: %t.param: @F.%T.binding.as_type (%T.binding.as_type) = value_param call_param0
  156. // CHECK:STDOUT: %.loc22_20.1: type = splice_block %.loc22_20.2 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)] {
  157. // CHECK:STDOUT: %T.ref.loc22: %facet_type = name_ref T, %T.loc22_6.2 [symbolic = %T.loc22_6.1 (constants.%T)]
  158. // CHECK:STDOUT: %T.as_type.loc22: type = facet_access_type %T.ref.loc22 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  159. // CHECK:STDOUT: %.loc22_20.2: type = converted %T.ref.loc22, %T.as_type.loc22 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: %t: @F.%T.binding.as_type (%T.binding.as_type) = value_binding t, %t.param
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: interface @I {
  167. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self.ab9]
  168. // CHECK:STDOUT: %I.II.decl: %I.II.type = fn_decl @I.II [concrete = constants.%I.II] {
  169. // CHECK:STDOUT: %self.patt: @I.II.%pattern_type (%pattern_type.fa0) = value_binding_pattern self [concrete]
  170. // CHECK:STDOUT: %self.param_patt: @I.II.%pattern_type (%pattern_type.fa0) = value_param_pattern %self.patt, call_param0 [concrete]
  171. // CHECK:STDOUT: } {
  172. // CHECK:STDOUT: %self.param: @I.II.%Self.binding.as_type (%Self.binding.as_type.d31) = value_param call_param0
  173. // CHECK:STDOUT: %.loc16_15.1: type = splice_block %.loc16_15.2 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)] {
  174. // CHECK:STDOUT: %Self.ref: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self.ab9)]
  175. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.ref [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  176. // CHECK:STDOUT: %.loc16_15.2: type = converted %Self.ref, %Self.as_type [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT: %self: @I.II.%Self.binding.as_type (%Self.binding.as_type.d31) = value_binding self, %self.param
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.II.decl [concrete = constants.%assoc0.b30]
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: !members:
  183. // CHECK:STDOUT: .Self = %Self
  184. // CHECK:STDOUT: .II = %assoc0
  185. // CHECK:STDOUT: .JJ = <poisoned>
  186. // CHECK:STDOUT: .J = <poisoned>
  187. // CHECK:STDOUT: witness = (%I.II.decl)
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: !requires:
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: interface @J {
  193. // CHECK:STDOUT: %Self: %J.type = symbolic_binding Self, 0 [symbolic = constants.%Self.8a1]
  194. // CHECK:STDOUT: %J.JJ.decl: %J.JJ.type = fn_decl @J.JJ [concrete = constants.%J.JJ] {
  195. // CHECK:STDOUT: %self.patt: @J.JJ.%pattern_type (%pattern_type.832) = value_binding_pattern self [concrete]
  196. // CHECK:STDOUT: %self.param_patt: @J.JJ.%pattern_type (%pattern_type.832) = value_param_pattern %self.patt, call_param0 [concrete]
  197. // CHECK:STDOUT: } {
  198. // CHECK:STDOUT: %self.param: @J.JJ.%Self.binding.as_type (%Self.binding.as_type.ed8) = value_param call_param0
  199. // CHECK:STDOUT: %.loc19_15.1: type = splice_block %.loc19_15.2 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.ed8)] {
  200. // CHECK:STDOUT: %Self.ref: %J.type = name_ref Self, @J.%Self [symbolic = %Self (constants.%Self.8a1)]
  201. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.ref [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.ed8)]
  202. // CHECK:STDOUT: %.loc19_15.2: type = converted %Self.ref, %Self.as_type [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.ed8)]
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT: %self: @J.JJ.%Self.binding.as_type (%Self.binding.as_type.ed8) = value_binding self, %self.param
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT: %assoc0: %J.assoc_type = assoc_entity element0, %J.JJ.decl [concrete = constants.%assoc0.d13]
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: !members:
  209. // CHECK:STDOUT: .Self = %Self
  210. // CHECK:STDOUT: .JJ = %assoc0
  211. // CHECK:STDOUT: witness = (%J.JJ.decl)
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: !requires:
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: impl @C.as.I.impl: %Self.ref as %I.ref {
  217. // CHECK:STDOUT: %C.as.I.impl.II.decl: %C.as.I.impl.II.type = fn_decl @C.as.I.impl.II [concrete = constants.%C.as.I.impl.II] {
  218. // CHECK:STDOUT: %self.patt: %pattern_type.893 = value_binding_pattern self [concrete]
  219. // CHECK:STDOUT: %self.param_patt: %pattern_type.893 = value_param_pattern %self.patt, call_param0 [concrete]
  220. // CHECK:STDOUT: } {
  221. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  222. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  223. // CHECK:STDOUT: %self: %C = value_binding self, %self.param
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%C.as.I.impl.II.decl), @C.as.I.impl [concrete]
  226. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: !members:
  229. // CHECK:STDOUT: .II = %C.as.I.impl.II.decl
  230. // CHECK:STDOUT: witness = %I.impl_witness
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: impl @C.as.J.impl: %Self.ref as %J.ref {
  234. // CHECK:STDOUT: %C.as.J.impl.JJ.decl: %C.as.J.impl.JJ.type = fn_decl @C.as.J.impl.JJ [concrete = constants.%C.as.J.impl.JJ] {
  235. // CHECK:STDOUT: %self.patt: %pattern_type.893 = value_binding_pattern self [concrete]
  236. // CHECK:STDOUT: %self.param_patt: %pattern_type.893 = value_param_pattern %self.patt, call_param0 [concrete]
  237. // CHECK:STDOUT: } {
  238. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  239. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  240. // CHECK:STDOUT: %self: %C = value_binding self, %self.param
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT: %J.impl_witness_table = impl_witness_table (%C.as.J.impl.JJ.decl), @C.as.J.impl [concrete]
  243. // CHECK:STDOUT: %J.impl_witness: <witness> = impl_witness %J.impl_witness_table [concrete = constants.%J.impl_witness]
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: !members:
  246. // CHECK:STDOUT: .JJ = %C.as.J.impl.JJ.decl
  247. // CHECK:STDOUT: witness = %J.impl_witness
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: class @C {
  251. // CHECK:STDOUT: impl_decl @C.as.I.impl [concrete] {} {
  252. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  253. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT: impl_decl @C.as.J.impl [concrete] {} {
  256. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  257. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  260. // CHECK:STDOUT: complete_type_witness = %complete_type
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: !members:
  263. // CHECK:STDOUT: .Self = constants.%C
  264. // CHECK:STDOUT: .I = <poisoned>
  265. // CHECK:STDOUT: .J = <poisoned>
  266. // CHECK:STDOUT: .JJ = <poisoned>
  267. // CHECK:STDOUT: extend @C.as.I.impl.%I.ref
  268. // CHECK:STDOUT: extend @C.as.J.impl.%J.ref
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: generic fn @I.II(@I.%Self: %I.type) {
  272. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self.ab9)]
  273. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  274. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type (constants.%pattern_type.fa0)]
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: fn(%self.param: @I.II.%Self.binding.as_type (%Self.binding.as_type.d31));
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: generic fn @J.JJ(@J.%Self: %J.type) {
  280. // CHECK:STDOUT: %Self: %J.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self.8a1)]
  281. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.ed8)]
  282. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type (constants.%pattern_type.832)]
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: fn(%self.param: @J.JJ.%Self.binding.as_type (%Self.binding.as_type.ed8));
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: generic fn @F(%T.loc22_6.2: %facet_type) {
  288. // CHECK:STDOUT: %T.loc22_6.1: %facet_type = symbolic_binding T, 0 [symbolic = %T.loc22_6.1 (constants.%T)]
  289. // CHECK:STDOUT: %T.binding.as_type: type = symbolic_binding_type T, 0, %T.loc22_6.1 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  290. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.binding.as_type [symbolic = %pattern_type (constants.%pattern_type.bd7)]
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: !definition:
  293. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.binding.as_type [symbolic = %require_complete (constants.%require_complete)]
  294. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc22_6.1, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  295. // CHECK:STDOUT: %I.facet.loc26_18.2: %I.type = facet_value %T.binding.as_type, (%I.lookup_impl_witness) [symbolic = %I.facet.loc26_18.2 (constants.%I.facet.990)]
  296. // CHECK:STDOUT: %J.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc22_6.1, @J [symbolic = %J.lookup_impl_witness (constants.%J.lookup_impl_witness)]
  297. // CHECK:STDOUT: %J.facet.loc26_33.2: %J.type = facet_value %T.binding.as_type, (%J.lookup_impl_witness) [symbolic = %J.facet.loc26_33.2 (constants.%J.facet.a3a)]
  298. // CHECK:STDOUT: %.loc26_69: type = fn_type_with_self_type constants.%J.JJ.type, %J.facet.loc26_33.2 [symbolic = %.loc26_69 (constants.%.7eb)]
  299. // CHECK:STDOUT: %impl.elem0.loc26_69.2: @F.%.loc26_69 (%.7eb) = impl_witness_access %J.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc26_69.2 (constants.%impl.elem0)]
  300. // CHECK:STDOUT: %specific_impl_fn.loc26_69.2: <specific function> = specific_impl_function %impl.elem0.loc26_69.2, @J.JJ(%J.facet.loc26_33.2) [symbolic = %specific_impl_fn.loc26_69.2 (constants.%specific_impl_fn)]
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: fn(%t.param: @F.%T.binding.as_type (%T.binding.as_type)) {
  303. // CHECK:STDOUT: !entry:
  304. // CHECK:STDOUT: %t.ref: @F.%T.binding.as_type (%T.binding.as_type) = name_ref t, %t
  305. // CHECK:STDOUT: %T.ref.loc26: %facet_type = name_ref T, %T.loc22_6.2 [symbolic = %T.loc22_6.1 (constants.%T)]
  306. // CHECK:STDOUT: %I.ref.loc26_21: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  307. // CHECK:STDOUT: %T.as_type.loc26: type = facet_access_type %T.ref.loc26 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  308. // CHECK:STDOUT: %I.facet.loc26_18.1: %I.type = facet_value %T.as_type.loc26, (constants.%I.lookup_impl_witness) [symbolic = %I.facet.loc26_18.2 (constants.%I.facet.990)]
  309. // CHECK:STDOUT: %.loc26_18: %I.type = converted %T.ref.loc26, %I.facet.loc26_18.1 [symbolic = %I.facet.loc26_18.2 (constants.%I.facet.990)]
  310. // CHECK:STDOUT: %as_type.loc26_24: type = facet_access_type %.loc26_18 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  311. // CHECK:STDOUT: %.loc26_24: type = converted %.loc26_18, %as_type.loc26_24 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  312. // CHECK:STDOUT: %J.ref.loc26_36: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  313. // CHECK:STDOUT: %J.facet.loc26_33.1: %J.type = facet_value %.loc26_24, (constants.%J.lookup_impl_witness) [symbolic = %J.facet.loc26_33.2 (constants.%J.facet.a3a)]
  314. // CHECK:STDOUT: %.loc26_33: %J.type = converted %.loc26_24, %J.facet.loc26_33.1 [symbolic = %J.facet.loc26_33.2 (constants.%J.facet.a3a)]
  315. // CHECK:STDOUT: %as_type.loc26_39: type = facet_access_type %.loc26_33 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  316. // CHECK:STDOUT: %.loc26_39: type = converted %.loc26_33, %as_type.loc26_39 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  317. // CHECK:STDOUT: %I.ref.loc26_51: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  318. // CHECK:STDOUT: %I.facet.loc26_48: %I.type = facet_value %.loc26_39, (constants.%I.lookup_impl_witness) [symbolic = %I.facet.loc26_18.2 (constants.%I.facet.990)]
  319. // CHECK:STDOUT: %.loc26_48: %I.type = converted %.loc26_39, %I.facet.loc26_48 [symbolic = %I.facet.loc26_18.2 (constants.%I.facet.990)]
  320. // CHECK:STDOUT: %as_type.loc26_54: type = facet_access_type %.loc26_48 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  321. // CHECK:STDOUT: %.loc26_54: type = converted %.loc26_48, %as_type.loc26_54 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  322. // CHECK:STDOUT: %J.ref.loc26_66: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  323. // CHECK:STDOUT: %J.facet.loc26_63: %J.type = facet_value %.loc26_54, (constants.%J.lookup_impl_witness) [symbolic = %J.facet.loc26_33.2 (constants.%J.facet.a3a)]
  324. // CHECK:STDOUT: %.loc26_63: %J.type = converted %.loc26_54, %J.facet.loc26_63 [symbolic = %J.facet.loc26_33.2 (constants.%J.facet.a3a)]
  325. // CHECK:STDOUT: %as_type.loc26_67: type = facet_access_type %.loc26_63 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  326. // CHECK:STDOUT: %.loc26_67: type = converted %.loc26_63, %as_type.loc26_67 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  327. // CHECK:STDOUT: %JJ.ref: %J.assoc_type = name_ref JJ, @J.%assoc0 [concrete = constants.%assoc0.d13]
  328. // CHECK:STDOUT: %impl.elem0.loc26_69.1: @F.%.loc26_69 (%.7eb) = impl_witness_access constants.%J.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc26_69.2 (constants.%impl.elem0)]
  329. // CHECK:STDOUT: %bound_method.loc26_69: <bound method> = bound_method %t.ref, %impl.elem0.loc26_69.1
  330. // CHECK:STDOUT: %specific_impl_fn.loc26_69.1: <specific function> = specific_impl_function %impl.elem0.loc26_69.1, @J.JJ(constants.%J.facet.a3a) [symbolic = %specific_impl_fn.loc26_69.2 (constants.%specific_impl_fn)]
  331. // CHECK:STDOUT: %bound_method.loc26_73: <bound method> = bound_method %t.ref, %specific_impl_fn.loc26_69.1
  332. // CHECK:STDOUT: %J.JJ.call: init %empty_tuple.type = call %bound_method.loc26_73(%t.ref)
  333. // CHECK:STDOUT: return
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: fn @G() {
  338. // CHECK:STDOUT: !entry:
  339. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  340. // CHECK:STDOUT: %.loc40_6.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  341. // CHECK:STDOUT: %C.ref.loc40_11: type = name_ref C, %C.decl [concrete = constants.%C]
  342. // CHECK:STDOUT: %.loc40_6.2: ref %C = temporary_storage
  343. // CHECK:STDOUT: %.loc40_6.3: init %C = class_init (), %.loc40_6.2 [concrete = constants.%C.val]
  344. // CHECK:STDOUT: %.loc40_6.4: ref %C = temporary %.loc40_6.2, %.loc40_6.3
  345. // CHECK:STDOUT: %.loc40_8.1: ref %C = converted %.loc40_6.1, %.loc40_6.4
  346. // CHECK:STDOUT: %C.ref.loc40_24: type = name_ref C, %C.decl [concrete = constants.%C]
  347. // CHECK:STDOUT: %I.ref.loc40_29: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  348. // CHECK:STDOUT: %I.facet.loc40_26: %I.type = facet_value %C.ref.loc40_24, (constants.%I.impl_witness) [concrete = constants.%I.facet.cbf]
  349. // CHECK:STDOUT: %.loc40_26: %I.type = converted %C.ref.loc40_24, %I.facet.loc40_26 [concrete = constants.%I.facet.cbf]
  350. // CHECK:STDOUT: %as_type.loc40_32: type = facet_access_type %.loc40_26 [concrete = constants.%C]
  351. // CHECK:STDOUT: %.loc40_32: type = converted %.loc40_26, %as_type.loc40_32 [concrete = constants.%C]
  352. // CHECK:STDOUT: %J.ref.loc40_44: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  353. // CHECK:STDOUT: %J.facet.loc40_41: %J.type = facet_value %.loc40_32, (constants.%J.impl_witness) [concrete = constants.%J.facet.fc3]
  354. // CHECK:STDOUT: %.loc40_41: %J.type = converted %.loc40_32, %J.facet.loc40_41 [concrete = constants.%J.facet.fc3]
  355. // CHECK:STDOUT: %as_type.loc40_47: type = facet_access_type %.loc40_41 [concrete = constants.%C]
  356. // CHECK:STDOUT: %.loc40_47: type = converted %.loc40_41, %as_type.loc40_47 [concrete = constants.%C]
  357. // CHECK:STDOUT: %I.ref.loc40_59: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  358. // CHECK:STDOUT: %I.facet.loc40_56: %I.type = facet_value %.loc40_47, (constants.%I.impl_witness) [concrete = constants.%I.facet.cbf]
  359. // CHECK:STDOUT: %.loc40_56: %I.type = converted %.loc40_47, %I.facet.loc40_56 [concrete = constants.%I.facet.cbf]
  360. // CHECK:STDOUT: %as_type.loc40_62: type = facet_access_type %.loc40_56 [concrete = constants.%C]
  361. // CHECK:STDOUT: %.loc40_62: type = converted %.loc40_56, %as_type.loc40_62 [concrete = constants.%C]
  362. // CHECK:STDOUT: %J.ref.loc40_74: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  363. // CHECK:STDOUT: %J.facet.loc40_71: %J.type = facet_value %.loc40_62, (constants.%J.impl_witness) [concrete = constants.%J.facet.fc3]
  364. // CHECK:STDOUT: %.loc40_71: %J.type = converted %.loc40_62, %J.facet.loc40_71 [concrete = constants.%J.facet.fc3]
  365. // CHECK:STDOUT: %as_type.loc40_75: type = facet_access_type %.loc40_71 [concrete = constants.%C]
  366. // CHECK:STDOUT: %.loc40_75: type = converted %.loc40_71, %as_type.loc40_75 [concrete = constants.%C]
  367. // CHECK:STDOUT: %JJ.ref: %J.assoc_type = name_ref JJ, @J.%assoc0 [concrete = constants.%assoc0.d13]
  368. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%J.impl_witness, element0 [concrete = constants.%C.as.J.impl.JJ]
  369. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc40_8.1, %impl.elem0
  370. // CHECK:STDOUT: %.loc40_8.2: %C = acquire_value %.loc40_8.1
  371. // CHECK:STDOUT: %C.as.J.impl.JJ.call: init %empty_tuple.type = call %bound_method(%.loc40_8.2)
  372. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  373. // CHECK:STDOUT: %C.ref.loc46_5: type = name_ref C, %C.decl [concrete = constants.%C]
  374. // CHECK:STDOUT: %.loc46_9.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  375. // CHECK:STDOUT: %C.ref.loc46_14: type = name_ref C, %C.decl [concrete = constants.%C]
  376. // CHECK:STDOUT: %.loc46_9.2: ref %C = temporary_storage
  377. // CHECK:STDOUT: %.loc46_9.3: init %C = class_init (), %.loc46_9.2 [concrete = constants.%C.val]
  378. // CHECK:STDOUT: %.loc46_9.4: ref %C = temporary %.loc46_9.2, %.loc46_9.3
  379. // CHECK:STDOUT: %.loc46_11.1: ref %C = converted %.loc46_9.1, %.loc46_9.4
  380. // CHECK:STDOUT: %facet_value.loc46_15.1: %facet_type = facet_value %C.ref.loc46_5, (constants.%I.impl_witness, constants.%J.impl_witness) [concrete = constants.%facet_value]
  381. // CHECK:STDOUT: %.loc46_15.1: %facet_type = converted %C.ref.loc46_5, %facet_value.loc46_15.1 [concrete = constants.%facet_value]
  382. // CHECK:STDOUT: %facet_value.loc46_15.2: %facet_type = facet_value constants.%C, (constants.%I.impl_witness, constants.%J.impl_witness) [concrete = constants.%facet_value]
  383. // CHECK:STDOUT: %.loc46_15.2: %facet_type = converted constants.%C, %facet_value.loc46_15.2 [concrete = constants.%facet_value]
  384. // CHECK:STDOUT: %facet_value.loc46_15.3: %facet_type = facet_value constants.%C, (constants.%I.impl_witness, constants.%J.impl_witness) [concrete = constants.%facet_value]
  385. // CHECK:STDOUT: %.loc46_15.3: %facet_type = converted constants.%C, %facet_value.loc46_15.3 [concrete = constants.%facet_value]
  386. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%facet_value) [concrete = constants.%F.specific_fn]
  387. // CHECK:STDOUT: %.loc46_11.2: %C = acquire_value %.loc46_11.1
  388. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn(%.loc46_11.2)
  389. // CHECK:STDOUT: %DestroyOp.bound.loc46: <bound method> = bound_method %.loc46_9.4, constants.%DestroyOp
  390. // CHECK:STDOUT: %DestroyOp.call.loc46: init %empty_tuple.type = call %DestroyOp.bound.loc46(%.loc46_9.4)
  391. // CHECK:STDOUT: %DestroyOp.bound.loc40: <bound method> = bound_method %.loc40_6.4, constants.%DestroyOp
  392. // CHECK:STDOUT: %DestroyOp.call.loc40: init %empty_tuple.type = call %DestroyOp.bound.loc40(%.loc40_6.4)
  393. // CHECK:STDOUT: return
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: fn @C.as.I.impl.II(%self.param: %C) {
  397. // CHECK:STDOUT: !entry:
  398. // CHECK:STDOUT: return
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: fn @C.as.J.impl.JJ(%self.param: %C) {
  402. // CHECK:STDOUT: !entry:
  403. // CHECK:STDOUT: return
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: fn @DestroyOp(%self.param: %C) = "no_op";
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: specific @I.II(constants.%Self.ab9) {
  409. // CHECK:STDOUT: %Self => constants.%Self.ab9
  410. // CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type.d31
  411. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.fa0
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: specific @J.JJ(constants.%Self.8a1) {
  415. // CHECK:STDOUT: %Self => constants.%Self.8a1
  416. // CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type.ed8
  417. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.832
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: specific @F(constants.%T) {
  421. // CHECK:STDOUT: %T.loc22_6.1 => constants.%T
  422. // CHECK:STDOUT: %T.binding.as_type => constants.%T.binding.as_type
  423. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.bd7
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: specific @J.JJ(constants.%J.facet.a3a) {
  427. // CHECK:STDOUT: %Self => constants.%J.facet.a3a
  428. // CHECK:STDOUT: %Self.binding.as_type => constants.%T.binding.as_type
  429. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.bd7
  430. // CHECK:STDOUT: }
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: specific @I.II(constants.%I.facet.cbf) {
  433. // CHECK:STDOUT: %Self => constants.%I.facet.cbf
  434. // CHECK:STDOUT: %Self.binding.as_type => constants.%C
  435. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.893
  436. // CHECK:STDOUT: }
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: specific @J.JJ(constants.%J.facet.fc3) {
  439. // CHECK:STDOUT: %Self => constants.%J.facet.fc3
  440. // CHECK:STDOUT: %Self.binding.as_type => constants.%C
  441. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.893
  442. // CHECK:STDOUT: }
  443. // CHECK:STDOUT:
  444. // CHECK:STDOUT: specific @F(constants.%facet_value) {
  445. // CHECK:STDOUT: %T.loc22_6.1 => constants.%facet_value
  446. // CHECK:STDOUT: %T.binding.as_type => constants.%C
  447. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.893
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: !definition:
  450. // CHECK:STDOUT: %require_complete => constants.%complete_type
  451. // CHECK:STDOUT: %I.lookup_impl_witness => constants.%I.impl_witness
  452. // CHECK:STDOUT: %I.facet.loc26_18.2 => constants.%I.facet.cbf
  453. // CHECK:STDOUT: %J.lookup_impl_witness => constants.%J.impl_witness
  454. // CHECK:STDOUT: %J.facet.loc26_33.2 => constants.%J.facet.fc3
  455. // CHECK:STDOUT: %.loc26_69 => constants.%.322
  456. // CHECK:STDOUT: %impl.elem0.loc26_69.2 => constants.%C.as.J.impl.JJ
  457. // CHECK:STDOUT: %specific_impl_fn.loc26_69.2 => constants.%C.as.J.impl.JJ
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT: