call_method_on_generic_facet.carbon 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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/function/generic/call_method_on_generic_facet.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/call_method_on_generic_facet.carbon
  14. interface Generic(Scalar:! type) {
  15. fn F();
  16. }
  17. class GenericParam {}
  18. class ImplsGeneric {}
  19. impl ImplsGeneric as Generic(GenericParam) {
  20. fn F() {}
  21. }
  22. interface Other {
  23. fn G();
  24. }
  25. impl ImplsGeneric as Other {
  26. fn G();
  27. }
  28. fn CallGenericMethod(T:! type, U:! Generic(T)) {
  29. U.F();
  30. }
  31. fn G() {
  32. CallGenericMethod(GenericParam, ImplsGeneric);
  33. }
  34. // CHECK:STDOUT: --- call_method_on_generic_facet.carbon
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: constants {
  37. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  38. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  39. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  40. // CHECK:STDOUT: %Scalar: type = symbolic_binding Scalar, 0 [symbolic]
  41. // CHECK:STDOUT: %Generic.type.835: type = generic_interface_type @Generic [concrete]
  42. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  43. // CHECK:STDOUT: %Generic.generic: %Generic.type.835 = struct_value () [concrete]
  44. // CHECK:STDOUT: %Generic.type.03dff7.1: type = facet_type <@Generic, @Generic(%Scalar)> [symbolic]
  45. // CHECK:STDOUT: %Self.15d2d5.1: %Generic.type.03dff7.1 = symbolic_binding Self, 1 [symbolic]
  46. // CHECK:STDOUT: %Generic.WithSelf.F.type.74390a.1: type = fn_type @Generic.WithSelf.F, @Generic.WithSelf(%Scalar, %Self.15d2d5.1) [symbolic]
  47. // CHECK:STDOUT: %Generic.WithSelf.F.baf95a.1: %Generic.WithSelf.F.type.74390a.1 = struct_value () [symbolic]
  48. // CHECK:STDOUT: %Generic.assoc_type.22afda.1: type = assoc_entity_type @Generic, @Generic(%Scalar) [symbolic]
  49. // CHECK:STDOUT: %assoc0.e0dc00.1: %Generic.assoc_type.22afda.1 = assoc_entity element0, @Generic.WithSelf.%Generic.WithSelf.F.decl [symbolic]
  50. // CHECK:STDOUT: %GenericParam: type = class_type @GenericParam [concrete]
  51. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  52. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  53. // CHECK:STDOUT: %ImplsGeneric: type = class_type @ImplsGeneric [concrete]
  54. // CHECK:STDOUT: %Generic.type.498: type = facet_type <@Generic, @Generic(%GenericParam)> [concrete]
  55. // CHECK:STDOUT: %Generic.impl_witness: <witness> = impl_witness @ImplsGeneric.as.Generic.impl.%Generic.impl_witness_table [concrete]
  56. // CHECK:STDOUT: %Self.1f5: %Generic.type.498 = symbolic_binding Self, 1 [symbolic]
  57. // CHECK:STDOUT: %Generic.WithSelf.F.type.a23: type = fn_type @Generic.WithSelf.F, @Generic.WithSelf(%GenericParam, %Self.15d2d5.1) [symbolic]
  58. // CHECK:STDOUT: %Generic.WithSelf.F.fe0: %Generic.WithSelf.F.type.a23 = struct_value () [symbolic]
  59. // CHECK:STDOUT: %Generic.assoc_type.6dc: type = assoc_entity_type @Generic, @Generic(%GenericParam) [concrete]
  60. // CHECK:STDOUT: %assoc0.717: %Generic.assoc_type.6dc = assoc_entity element0, @Generic.WithSelf.%Generic.WithSelf.F.decl [concrete]
  61. // CHECK:STDOUT: %ImplsGeneric.as.Generic.impl.F.type: type = fn_type @ImplsGeneric.as.Generic.impl.F [concrete]
  62. // CHECK:STDOUT: %ImplsGeneric.as.Generic.impl.F: %ImplsGeneric.as.Generic.impl.F.type = struct_value () [concrete]
  63. // CHECK:STDOUT: %Generic.facet: %Generic.type.498 = facet_value %ImplsGeneric, (%Generic.impl_witness) [concrete]
  64. // CHECK:STDOUT: %Generic.WithSelf.F.type.c86: type = fn_type @Generic.WithSelf.F, @Generic.WithSelf(%GenericParam, %Generic.facet) [concrete]
  65. // CHECK:STDOUT: %Generic.WithSelf.F.1fd: %Generic.WithSelf.F.type.c86 = struct_value () [concrete]
  66. // CHECK:STDOUT: %Other.type: type = facet_type <@Other> [concrete]
  67. // CHECK:STDOUT: %Self.8c4: %Other.type = symbolic_binding Self, 0 [symbolic]
  68. // CHECK:STDOUT: %Other.WithSelf.G.type.acd: type = fn_type @Other.WithSelf.G, @Other.WithSelf(%Self.8c4) [symbolic]
  69. // CHECK:STDOUT: %Other.WithSelf.G.63d: %Other.WithSelf.G.type.acd = struct_value () [symbolic]
  70. // CHECK:STDOUT: %Other.assoc_type: type = assoc_entity_type @Other [concrete]
  71. // CHECK:STDOUT: %assoc0.205: %Other.assoc_type = assoc_entity element0, @Other.WithSelf.%Other.WithSelf.G.decl [concrete]
  72. // CHECK:STDOUT: %Other.impl_witness: <witness> = impl_witness @ImplsGeneric.as.Other.impl.%Other.impl_witness_table [concrete]
  73. // CHECK:STDOUT: %ImplsGeneric.as.Other.impl.G.type: type = fn_type @ImplsGeneric.as.Other.impl.G [concrete]
  74. // CHECK:STDOUT: %ImplsGeneric.as.Other.impl.G: %ImplsGeneric.as.Other.impl.G.type = struct_value () [concrete]
  75. // CHECK:STDOUT: %Other.facet: %Other.type = facet_value %ImplsGeneric, (%Other.impl_witness) [concrete]
  76. // CHECK:STDOUT: %Other.WithSelf.G.type.1df: type = fn_type @Other.WithSelf.G, @Other.WithSelf(%Other.facet) [concrete]
  77. // CHECK:STDOUT: %Other.WithSelf.G.13d: %Other.WithSelf.G.type.1df = struct_value () [concrete]
  78. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  79. // CHECK:STDOUT: %Generic.type.03dff7.2: type = facet_type <@Generic, @Generic(%T)> [symbolic]
  80. // CHECK:STDOUT: %pattern_type.c49: type = pattern_type %Generic.type.03dff7.2 [symbolic]
  81. // CHECK:STDOUT: %U: %Generic.type.03dff7.2 = symbolic_binding U, 1 [symbolic]
  82. // CHECK:STDOUT: %CallGenericMethod.type: type = fn_type @CallGenericMethod [concrete]
  83. // CHECK:STDOUT: %CallGenericMethod: %CallGenericMethod.type = struct_value () [concrete]
  84. // CHECK:STDOUT: %Self.15d2d5.2: %Generic.type.03dff7.2 = symbolic_binding Self, 1 [symbolic]
  85. // CHECK:STDOUT: %Generic.WithSelf.F.type.74390a.2: type = fn_type @Generic.WithSelf.F, @Generic.WithSelf(%T, %Self.15d2d5.1) [symbolic]
  86. // CHECK:STDOUT: %Generic.WithSelf.F.baf95a.2: %Generic.WithSelf.F.type.74390a.2 = struct_value () [symbolic]
  87. // CHECK:STDOUT: %Generic.assoc_type.22afda.2: type = assoc_entity_type @Generic, @Generic(%T) [symbolic]
  88. // CHECK:STDOUT: %assoc0.e0dc00.2: %Generic.assoc_type.22afda.2 = assoc_entity element0, @Generic.WithSelf.%Generic.WithSelf.F.decl [symbolic]
  89. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Generic.type.03dff7.2 [symbolic]
  90. // CHECK:STDOUT: %Generic.WithSelf.F.type.56e: type = fn_type @Generic.WithSelf.F, @Generic.WithSelf(%T, %U) [symbolic]
  91. // CHECK:STDOUT: %Generic.WithSelf.F.a99: %Generic.WithSelf.F.type.56e = struct_value () [symbolic]
  92. // CHECK:STDOUT: %U.binding.as_type: type = symbolic_binding_type U, 1, %U [symbolic]
  93. // CHECK:STDOUT: %Generic.lookup_impl_witness: <witness> = lookup_impl_witness %U, @Generic, @Generic(%T) [symbolic]
  94. // CHECK:STDOUT: %.ab3: type = fn_type_with_self_type %Generic.WithSelf.F.type.56e, %U [symbolic]
  95. // CHECK:STDOUT: %impl.elem0: %.ab3 = impl_witness_access %Generic.lookup_impl_witness, element0 [symbolic]
  96. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @Generic.WithSelf.F(%T, %U) [symbolic]
  97. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  98. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  99. // CHECK:STDOUT: %pattern_type.cba: type = pattern_type %Generic.type.498 [concrete]
  100. // CHECK:STDOUT: %CallGenericMethod.specific_fn: <specific function> = specific_function %CallGenericMethod, @CallGenericMethod(%GenericParam, %Generic.facet) [concrete]
  101. // CHECK:STDOUT: %complete_type.57a: <witness> = complete_type_witness %Generic.type.498 [concrete]
  102. // CHECK:STDOUT: %.fcf: type = fn_type_with_self_type %Generic.WithSelf.F.type.c86, %Generic.facet [concrete]
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: imports {
  106. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  107. // CHECK:STDOUT: import Core//prelude
  108. // CHECK:STDOUT: import Core//prelude/...
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: file {
  113. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  114. // CHECK:STDOUT: .Core = imports.%Core
  115. // CHECK:STDOUT: .Generic = %Generic.decl
  116. // CHECK:STDOUT: .GenericParam = %GenericParam.decl
  117. // CHECK:STDOUT: .ImplsGeneric = %ImplsGeneric.decl
  118. // CHECK:STDOUT: .Other = %Other.decl
  119. // CHECK:STDOUT: .CallGenericMethod = %CallGenericMethod.decl
  120. // CHECK:STDOUT: .G = %G.decl
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT: %Core.import = import Core
  123. // CHECK:STDOUT: %Generic.decl: %Generic.type.835 = interface_decl @Generic [concrete = constants.%Generic.generic] {
  124. // CHECK:STDOUT: %Scalar.patt: %pattern_type.98f = symbolic_binding_pattern Scalar, 0 [concrete]
  125. // CHECK:STDOUT: } {
  126. // CHECK:STDOUT: %.loc15_28.1: type = splice_block %.loc15_28.2 [concrete = type] {
  127. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  128. // CHECK:STDOUT: %.loc15_28.2: type = type_literal type [concrete = type]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %Scalar.loc15_25.2: type = symbolic_binding Scalar, 0 [symbolic = %Scalar.loc15_25.1 (constants.%Scalar)]
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT: %GenericParam.decl: type = class_decl @GenericParam [concrete = constants.%GenericParam] {} {}
  133. // CHECK:STDOUT: %ImplsGeneric.decl: type = class_decl @ImplsGeneric [concrete = constants.%ImplsGeneric] {} {}
  134. // CHECK:STDOUT: impl_decl @ImplsGeneric.as.Generic.impl [concrete] {} {
  135. // CHECK:STDOUT: %ImplsGeneric.ref: type = name_ref ImplsGeneric, file.%ImplsGeneric.decl [concrete = constants.%ImplsGeneric]
  136. // CHECK:STDOUT: %Generic.ref: %Generic.type.835 = name_ref Generic, file.%Generic.decl [concrete = constants.%Generic.generic]
  137. // CHECK:STDOUT: %GenericParam.ref: type = name_ref GenericParam, file.%GenericParam.decl [concrete = constants.%GenericParam]
  138. // CHECK:STDOUT: %Generic.type: type = facet_type <@Generic, @Generic(constants.%GenericParam)> [concrete = constants.%Generic.type.498]
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT: %Other.decl: type = interface_decl @Other [concrete = constants.%Other.type] {} {}
  141. // CHECK:STDOUT: impl_decl @ImplsGeneric.as.Other.impl [concrete] {} {
  142. // CHECK:STDOUT: %ImplsGeneric.ref: type = name_ref ImplsGeneric, file.%ImplsGeneric.decl [concrete = constants.%ImplsGeneric]
  143. // CHECK:STDOUT: %Other.ref: type = name_ref Other, file.%Other.decl [concrete = constants.%Other.type]
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %CallGenericMethod.decl: %CallGenericMethod.type = fn_decl @CallGenericMethod [concrete = constants.%CallGenericMethod] {
  146. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  147. // CHECK:STDOUT: %U.patt: @CallGenericMethod.%pattern_type (%pattern_type.c49) = symbolic_binding_pattern U, 1 [concrete]
  148. // CHECK:STDOUT: } {
  149. // CHECK:STDOUT: %.loc33_26.1: type = splice_block %.loc33_26.2 [concrete = type] {
  150. // CHECK:STDOUT: %.Self.2: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  151. // CHECK:STDOUT: %.loc33_26.2: type = type_literal type [concrete = type]
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: %T.loc33_23.2: type = symbolic_binding T, 0 [symbolic = %T.loc33_23.1 (constants.%T)]
  154. // CHECK:STDOUT: %.loc33_45: type = splice_block %Generic.type.loc33_45.2 [symbolic = %Generic.type.loc33_45.1 (constants.%Generic.type.03dff7.2)] {
  155. // CHECK:STDOUT: %.Self.1: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  156. // CHECK:STDOUT: %Generic.ref: %Generic.type.835 = name_ref Generic, file.%Generic.decl [concrete = constants.%Generic.generic]
  157. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc33_23.2 [symbolic = %T.loc33_23.1 (constants.%T)]
  158. // CHECK:STDOUT: %Generic.type.loc33_45.2: type = facet_type <@Generic, @Generic(constants.%T)> [symbolic = %Generic.type.loc33_45.1 (constants.%Generic.type.03dff7.2)]
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT: %U.loc33_33.2: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.03dff7.2) = symbolic_binding U, 1 [symbolic = %U.loc33_33.1 (constants.%U)]
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: generic interface @Generic(%Scalar.loc15_25.2: type) {
  166. // CHECK:STDOUT: %Scalar.loc15_25.1: type = symbolic_binding Scalar, 0 [symbolic = %Scalar.loc15_25.1 (constants.%Scalar)]
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: !definition:
  169. // CHECK:STDOUT: %Generic.type: type = facet_type <@Generic, @Generic(%Scalar.loc15_25.1)> [symbolic = %Generic.type (constants.%Generic.type.03dff7.1)]
  170. // CHECK:STDOUT: %Self.loc15_34.2: @Generic.%Generic.type (%Generic.type.03dff7.1) = symbolic_binding Self, 1 [symbolic = %Self.loc15_34.2 (constants.%Self.15d2d5.1)]
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: interface {
  173. // CHECK:STDOUT: %Self.loc15_34.1: @Generic.%Generic.type (%Generic.type.03dff7.1) = symbolic_binding Self, 1 [symbolic = %Self.loc15_34.2 (constants.%Self.15d2d5.1)]
  174. // CHECK:STDOUT: %Generic.WithSelf.decl = interface_with_self_decl @Generic [concrete]
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: !with Self:
  177. // CHECK:STDOUT: %Generic.WithSelf.F.decl: @Generic.WithSelf.%Generic.WithSelf.F.type (%Generic.WithSelf.F.type.74390a.1) = fn_decl @Generic.WithSelf.F [symbolic = @Generic.WithSelf.%Generic.WithSelf.F (constants.%Generic.WithSelf.F.baf95a.1)] {} {}
  178. // CHECK:STDOUT: %assoc0.loc16_9.1: @Generic.WithSelf.%Generic.assoc_type (%Generic.assoc_type.22afda.1) = assoc_entity element0, %Generic.WithSelf.F.decl [symbolic = %assoc0.loc16_9.2 (constants.%assoc0.e0dc00.1)]
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: !members:
  181. // CHECK:STDOUT: .Self = %Self.loc15_34.1
  182. // CHECK:STDOUT: .F = @Generic.WithSelf.%assoc0.loc16_9.1
  183. // CHECK:STDOUT: witness = (@Generic.WithSelf.%Generic.WithSelf.F.decl)
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: !requires:
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: interface @Other {
  190. // CHECK:STDOUT: %Self: %Other.type = symbolic_binding Self, 0 [symbolic = constants.%Self.8c4]
  191. // CHECK:STDOUT: %Other.WithSelf.decl = interface_with_self_decl @Other [concrete]
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: !with Self:
  194. // CHECK:STDOUT: %Other.WithSelf.G.decl: @Other.WithSelf.%Other.WithSelf.G.type (%Other.WithSelf.G.type.acd) = fn_decl @Other.WithSelf.G [symbolic = @Other.WithSelf.%Other.WithSelf.G (constants.%Other.WithSelf.G.63d)] {} {}
  195. // CHECK:STDOUT: %assoc0: %Other.assoc_type = assoc_entity element0, %Other.WithSelf.G.decl [concrete = constants.%assoc0.205]
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: !members:
  198. // CHECK:STDOUT: .Self = %Self
  199. // CHECK:STDOUT: .G = @Other.WithSelf.%assoc0
  200. // CHECK:STDOUT: witness = (@Other.WithSelf.%Other.WithSelf.G.decl)
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: !requires:
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: impl @ImplsGeneric.as.Generic.impl: %ImplsGeneric.ref as %Generic.type {
  206. // CHECK:STDOUT: %ImplsGeneric.as.Generic.impl.F.decl: %ImplsGeneric.as.Generic.impl.F.type = fn_decl @ImplsGeneric.as.Generic.impl.F [concrete = constants.%ImplsGeneric.as.Generic.impl.F] {} {}
  207. // CHECK:STDOUT: %Generic.impl_witness_table = impl_witness_table (%ImplsGeneric.as.Generic.impl.F.decl), @ImplsGeneric.as.Generic.impl [concrete]
  208. // CHECK:STDOUT: %Generic.impl_witness: <witness> = impl_witness %Generic.impl_witness_table [concrete = constants.%Generic.impl_witness]
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: !members:
  211. // CHECK:STDOUT: .F = %ImplsGeneric.as.Generic.impl.F.decl
  212. // CHECK:STDOUT: witness = %Generic.impl_witness
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: impl @ImplsGeneric.as.Other.impl: %ImplsGeneric.ref as %Other.ref {
  216. // CHECK:STDOUT: %ImplsGeneric.as.Other.impl.G.decl: %ImplsGeneric.as.Other.impl.G.type = fn_decl @ImplsGeneric.as.Other.impl.G [concrete = constants.%ImplsGeneric.as.Other.impl.G] {} {}
  217. // CHECK:STDOUT: %Other.impl_witness_table = impl_witness_table (%ImplsGeneric.as.Other.impl.G.decl), @ImplsGeneric.as.Other.impl [concrete]
  218. // CHECK:STDOUT: %Other.impl_witness: <witness> = impl_witness %Other.impl_witness_table [concrete = constants.%Other.impl_witness]
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: !members:
  221. // CHECK:STDOUT: .G = %ImplsGeneric.as.Other.impl.G.decl
  222. // CHECK:STDOUT: witness = %Other.impl_witness
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: class @GenericParam {
  226. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  227. // CHECK:STDOUT: complete_type_witness = %complete_type
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: !members:
  230. // CHECK:STDOUT: .Self = constants.%GenericParam
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: class @ImplsGeneric {
  234. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  235. // CHECK:STDOUT: complete_type_witness = %complete_type
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: !members:
  238. // CHECK:STDOUT: .Self = constants.%ImplsGeneric
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: generic fn @Generic.WithSelf.F(@Generic.%Scalar.loc15_25.2: type, @Generic.%Self.loc15_34.1: @Generic.%Generic.type (%Generic.type.03dff7.1)) {
  242. // CHECK:STDOUT: fn();
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: fn @ImplsGeneric.as.Generic.impl.F() {
  246. // CHECK:STDOUT: !entry:
  247. // CHECK:STDOUT: return
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: generic fn @Other.WithSelf.G(@Other.%Self: %Other.type) {
  251. // CHECK:STDOUT: fn();
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: fn @ImplsGeneric.as.Other.impl.G();
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: generic fn @CallGenericMethod(%T.loc33_23.2: type, %U.loc33_33.2: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.03dff7.2)) {
  257. // CHECK:STDOUT: %T.loc33_23.1: type = symbolic_binding T, 0 [symbolic = %T.loc33_23.1 (constants.%T)]
  258. // CHECK:STDOUT: %Generic.type.loc33_45.1: type = facet_type <@Generic, @Generic(%T.loc33_23.1)> [symbolic = %Generic.type.loc33_45.1 (constants.%Generic.type.03dff7.2)]
  259. // CHECK:STDOUT: %U.loc33_33.1: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.03dff7.2) = symbolic_binding U, 1 [symbolic = %U.loc33_33.1 (constants.%U)]
  260. // CHECK:STDOUT: %pattern_type: type = pattern_type %Generic.type.loc33_45.1 [symbolic = %pattern_type (constants.%pattern_type.c49)]
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: !definition:
  263. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Generic.type.loc33_45.1 [symbolic = %require_complete (constants.%require_complete)]
  264. // CHECK:STDOUT: %U.binding.as_type: type = symbolic_binding_type U, 1, %U.loc33_33.1 [symbolic = %U.binding.as_type (constants.%U.binding.as_type)]
  265. // CHECK:STDOUT: %Generic.assoc_type: type = assoc_entity_type @Generic, @Generic(%T.loc33_23.1) [symbolic = %Generic.assoc_type (constants.%Generic.assoc_type.22afda.2)]
  266. // CHECK:STDOUT: %assoc0: @CallGenericMethod.%Generic.assoc_type (%Generic.assoc_type.22afda.2) = assoc_entity element0, @Generic.WithSelf.%Generic.WithSelf.F.decl [symbolic = %assoc0 (constants.%assoc0.e0dc00.2)]
  267. // CHECK:STDOUT: %Generic.WithSelf.F.type: type = fn_type @Generic.WithSelf.F, @Generic.WithSelf(%T.loc33_23.1, %U.loc33_33.1) [symbolic = %Generic.WithSelf.F.type (constants.%Generic.WithSelf.F.type.56e)]
  268. // CHECK:STDOUT: %.loc34_4.3: type = fn_type_with_self_type %Generic.WithSelf.F.type, %U.loc33_33.1 [symbolic = %.loc34_4.3 (constants.%.ab3)]
  269. // CHECK:STDOUT: %Generic.lookup_impl_witness: <witness> = lookup_impl_witness %U.loc33_33.1, @Generic, @Generic(%T.loc33_23.1) [symbolic = %Generic.lookup_impl_witness (constants.%Generic.lookup_impl_witness)]
  270. // CHECK:STDOUT: %impl.elem0.loc34_4.2: @CallGenericMethod.%.loc34_4.3 (%.ab3) = impl_witness_access %Generic.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0)]
  271. // CHECK:STDOUT: %specific_impl_fn.loc34_4.2: <specific function> = specific_impl_function %impl.elem0.loc34_4.2, @Generic.WithSelf.F(%T.loc33_23.1, %U.loc33_33.1) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn)]
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: fn() {
  274. // CHECK:STDOUT: !entry:
  275. // CHECK:STDOUT: %U.ref: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.03dff7.2) = name_ref U, %U.loc33_33.2 [symbolic = %U.loc33_33.1 (constants.%U)]
  276. // CHECK:STDOUT: %U.as_type: type = facet_access_type %U.ref [symbolic = %U.binding.as_type (constants.%U.binding.as_type)]
  277. // CHECK:STDOUT: %.loc34_4.1: type = converted %U.ref, %U.as_type [symbolic = %U.binding.as_type (constants.%U.binding.as_type)]
  278. // CHECK:STDOUT: %.loc34_4.2: @CallGenericMethod.%Generic.assoc_type (%Generic.assoc_type.22afda.2) = specific_constant @Generic.WithSelf.%assoc0.loc16_9.1, @Generic.WithSelf(constants.%T, constants.%U) [symbolic = %assoc0 (constants.%assoc0.e0dc00.2)]
  279. // CHECK:STDOUT: %F.ref: @CallGenericMethod.%Generic.assoc_type (%Generic.assoc_type.22afda.2) = name_ref F, %.loc34_4.2 [symbolic = %assoc0 (constants.%assoc0.e0dc00.2)]
  280. // CHECK:STDOUT: %impl.elem0.loc34_4.1: @CallGenericMethod.%.loc34_4.3 (%.ab3) = impl_witness_access constants.%Generic.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0)]
  281. // CHECK:STDOUT: %specific_impl_fn.loc34_4.1: <specific function> = specific_impl_function %impl.elem0.loc34_4.1, @Generic.WithSelf.F(constants.%T, constants.%U) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn)]
  282. // CHECK:STDOUT: %Generic.WithSelf.F.call: init %empty_tuple.type = call %specific_impl_fn.loc34_4.1()
  283. // CHECK:STDOUT: return
  284. // CHECK:STDOUT: }
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: fn @G() {
  288. // CHECK:STDOUT: !entry:
  289. // CHECK:STDOUT: %CallGenericMethod.ref: %CallGenericMethod.type = name_ref CallGenericMethod, file.%CallGenericMethod.decl [concrete = constants.%CallGenericMethod]
  290. // CHECK:STDOUT: %GenericParam.ref: type = name_ref GenericParam, file.%GenericParam.decl [concrete = constants.%GenericParam]
  291. // CHECK:STDOUT: %ImplsGeneric.ref: type = name_ref ImplsGeneric, file.%ImplsGeneric.decl [concrete = constants.%ImplsGeneric]
  292. // CHECK:STDOUT: %Generic.facet: %Generic.type.498 = facet_value constants.%ImplsGeneric, (constants.%Generic.impl_witness) [concrete = constants.%Generic.facet]
  293. // CHECK:STDOUT: %.loc38: %Generic.type.498 = converted constants.%ImplsGeneric, %Generic.facet [concrete = constants.%Generic.facet]
  294. // CHECK:STDOUT: %CallGenericMethod.specific_fn: <specific function> = specific_function %CallGenericMethod.ref, @CallGenericMethod(constants.%GenericParam, constants.%Generic.facet) [concrete = constants.%CallGenericMethod.specific_fn]
  295. // CHECK:STDOUT: %CallGenericMethod.call: init %empty_tuple.type = call %CallGenericMethod.specific_fn()
  296. // CHECK:STDOUT: return
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: specific @Generic(constants.%Scalar) {
  300. // CHECK:STDOUT: %Scalar.loc15_25.1 => constants.%Scalar
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: specific @Generic.WithSelf(constants.%Scalar, constants.%Self.15d2d5.1) {}
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: specific @Generic.WithSelf.F(constants.%Scalar, constants.%Self.15d2d5.1) {}
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: specific @Generic(constants.%GenericParam) {
  308. // CHECK:STDOUT: %Scalar.loc15_25.1 => constants.%GenericParam
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: !definition:
  311. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.498
  312. // CHECK:STDOUT: %Self.loc15_34.2 => constants.%Self.1f5
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: specific @Generic.WithSelf(constants.%GenericParam, constants.%Self.15d2d5.1) {
  316. // CHECK:STDOUT: !definition:
  317. // CHECK:STDOUT: %Scalar => constants.%GenericParam
  318. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.498
  319. // CHECK:STDOUT: %Self => constants.%Self.15d2d5.1
  320. // CHECK:STDOUT: %Generic.WithSelf.F.type => constants.%Generic.WithSelf.F.type.a23
  321. // CHECK:STDOUT: %Generic.WithSelf.F => constants.%Generic.WithSelf.F.fe0
  322. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.6dc
  323. // CHECK:STDOUT: %assoc0.loc16_9.2 => constants.%assoc0.717
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: specific @Generic.WithSelf(constants.%GenericParam, constants.%Generic.facet) {
  327. // CHECK:STDOUT: !definition:
  328. // CHECK:STDOUT: %Scalar => constants.%GenericParam
  329. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.498
  330. // CHECK:STDOUT: %Self => constants.%Generic.facet
  331. // CHECK:STDOUT: %Generic.WithSelf.F.type => constants.%Generic.WithSelf.F.type.c86
  332. // CHECK:STDOUT: %Generic.WithSelf.F => constants.%Generic.WithSelf.F.1fd
  333. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.6dc
  334. // CHECK:STDOUT: %assoc0.loc16_9.2 => constants.%assoc0.717
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: specific @Generic.WithSelf.F(constants.%GenericParam, constants.%Generic.facet) {}
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: specific @Other.WithSelf(constants.%Self.8c4) {
  340. // CHECK:STDOUT: !definition:
  341. // CHECK:STDOUT: %Self => constants.%Self.8c4
  342. // CHECK:STDOUT: %Other.WithSelf.G.type => constants.%Other.WithSelf.G.type.acd
  343. // CHECK:STDOUT: %Other.WithSelf.G => constants.%Other.WithSelf.G.63d
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: specific @Other.WithSelf.G(constants.%Self.8c4) {}
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: specific @Other.WithSelf(constants.%Other.facet) {
  349. // CHECK:STDOUT: !definition:
  350. // CHECK:STDOUT: %Self => constants.%Other.facet
  351. // CHECK:STDOUT: %Other.WithSelf.G.type => constants.%Other.WithSelf.G.type.1df
  352. // CHECK:STDOUT: %Other.WithSelf.G => constants.%Other.WithSelf.G.13d
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: specific @Other.WithSelf.G(constants.%Other.facet) {}
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: specific @Generic(constants.%T) {
  358. // CHECK:STDOUT: %Scalar.loc15_25.1 => constants.%T
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: !definition:
  361. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.03dff7.2
  362. // CHECK:STDOUT: %Self.loc15_34.2 => constants.%Self.15d2d5.2
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: specific @CallGenericMethod(constants.%T, constants.%U) {
  366. // CHECK:STDOUT: %T.loc33_23.1 => constants.%T
  367. // CHECK:STDOUT: %Generic.type.loc33_45.1 => constants.%Generic.type.03dff7.2
  368. // CHECK:STDOUT: %U.loc33_33.1 => constants.%U
  369. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.c49
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: specific @Generic.WithSelf(constants.%T, constants.%Self.15d2d5.1) {
  373. // CHECK:STDOUT: !definition:
  374. // CHECK:STDOUT: %Scalar => constants.%T
  375. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.03dff7.2
  376. // CHECK:STDOUT: %Self => constants.%Self.15d2d5.1
  377. // CHECK:STDOUT: %Generic.WithSelf.F.type => constants.%Generic.WithSelf.F.type.74390a.2
  378. // CHECK:STDOUT: %Generic.WithSelf.F => constants.%Generic.WithSelf.F.baf95a.2
  379. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.22afda.2
  380. // CHECK:STDOUT: %assoc0.loc16_9.2 => constants.%assoc0.e0dc00.2
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: specific @Generic.WithSelf(constants.%T, constants.%U) {
  384. // CHECK:STDOUT: !definition:
  385. // CHECK:STDOUT: %Scalar => constants.%T
  386. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.03dff7.2
  387. // CHECK:STDOUT: %Self => constants.%U
  388. // CHECK:STDOUT: %Generic.WithSelf.F.type => constants.%Generic.WithSelf.F.type.56e
  389. // CHECK:STDOUT: %Generic.WithSelf.F => constants.%Generic.WithSelf.F.a99
  390. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.22afda.2
  391. // CHECK:STDOUT: %assoc0.loc16_9.2 => constants.%assoc0.e0dc00.2
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: specific @Generic.WithSelf.F(constants.%T, constants.%U) {}
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: specific @CallGenericMethod(constants.%GenericParam, constants.%Generic.facet) {
  397. // CHECK:STDOUT: %T.loc33_23.1 => constants.%GenericParam
  398. // CHECK:STDOUT: %Generic.type.loc33_45.1 => constants.%Generic.type.498
  399. // CHECK:STDOUT: %U.loc33_33.1 => constants.%Generic.facet
  400. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.cba
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: !definition:
  403. // CHECK:STDOUT: %require_complete => constants.%complete_type.57a
  404. // CHECK:STDOUT: %U.binding.as_type => constants.%ImplsGeneric
  405. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.6dc
  406. // CHECK:STDOUT: %assoc0 => constants.%assoc0.717
  407. // CHECK:STDOUT: %Generic.WithSelf.F.type => constants.%Generic.WithSelf.F.type.c86
  408. // CHECK:STDOUT: %.loc34_4.3 => constants.%.fcf
  409. // CHECK:STDOUT: %Generic.lookup_impl_witness => constants.%Generic.impl_witness
  410. // CHECK:STDOUT: %impl.elem0.loc34_4.2 => constants.%ImplsGeneric.as.Generic.impl.F
  411. // CHECK:STDOUT: %specific_impl_fn.loc34_4.2 => constants.%ImplsGeneric.as.Generic.impl.F
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT: