call_method_on_generic_facet.carbon 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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 = bind_symbolic_name .Self [symbolic_self]
  39. // CHECK:STDOUT: %Scalar: type = bind_symbolic_name Scalar, 0 [symbolic]
  40. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  41. // CHECK:STDOUT: %Generic.type.c21: type = generic_interface_type @Generic [concrete]
  42. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  43. // CHECK:STDOUT: %Generic.generic: %Generic.type.c21 = struct_value () [concrete]
  44. // CHECK:STDOUT: %Generic.type.4045f4.1: type = facet_type <@Generic, @Generic(%Scalar)> [symbolic]
  45. // CHECK:STDOUT: %Self.f48852.1: %Generic.type.4045f4.1 = bind_symbolic_name Self, 1 [symbolic]
  46. // CHECK:STDOUT: %Generic.F.type.f439a9.1: type = fn_type @Generic.F, @Generic(%Scalar) [symbolic]
  47. // CHECK:STDOUT: %Generic.F.8a2d67.1: %Generic.F.type.f439a9.1 = struct_value () [symbolic]
  48. // CHECK:STDOUT: %Generic.assoc_type.0fd877.1: type = assoc_entity_type @Generic, @Generic(%Scalar) [symbolic]
  49. // CHECK:STDOUT: %assoc0.2966cb.1: %Generic.assoc_type.0fd877.1 = assoc_entity element0, @Generic.%Generic.F.decl [symbolic]
  50. // CHECK:STDOUT: %GenericParam: type = class_type @GenericParam [concrete]
  51. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  52. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  53. // CHECK:STDOUT: %Destroy.impl_witness.7e7: <witness> = impl_witness @GenericParam.%Destroy.impl_witness_table [concrete]
  54. // CHECK:STDOUT: %ptr.f73: type = ptr_type %GenericParam [concrete]
  55. // CHECK:STDOUT: %pattern_type.7c3: type = pattern_type %ptr.f73 [concrete]
  56. // CHECK:STDOUT: %GenericParam.as.Destroy.impl.Op.type: type = fn_type @GenericParam.as.Destroy.impl.Op [concrete]
  57. // CHECK:STDOUT: %GenericParam.as.Destroy.impl.Op: %GenericParam.as.Destroy.impl.Op.type = struct_value () [concrete]
  58. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  59. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  60. // CHECK:STDOUT: %ImplsGeneric: type = class_type @ImplsGeneric [concrete]
  61. // CHECK:STDOUT: %Destroy.impl_witness.813: <witness> = impl_witness @ImplsGeneric.%Destroy.impl_witness_table [concrete]
  62. // CHECK:STDOUT: %ptr.011: type = ptr_type %ImplsGeneric [concrete]
  63. // CHECK:STDOUT: %pattern_type.2db: type = pattern_type %ptr.011 [concrete]
  64. // CHECK:STDOUT: %ImplsGeneric.as.Destroy.impl.Op.type: type = fn_type @ImplsGeneric.as.Destroy.impl.Op [concrete]
  65. // CHECK:STDOUT: %ImplsGeneric.as.Destroy.impl.Op: %ImplsGeneric.as.Destroy.impl.Op.type = struct_value () [concrete]
  66. // CHECK:STDOUT: %Generic.type.cfe: type = facet_type <@Generic, @Generic(%GenericParam)> [concrete]
  67. // CHECK:STDOUT: %Self.b8f: %Generic.type.cfe = bind_symbolic_name Self, 1 [symbolic]
  68. // CHECK:STDOUT: %Generic.F.type.4cf: type = fn_type @Generic.F, @Generic(%GenericParam) [concrete]
  69. // CHECK:STDOUT: %Generic.F.118: %Generic.F.type.4cf = struct_value () [concrete]
  70. // CHECK:STDOUT: %Generic.assoc_type.713: type = assoc_entity_type @Generic, @Generic(%GenericParam) [concrete]
  71. // CHECK:STDOUT: %assoc0.9b7: %Generic.assoc_type.713 = assoc_entity element0, @Generic.%Generic.F.decl [concrete]
  72. // CHECK:STDOUT: %Generic.impl_witness: <witness> = impl_witness file.%Generic.impl_witness_table [concrete]
  73. // CHECK:STDOUT: %ImplsGeneric.as.Generic.impl.F.type: type = fn_type @ImplsGeneric.as.Generic.impl.F [concrete]
  74. // CHECK:STDOUT: %ImplsGeneric.as.Generic.impl.F: %ImplsGeneric.as.Generic.impl.F.type = struct_value () [concrete]
  75. // CHECK:STDOUT: %Generic.facet.924: %Generic.type.cfe = facet_value %ImplsGeneric, (%Generic.impl_witness) [concrete]
  76. // CHECK:STDOUT: %Other.type: type = facet_type <@Other> [concrete]
  77. // CHECK:STDOUT: %Self.939: %Other.type = bind_symbolic_name Self, 0 [symbolic]
  78. // CHECK:STDOUT: %Other.G.type: type = fn_type @Other.G [concrete]
  79. // CHECK:STDOUT: %Other.G: %Other.G.type = struct_value () [concrete]
  80. // CHECK:STDOUT: %Other.assoc_type: type = assoc_entity_type @Other [concrete]
  81. // CHECK:STDOUT: %assoc0.25d: %Other.assoc_type = assoc_entity element0, @Other.%Other.G.decl [concrete]
  82. // CHECK:STDOUT: %Other.impl_witness: <witness> = impl_witness file.%Other.impl_witness_table [concrete]
  83. // CHECK:STDOUT: %ImplsGeneric.as.Other.impl.G.type: type = fn_type @ImplsGeneric.as.Other.impl.G [concrete]
  84. // CHECK:STDOUT: %ImplsGeneric.as.Other.impl.G: %ImplsGeneric.as.Other.impl.G.type = struct_value () [concrete]
  85. // CHECK:STDOUT: %Other.facet: %Other.type = facet_value %ImplsGeneric, (%Other.impl_witness) [concrete]
  86. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  87. // CHECK:STDOUT: %Generic.type.4045f4.2: type = facet_type <@Generic, @Generic(%T)> [symbolic]
  88. // CHECK:STDOUT: %U: %Generic.type.4045f4.2 = bind_symbolic_name U, 1 [symbolic]
  89. // CHECK:STDOUT: %pattern_type.3c6: type = pattern_type %Generic.type.4045f4.2 [symbolic]
  90. // CHECK:STDOUT: %CallGenericMethod.type: type = fn_type @CallGenericMethod [concrete]
  91. // CHECK:STDOUT: %CallGenericMethod: %CallGenericMethod.type = struct_value () [concrete]
  92. // CHECK:STDOUT: %Self.f48852.2: %Generic.type.4045f4.2 = bind_symbolic_name Self, 1 [symbolic]
  93. // CHECK:STDOUT: %Generic.F.type.f439a9.2: type = fn_type @Generic.F, @Generic(%T) [symbolic]
  94. // CHECK:STDOUT: %Generic.F.8a2d67.2: %Generic.F.type.f439a9.2 = struct_value () [symbolic]
  95. // CHECK:STDOUT: %Generic.assoc_type.0fd877.2: type = assoc_entity_type @Generic, @Generic(%T) [symbolic]
  96. // CHECK:STDOUT: %assoc0.2966cb.2: %Generic.assoc_type.0fd877.2 = assoc_entity element0, @Generic.%Generic.F.decl [symbolic]
  97. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Generic.type.4045f4.2 [symbolic]
  98. // CHECK:STDOUT: %U.as_type: type = facet_access_type %U [symbolic]
  99. // CHECK:STDOUT: %Generic.lookup_impl_witness: <witness> = lookup_impl_witness %U, @Generic, @Generic(%T) [symbolic]
  100. // CHECK:STDOUT: %Generic.facet.049: %Generic.type.4045f4.2 = facet_value %U.as_type, (%Generic.lookup_impl_witness) [symbolic]
  101. // CHECK:STDOUT: %.1bd: type = fn_type_with_self_type %Generic.F.type.f439a9.2, %Generic.facet.049 [symbolic]
  102. // CHECK:STDOUT: %impl.elem0: %.1bd = impl_witness_access %Generic.lookup_impl_witness, element0 [symbolic]
  103. // CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @Generic.F(%T, %Generic.facet.049) [symbolic]
  104. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  105. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  106. // CHECK:STDOUT: %pattern_type.bd9: type = pattern_type %Generic.type.cfe [concrete]
  107. // CHECK:STDOUT: %CallGenericMethod.specific_fn: <specific function> = specific_function %CallGenericMethod, @CallGenericMethod(%GenericParam, %Generic.facet.924) [concrete]
  108. // CHECK:STDOUT: %complete_type.10d: <witness> = complete_type_witness %Generic.type.cfe [concrete]
  109. // CHECK:STDOUT: %.e21: type = fn_type_with_self_type %Generic.F.type.4cf, %Generic.facet.924 [concrete]
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: imports {
  113. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  114. // CHECK:STDOUT: .Destroy = %Core.Destroy
  115. // CHECK:STDOUT: import Core//prelude
  116. // CHECK:STDOUT: import Core//prelude/...
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: file {
  122. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  123. // CHECK:STDOUT: .Core = imports.%Core
  124. // CHECK:STDOUT: .Generic = %Generic.decl
  125. // CHECK:STDOUT: .GenericParam = %GenericParam.decl
  126. // CHECK:STDOUT: .ImplsGeneric = %ImplsGeneric.decl
  127. // CHECK:STDOUT: .Other = %Other.decl
  128. // CHECK:STDOUT: .CallGenericMethod = %CallGenericMethod.decl
  129. // CHECK:STDOUT: .G = %G.decl
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %Core.import = import Core
  132. // CHECK:STDOUT: %Generic.decl: %Generic.type.c21 = interface_decl @Generic [concrete = constants.%Generic.generic] {
  133. // CHECK:STDOUT: %Scalar.patt: %pattern_type.98f = symbolic_binding_pattern Scalar, 0 [concrete]
  134. // CHECK:STDOUT: } {
  135. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  136. // CHECK:STDOUT: %Scalar.loc15_19.2: type = bind_symbolic_name Scalar, 0 [symbolic = %Scalar.loc15_19.1 (constants.%Scalar)]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: %GenericParam.decl: type = class_decl @GenericParam [concrete = constants.%GenericParam] {} {}
  139. // CHECK:STDOUT: %ImplsGeneric.decl: type = class_decl @ImplsGeneric [concrete = constants.%ImplsGeneric] {} {}
  140. // CHECK:STDOUT: impl_decl @ImplsGeneric.as.Generic.impl [concrete] {} {
  141. // CHECK:STDOUT: %ImplsGeneric.ref: type = name_ref ImplsGeneric, file.%ImplsGeneric.decl [concrete = constants.%ImplsGeneric]
  142. // CHECK:STDOUT: %Generic.ref: %Generic.type.c21 = name_ref Generic, file.%Generic.decl [concrete = constants.%Generic.generic]
  143. // CHECK:STDOUT: %GenericParam.ref: type = name_ref GenericParam, file.%GenericParam.decl [concrete = constants.%GenericParam]
  144. // CHECK:STDOUT: %Generic.type: type = facet_type <@Generic, @Generic(constants.%GenericParam)> [concrete = constants.%Generic.type.cfe]
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: %Generic.impl_witness_table = impl_witness_table (@ImplsGeneric.as.Generic.impl.%ImplsGeneric.as.Generic.impl.F.decl), @ImplsGeneric.as.Generic.impl [concrete]
  147. // CHECK:STDOUT: %Generic.impl_witness: <witness> = impl_witness %Generic.impl_witness_table [concrete = constants.%Generic.impl_witness]
  148. // CHECK:STDOUT: %Other.decl: type = interface_decl @Other [concrete = constants.%Other.type] {} {}
  149. // CHECK:STDOUT: impl_decl @ImplsGeneric.as.Other.impl [concrete] {} {
  150. // CHECK:STDOUT: %ImplsGeneric.ref: type = name_ref ImplsGeneric, file.%ImplsGeneric.decl [concrete = constants.%ImplsGeneric]
  151. // CHECK:STDOUT: %Other.ref: type = name_ref Other, file.%Other.decl [concrete = constants.%Other.type]
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: %Other.impl_witness_table = impl_witness_table (@ImplsGeneric.as.Other.impl.%ImplsGeneric.as.Other.impl.G.decl), @ImplsGeneric.as.Other.impl [concrete]
  154. // CHECK:STDOUT: %Other.impl_witness: <witness> = impl_witness %Other.impl_witness_table [concrete = constants.%Other.impl_witness]
  155. // CHECK:STDOUT: %CallGenericMethod.decl: %CallGenericMethod.type = fn_decl @CallGenericMethod [concrete = constants.%CallGenericMethod] {
  156. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  157. // CHECK:STDOUT: %U.patt: @CallGenericMethod.%pattern_type (%pattern_type.3c6) = symbolic_binding_pattern U, 1 [concrete]
  158. // CHECK:STDOUT: } {
  159. // CHECK:STDOUT: %.Self.1: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  160. // CHECK:STDOUT: %T.loc33_22.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc33_22.1 (constants.%T)]
  161. // CHECK:STDOUT: %.loc33: type = splice_block %Generic.type.loc33_45.2 [symbolic = %Generic.type.loc33_45.1 (constants.%Generic.type.4045f4.2)] {
  162. // CHECK:STDOUT: %.Self.2: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  163. // CHECK:STDOUT: %Generic.ref: %Generic.type.c21 = name_ref Generic, file.%Generic.decl [concrete = constants.%Generic.generic]
  164. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc33_22.2 [symbolic = %T.loc33_22.1 (constants.%T)]
  165. // CHECK:STDOUT: %Generic.type.loc33_45.2: type = facet_type <@Generic, @Generic(constants.%T)> [symbolic = %Generic.type.loc33_45.1 (constants.%Generic.type.4045f4.2)]
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT: %U.loc33_32.2: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.4045f4.2) = bind_symbolic_name U, 1 [symbolic = %U.loc33_32.1 (constants.%U)]
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: generic interface @Generic(%Scalar.loc15_19.2: type) {
  173. // CHECK:STDOUT: %Scalar.loc15_19.1: type = bind_symbolic_name Scalar, 0 [symbolic = %Scalar.loc15_19.1 (constants.%Scalar)]
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: !definition:
  176. // CHECK:STDOUT: %Generic.type: type = facet_type <@Generic, @Generic(%Scalar.loc15_19.1)> [symbolic = %Generic.type (constants.%Generic.type.4045f4.1)]
  177. // CHECK:STDOUT: %Self.2: @Generic.%Generic.type (%Generic.type.4045f4.1) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.f48852.1)]
  178. // CHECK:STDOUT: %Generic.F.type: type = fn_type @Generic.F, @Generic(%Scalar.loc15_19.1) [symbolic = %Generic.F.type (constants.%Generic.F.type.f439a9.1)]
  179. // CHECK:STDOUT: %Generic.F: @Generic.%Generic.F.type (%Generic.F.type.f439a9.1) = struct_value () [symbolic = %Generic.F (constants.%Generic.F.8a2d67.1)]
  180. // CHECK:STDOUT: %Generic.assoc_type: type = assoc_entity_type @Generic, @Generic(%Scalar.loc15_19.1) [symbolic = %Generic.assoc_type (constants.%Generic.assoc_type.0fd877.1)]
  181. // CHECK:STDOUT: %assoc0.loc16_9.2: @Generic.%Generic.assoc_type (%Generic.assoc_type.0fd877.1) = assoc_entity element0, %Generic.F.decl [symbolic = %assoc0.loc16_9.2 (constants.%assoc0.2966cb.1)]
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: interface {
  184. // CHECK:STDOUT: %Self.1: @Generic.%Generic.type (%Generic.type.4045f4.1) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.f48852.1)]
  185. // CHECK:STDOUT: %Generic.F.decl: @Generic.%Generic.F.type (%Generic.F.type.f439a9.1) = fn_decl @Generic.F [symbolic = @Generic.%Generic.F (constants.%Generic.F.8a2d67.1)] {} {}
  186. // CHECK:STDOUT: %assoc0.loc16_9.1: @Generic.%Generic.assoc_type (%Generic.assoc_type.0fd877.1) = assoc_entity element0, %Generic.F.decl [symbolic = %assoc0.loc16_9.2 (constants.%assoc0.2966cb.1)]
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !members:
  189. // CHECK:STDOUT: .Self = %Self.1
  190. // CHECK:STDOUT: .F = %assoc0.loc16_9.1
  191. // CHECK:STDOUT: witness = (%Generic.F.decl)
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: interface @Other {
  196. // CHECK:STDOUT: %Self: %Other.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.939]
  197. // CHECK:STDOUT: %Other.G.decl: %Other.G.type = fn_decl @Other.G [concrete = constants.%Other.G] {} {}
  198. // CHECK:STDOUT: %assoc0: %Other.assoc_type = assoc_entity element0, %Other.G.decl [concrete = constants.%assoc0.25d]
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: !members:
  201. // CHECK:STDOUT: .Self = %Self
  202. // CHECK:STDOUT: .G = %assoc0
  203. // CHECK:STDOUT: witness = (%Other.G.decl)
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: impl @GenericParam.as.Destroy.impl: @GenericParam.%Self.ref as constants.%Destroy.type {
  207. // CHECK:STDOUT: %GenericParam.as.Destroy.impl.Op.decl: %GenericParam.as.Destroy.impl.Op.type = fn_decl @GenericParam.as.Destroy.impl.Op [concrete = constants.%GenericParam.as.Destroy.impl.Op] {
  208. // CHECK:STDOUT: %self.patt: %pattern_type.7c3 = binding_pattern self [concrete]
  209. // CHECK:STDOUT: %self.param_patt: %pattern_type.7c3 = value_param_pattern %self.patt, call_param0 [concrete]
  210. // CHECK:STDOUT: %.loc19: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  211. // CHECK:STDOUT: } {
  212. // CHECK:STDOUT: %self.param: %ptr.f73 = value_param call_param0
  213. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%GenericParam [concrete = constants.%GenericParam]
  214. // CHECK:STDOUT: %self: %ptr.f73 = bind_name self, %self.param
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: !members:
  218. // CHECK:STDOUT: .Op = %GenericParam.as.Destroy.impl.Op.decl
  219. // CHECK:STDOUT: witness = @GenericParam.%Destroy.impl_witness
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: impl @ImplsGeneric.as.Destroy.impl: @ImplsGeneric.%Self.ref as constants.%Destroy.type {
  223. // CHECK:STDOUT: %ImplsGeneric.as.Destroy.impl.Op.decl: %ImplsGeneric.as.Destroy.impl.Op.type = fn_decl @ImplsGeneric.as.Destroy.impl.Op [concrete = constants.%ImplsGeneric.as.Destroy.impl.Op] {
  224. // CHECK:STDOUT: %self.patt: %pattern_type.2db = binding_pattern self [concrete]
  225. // CHECK:STDOUT: %self.param_patt: %pattern_type.2db = value_param_pattern %self.patt, call_param0 [concrete]
  226. // CHECK:STDOUT: %.loc21: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  227. // CHECK:STDOUT: } {
  228. // CHECK:STDOUT: %self.param: %ptr.011 = value_param call_param0
  229. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%ImplsGeneric [concrete = constants.%ImplsGeneric]
  230. // CHECK:STDOUT: %self: %ptr.011 = bind_name self, %self.param
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: !members:
  234. // CHECK:STDOUT: .Op = %ImplsGeneric.as.Destroy.impl.Op.decl
  235. // CHECK:STDOUT: witness = @ImplsGeneric.%Destroy.impl_witness
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: impl @ImplsGeneric.as.Generic.impl: %ImplsGeneric.ref as %Generic.type {
  239. // 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] {} {}
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: !members:
  242. // CHECK:STDOUT: .F = %ImplsGeneric.as.Generic.impl.F.decl
  243. // CHECK:STDOUT: witness = file.%Generic.impl_witness
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: impl @ImplsGeneric.as.Other.impl: %ImplsGeneric.ref as %Other.ref {
  247. // 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] {} {}
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: !members:
  250. // CHECK:STDOUT: .G = %ImplsGeneric.as.Other.impl.G.decl
  251. // CHECK:STDOUT: witness = file.%Other.impl_witness
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: class @GenericParam {
  255. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%GenericParam [concrete = constants.%GenericParam]
  256. // CHECK:STDOUT: impl_decl @GenericParam.as.Destroy.impl [concrete] {} {}
  257. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@GenericParam.as.Destroy.impl.%GenericParam.as.Destroy.impl.Op.decl), @GenericParam.as.Destroy.impl [concrete]
  258. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.7e7]
  259. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  260. // CHECK:STDOUT: complete_type_witness = %complete_type
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: !members:
  263. // CHECK:STDOUT: .Self = constants.%GenericParam
  264. // CHECK:STDOUT: }
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: class @ImplsGeneric {
  267. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%ImplsGeneric [concrete = constants.%ImplsGeneric]
  268. // CHECK:STDOUT: impl_decl @ImplsGeneric.as.Destroy.impl [concrete] {} {}
  269. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@ImplsGeneric.as.Destroy.impl.%ImplsGeneric.as.Destroy.impl.Op.decl), @ImplsGeneric.as.Destroy.impl [concrete]
  270. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.813]
  271. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  272. // CHECK:STDOUT: complete_type_witness = %complete_type
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: !members:
  275. // CHECK:STDOUT: .Self = constants.%ImplsGeneric
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: generic fn @Generic.F(@Generic.%Scalar.loc15_19.2: type, @Generic.%Self.1: @Generic.%Generic.type (%Generic.type.4045f4.1)) {
  279. // CHECK:STDOUT: fn();
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: fn @GenericParam.as.Destroy.impl.Op(%self.param: %ptr.f73) = "no_op";
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: fn @ImplsGeneric.as.Destroy.impl.Op(%self.param: %ptr.011) = "no_op";
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: fn @ImplsGeneric.as.Generic.impl.F() {
  287. // CHECK:STDOUT: !entry:
  288. // CHECK:STDOUT: return
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: generic fn @Other.G(@Other.%Self: %Other.type) {
  292. // CHECK:STDOUT: fn();
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: fn @ImplsGeneric.as.Other.impl.G();
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: generic fn @CallGenericMethod(%T.loc33_22.2: type, %U.loc33_32.2: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.4045f4.2)) {
  298. // CHECK:STDOUT: %T.loc33_22.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc33_22.1 (constants.%T)]
  299. // CHECK:STDOUT: %Generic.type.loc33_45.1: type = facet_type <@Generic, @Generic(%T.loc33_22.1)> [symbolic = %Generic.type.loc33_45.1 (constants.%Generic.type.4045f4.2)]
  300. // CHECK:STDOUT: %U.loc33_32.1: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.4045f4.2) = bind_symbolic_name U, 1 [symbolic = %U.loc33_32.1 (constants.%U)]
  301. // CHECK:STDOUT: %pattern_type: type = pattern_type %Generic.type.loc33_45.1 [symbolic = %pattern_type (constants.%pattern_type.3c6)]
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: !definition:
  304. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Generic.type.loc33_45.1 [symbolic = %require_complete (constants.%require_complete)]
  305. // CHECK:STDOUT: %Generic.assoc_type: type = assoc_entity_type @Generic, @Generic(%T.loc33_22.1) [symbolic = %Generic.assoc_type (constants.%Generic.assoc_type.0fd877.2)]
  306. // CHECK:STDOUT: %assoc0: @CallGenericMethod.%Generic.assoc_type (%Generic.assoc_type.0fd877.2) = assoc_entity element0, @Generic.%Generic.F.decl [symbolic = %assoc0 (constants.%assoc0.2966cb.2)]
  307. // CHECK:STDOUT: %U.as_type.loc34_4.2: type = facet_access_type %U.loc33_32.1 [symbolic = %U.as_type.loc34_4.2 (constants.%U.as_type)]
  308. // CHECK:STDOUT: %Generic.lookup_impl_witness: <witness> = lookup_impl_witness %U.loc33_32.1, @Generic, @Generic(%T.loc33_22.1) [symbolic = %Generic.lookup_impl_witness (constants.%Generic.lookup_impl_witness)]
  309. // CHECK:STDOUT: %Generic.F.type: type = fn_type @Generic.F, @Generic(%T.loc33_22.1) [symbolic = %Generic.F.type (constants.%Generic.F.type.f439a9.2)]
  310. // CHECK:STDOUT: %Generic.facet: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.4045f4.2) = facet_value %U.as_type.loc34_4.2, (%Generic.lookup_impl_witness) [symbolic = %Generic.facet (constants.%Generic.facet.049)]
  311. // CHECK:STDOUT: %.loc34_4.3: type = fn_type_with_self_type %Generic.F.type, %Generic.facet [symbolic = %.loc34_4.3 (constants.%.1bd)]
  312. // CHECK:STDOUT: %impl.elem0.loc34_4.2: @CallGenericMethod.%.loc34_4.3 (%.1bd) = impl_witness_access %Generic.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0)]
  313. // CHECK:STDOUT: %specific_impl_fn.loc34_4.2: <specific function> = specific_impl_function %impl.elem0.loc34_4.2, @Generic.F(%T.loc33_22.1, %Generic.facet) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn)]
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: fn() {
  316. // CHECK:STDOUT: !entry:
  317. // CHECK:STDOUT: %U.ref: @CallGenericMethod.%Generic.type.loc33_45.1 (%Generic.type.4045f4.2) = name_ref U, %U.loc33_32.2 [symbolic = %U.loc33_32.1 (constants.%U)]
  318. // CHECK:STDOUT: %.loc34_4.1: @CallGenericMethod.%Generic.assoc_type (%Generic.assoc_type.0fd877.2) = specific_constant @Generic.%assoc0.loc16_9.1, @Generic(constants.%T) [symbolic = %assoc0 (constants.%assoc0.2966cb.2)]
  319. // CHECK:STDOUT: %F.ref: @CallGenericMethod.%Generic.assoc_type (%Generic.assoc_type.0fd877.2) = name_ref F, %.loc34_4.1 [symbolic = %assoc0 (constants.%assoc0.2966cb.2)]
  320. // CHECK:STDOUT: %U.as_type.loc34_4.1: type = facet_access_type %U.ref [symbolic = %U.as_type.loc34_4.2 (constants.%U.as_type)]
  321. // CHECK:STDOUT: %.loc34_4.2: type = converted %U.ref, %U.as_type.loc34_4.1 [symbolic = %U.as_type.loc34_4.2 (constants.%U.as_type)]
  322. // CHECK:STDOUT: %impl.elem0.loc34_4.1: @CallGenericMethod.%.loc34_4.3 (%.1bd) = impl_witness_access constants.%Generic.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0)]
  323. // CHECK:STDOUT: %specific_impl_fn.loc34_4.1: <specific function> = specific_impl_function %impl.elem0.loc34_4.1, @Generic.F(constants.%T, constants.%Generic.facet.049) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn)]
  324. // CHECK:STDOUT: %.loc34_7: init %empty_tuple.type = call %specific_impl_fn.loc34_4.1()
  325. // CHECK:STDOUT: return
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: fn @G() {
  330. // CHECK:STDOUT: !entry:
  331. // CHECK:STDOUT: %CallGenericMethod.ref: %CallGenericMethod.type = name_ref CallGenericMethod, file.%CallGenericMethod.decl [concrete = constants.%CallGenericMethod]
  332. // CHECK:STDOUT: %GenericParam.ref: type = name_ref GenericParam, file.%GenericParam.decl [concrete = constants.%GenericParam]
  333. // CHECK:STDOUT: %ImplsGeneric.ref: type = name_ref ImplsGeneric, file.%ImplsGeneric.decl [concrete = constants.%ImplsGeneric]
  334. // CHECK:STDOUT: %Generic.facet: %Generic.type.cfe = facet_value constants.%ImplsGeneric, (constants.%Generic.impl_witness) [concrete = constants.%Generic.facet.924]
  335. // CHECK:STDOUT: %.loc38: %Generic.type.cfe = converted constants.%ImplsGeneric, %Generic.facet [concrete = constants.%Generic.facet.924]
  336. // CHECK:STDOUT: %CallGenericMethod.specific_fn: <specific function> = specific_function %CallGenericMethod.ref, @CallGenericMethod(constants.%GenericParam, constants.%Generic.facet.924) [concrete = constants.%CallGenericMethod.specific_fn]
  337. // CHECK:STDOUT: %CallGenericMethod.call: init %empty_tuple.type = call %CallGenericMethod.specific_fn()
  338. // CHECK:STDOUT: return
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: specific @Generic(constants.%Scalar) {
  342. // CHECK:STDOUT: %Scalar.loc15_19.1 => constants.%Scalar
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: specific @Generic.F(constants.%Scalar, constants.%Self.f48852.1) {}
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: specific @Generic(constants.%GenericParam) {
  348. // CHECK:STDOUT: %Scalar.loc15_19.1 => constants.%GenericParam
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: !definition:
  351. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.cfe
  352. // CHECK:STDOUT: %Self.2 => constants.%Self.b8f
  353. // CHECK:STDOUT: %Generic.F.type => constants.%Generic.F.type.4cf
  354. // CHECK:STDOUT: %Generic.F => constants.%Generic.F.118
  355. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.713
  356. // CHECK:STDOUT: %assoc0.loc16_9.2 => constants.%assoc0.9b7
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: specific @Generic.F(constants.%GenericParam, constants.%Generic.facet.924) {}
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: specific @Other.G(constants.%Self.939) {}
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: specific @Other.G(constants.%Other.facet) {}
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: specific @Generic(constants.%T) {
  366. // CHECK:STDOUT: %Scalar.loc15_19.1 => constants.%T
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: !definition:
  369. // CHECK:STDOUT: %Generic.type => constants.%Generic.type.4045f4.2
  370. // CHECK:STDOUT: %Self.2 => constants.%Self.f48852.2
  371. // CHECK:STDOUT: %Generic.F.type => constants.%Generic.F.type.f439a9.2
  372. // CHECK:STDOUT: %Generic.F => constants.%Generic.F.8a2d67.2
  373. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.0fd877.2
  374. // CHECK:STDOUT: %assoc0.loc16_9.2 => constants.%assoc0.2966cb.2
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: specific @CallGenericMethod(constants.%T, constants.%U) {
  378. // CHECK:STDOUT: %T.loc33_22.1 => constants.%T
  379. // CHECK:STDOUT: %Generic.type.loc33_45.1 => constants.%Generic.type.4045f4.2
  380. // CHECK:STDOUT: %U.loc33_32.1 => constants.%U
  381. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.3c6
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: specific @Generic.F(constants.%T, constants.%Generic.facet.049) {}
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: specific @CallGenericMethod(constants.%GenericParam, constants.%Generic.facet.924) {
  387. // CHECK:STDOUT: %T.loc33_22.1 => constants.%GenericParam
  388. // CHECK:STDOUT: %Generic.type.loc33_45.1 => constants.%Generic.type.cfe
  389. // CHECK:STDOUT: %U.loc33_32.1 => constants.%Generic.facet.924
  390. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.bd9
  391. // CHECK:STDOUT:
  392. // CHECK:STDOUT: !definition:
  393. // CHECK:STDOUT: %require_complete => constants.%complete_type.10d
  394. // CHECK:STDOUT: %Generic.assoc_type => constants.%Generic.assoc_type.713
  395. // CHECK:STDOUT: %assoc0 => constants.%assoc0.9b7
  396. // CHECK:STDOUT: %U.as_type.loc34_4.2 => constants.%ImplsGeneric
  397. // CHECK:STDOUT: %Generic.lookup_impl_witness => constants.%Generic.impl_witness
  398. // CHECK:STDOUT: %Generic.F.type => constants.%Generic.F.type.4cf
  399. // CHECK:STDOUT: %Generic.facet => constants.%Generic.facet.924
  400. // CHECK:STDOUT: %.loc34_4.3 => constants.%.e21
  401. // CHECK:STDOUT: %impl.elem0.loc34_4.2 => constants.%ImplsGeneric.as.Generic.impl.F
  402. // CHECK:STDOUT: %specific_impl_fn.loc34_4.2 => constants.%ImplsGeneric.as.Generic.impl.F
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT: