call_combined_impl_witness.carbon 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  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/facet/call_combined_impl_witness.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/call_combined_impl_witness.carbon
  14. interface Empty {
  15. }
  16. interface A {
  17. fn AA();
  18. }
  19. interface B {
  20. fn BB();
  21. }
  22. class C {}
  23. impl C as Empty {}
  24. impl C as A {
  25. fn AA() {}
  26. }
  27. impl C as B {
  28. fn BB() {}
  29. }
  30. fn G[T:! A & Empty & B](t: T) {
  31. t.AA();
  32. t.BB();
  33. T.AA();
  34. T.BB();
  35. T.(A.AA)();
  36. T.(B.BB)();
  37. }
  38. fn F() {
  39. G({} as C);
  40. }
  41. // CHECK:STDOUT: --- call_combined_impl_witness.carbon
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: constants {
  44. // CHECK:STDOUT: %Empty.type: type = facet_type <@Empty> [concrete]
  45. // CHECK:STDOUT: %Self.e3a: %Empty.type = bind_symbolic_name Self, 0 [symbolic]
  46. // CHECK:STDOUT: %A.type: type = facet_type <@A> [concrete]
  47. // CHECK:STDOUT: %Self.0dd: %A.type = bind_symbolic_name Self, 0 [symbolic]
  48. // CHECK:STDOUT: %A.AA.type: type = fn_type @A.AA [concrete]
  49. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  50. // CHECK:STDOUT: %A.AA: %A.AA.type = struct_value () [concrete]
  51. // CHECK:STDOUT: %A.assoc_type: type = assoc_entity_type @A [concrete]
  52. // CHECK:STDOUT: %assoc0.6e7: %A.assoc_type = assoc_entity element0, @A.%A.AA.decl [concrete]
  53. // CHECK:STDOUT: %B.type: type = facet_type <@B> [concrete]
  54. // CHECK:STDOUT: %Self.975: %B.type = bind_symbolic_name Self, 0 [symbolic]
  55. // CHECK:STDOUT: %B.BB.type: type = fn_type @B.BB [concrete]
  56. // CHECK:STDOUT: %B.BB: %B.BB.type = struct_value () [concrete]
  57. // CHECK:STDOUT: %B.assoc_type: type = assoc_entity_type @B [concrete]
  58. // CHECK:STDOUT: %assoc0.a29: %B.assoc_type = assoc_entity element0, @B.%B.BB.decl [concrete]
  59. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  60. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  61. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  62. // CHECK:STDOUT: %Destroy.impl_witness.071: <witness> = impl_witness @C.%Destroy.impl_witness_table [concrete]
  63. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  64. // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete]
  65. // CHECK:STDOUT: %C.as.Destroy.impl.Op.type: type = fn_type @C.as.Destroy.impl.Op [concrete]
  66. // CHECK:STDOUT: %C.as.Destroy.impl.Op: %C.as.Destroy.impl.Op.type = struct_value () [concrete]
  67. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  68. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  69. // CHECK:STDOUT: %Empty.impl_witness: <witness> = impl_witness file.%Empty.impl_witness_table [concrete]
  70. // CHECK:STDOUT: %A.impl_witness: <witness> = impl_witness file.%A.impl_witness_table [concrete]
  71. // CHECK:STDOUT: %C.as.A.impl.AA.type: type = fn_type @C.as.A.impl.AA [concrete]
  72. // CHECK:STDOUT: %C.as.A.impl.AA: %C.as.A.impl.AA.type = struct_value () [concrete]
  73. // CHECK:STDOUT: %A.facet.d7e: %A.type = facet_value %C, (%A.impl_witness) [concrete]
  74. // CHECK:STDOUT: %B.impl_witness: <witness> = impl_witness file.%B.impl_witness_table [concrete]
  75. // CHECK:STDOUT: %C.as.B.impl.BB.type: type = fn_type @C.as.B.impl.BB [concrete]
  76. // CHECK:STDOUT: %C.as.B.impl.BB: %C.as.B.impl.BB.type = struct_value () [concrete]
  77. // CHECK:STDOUT: %B.facet.c0b: %B.type = facet_value %C, (%B.impl_witness) [concrete]
  78. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  79. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self]
  80. // CHECK:STDOUT: %BitAndWith.type.f2e: type = generic_interface_type @BitAndWith [concrete]
  81. // CHECK:STDOUT: %BitAndWith.generic: %BitAndWith.type.f2e = struct_value () [concrete]
  82. // CHECK:STDOUT: %BitAndWith.type.8a6: type = facet_type <@BitAndWith, @BitAndWith(type)> [concrete]
  83. // CHECK:STDOUT: %BitAndWith.Op.type.9a3: type = fn_type @BitAndWith.Op, @BitAndWith(type) [concrete]
  84. // CHECK:STDOUT: %BitAndWith.impl_witness: <witness> = impl_witness imports.%BitAndWith.impl_witness_table [concrete]
  85. // CHECK:STDOUT: %BitAndWith.facet: %BitAndWith.type.8a6 = facet_value type, (%BitAndWith.impl_witness) [concrete]
  86. // CHECK:STDOUT: %.fa7: type = fn_type_with_self_type %BitAndWith.Op.type.9a3, %BitAndWith.facet [concrete]
  87. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.type: type = fn_type @type.as.BitAndWith.impl.Op [concrete]
  88. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op: %type.as.BitAndWith.impl.Op.type = struct_value () [concrete]
  89. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.bound.152: <bound method> = bound_method %A.type, %type.as.BitAndWith.impl.Op [concrete]
  90. // CHECK:STDOUT: %facet_type.c95: type = facet_type <@Empty & @A> [concrete]
  91. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.bound.49f: <bound method> = bound_method %facet_type.c95, %type.as.BitAndWith.impl.Op [concrete]
  92. // CHECK:STDOUT: %facet_type.b5f: type = facet_type <@Empty & @A & @B> [concrete]
  93. // CHECK:STDOUT: %T: %facet_type.b5f = bind_symbolic_name T, 0 [symbolic]
  94. // CHECK:STDOUT: %pattern_type.001: type = pattern_type %facet_type.b5f [concrete]
  95. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  96. // CHECK:STDOUT: %pattern_type.e02: type = pattern_type %T.as_type [symbolic]
  97. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  98. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  99. // CHECK:STDOUT: %require_complete.359: <witness> = require_complete_type %T.as_type [symbolic]
  100. // CHECK:STDOUT: %A.lookup_impl_witness: <witness> = lookup_impl_witness %T, @A [symbolic]
  101. // CHECK:STDOUT: %A.facet.d1f: %A.type = facet_value %T.as_type, (%A.lookup_impl_witness) [symbolic]
  102. // CHECK:STDOUT: %.b2b: type = fn_type_with_self_type %A.AA.type, %A.facet.d1f [symbolic]
  103. // CHECK:STDOUT: %impl.elem0.d41: %.b2b = impl_witness_access %A.lookup_impl_witness, element0 [symbolic]
  104. // CHECK:STDOUT: %specific_impl_fn.e57: <specific function> = specific_impl_function %impl.elem0.d41, @A.AA(%A.facet.d1f) [symbolic]
  105. // CHECK:STDOUT: %B.lookup_impl_witness: <witness> = lookup_impl_witness %T, @B [symbolic]
  106. // CHECK:STDOUT: %B.facet.434: %B.type = facet_value %T.as_type, (%B.lookup_impl_witness) [symbolic]
  107. // CHECK:STDOUT: %.1ce: type = fn_type_with_self_type %B.BB.type, %B.facet.434 [symbolic]
  108. // CHECK:STDOUT: %impl.elem0.629: %.1ce = impl_witness_access %B.lookup_impl_witness, element0 [symbolic]
  109. // CHECK:STDOUT: %specific_impl_fn.c90: <specific function> = specific_impl_function %impl.elem0.629, @B.BB(%B.facet.434) [symbolic]
  110. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  111. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  112. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  113. // CHECK:STDOUT: %facet_value: %facet_type.b5f = facet_value %C, (%Empty.impl_witness, %A.impl_witness, %B.impl_witness) [concrete]
  114. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  115. // CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G, @G(%facet_value) [concrete]
  116. // CHECK:STDOUT: %.1ee: type = fn_type_with_self_type %A.AA.type, %A.facet.d7e [concrete]
  117. // CHECK:STDOUT: %.d72: type = fn_type_with_self_type %B.BB.type, %B.facet.c0b [concrete]
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: imports {
  121. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  122. // CHECK:STDOUT: .Destroy = %Core.Destroy
  123. // CHECK:STDOUT: .BitAndWith = %Core.BitAndWith
  124. // CHECK:STDOUT: import Core//prelude
  125. // CHECK:STDOUT: import Core//prelude/...
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  128. // CHECK:STDOUT: %Core.BitAndWith: %BitAndWith.type.f2e = import_ref Core//prelude/parts/as, BitAndWith, loaded [concrete = constants.%BitAndWith.generic]
  129. // CHECK:STDOUT: %Core.import_ref.636: %type.as.BitAndWith.impl.Op.type = import_ref Core//prelude/parts/as, loc25_42, loaded [concrete = constants.%type.as.BitAndWith.impl.Op]
  130. // CHECK:STDOUT: %BitAndWith.impl_witness_table = impl_witness_table (%Core.import_ref.636), @type.as.BitAndWith.impl [concrete]
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: file {
  134. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  135. // CHECK:STDOUT: .Core = imports.%Core
  136. // CHECK:STDOUT: .Empty = %Empty.decl
  137. // CHECK:STDOUT: .A = %A.decl
  138. // CHECK:STDOUT: .B = %B.decl
  139. // CHECK:STDOUT: .C = %C.decl
  140. // CHECK:STDOUT: .G = %G.decl
  141. // CHECK:STDOUT: .F = %F.decl
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT: %Core.import = import Core
  144. // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [concrete = constants.%Empty.type] {} {}
  145. // CHECK:STDOUT: %A.decl: type = interface_decl @A [concrete = constants.%A.type] {} {}
  146. // CHECK:STDOUT: %B.decl: type = interface_decl @B [concrete = constants.%B.type] {} {}
  147. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  148. // CHECK:STDOUT: impl_decl @C.as.Empty.impl [concrete] {} {
  149. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  150. // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, file.%Empty.decl [concrete = constants.%Empty.type]
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: %Empty.impl_witness_table = impl_witness_table (), @C.as.Empty.impl [concrete]
  153. // CHECK:STDOUT: %Empty.impl_witness: <witness> = impl_witness %Empty.impl_witness_table [concrete = constants.%Empty.impl_witness]
  154. // CHECK:STDOUT: impl_decl @C.as.A.impl [concrete] {} {
  155. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  156. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A.type]
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT: %A.impl_witness_table = impl_witness_table (@C.as.A.impl.%C.as.A.impl.AA.decl), @C.as.A.impl [concrete]
  159. // CHECK:STDOUT: %A.impl_witness: <witness> = impl_witness %A.impl_witness_table [concrete = constants.%A.impl_witness]
  160. // CHECK:STDOUT: impl_decl @C.as.B.impl [concrete] {} {
  161. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  162. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B.type]
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT: %B.impl_witness_table = impl_witness_table (@C.as.B.impl.%C.as.B.impl.BB.decl), @C.as.B.impl [concrete]
  165. // CHECK:STDOUT: %B.impl_witness: <witness> = impl_witness %B.impl_witness_table [concrete = constants.%B.impl_witness]
  166. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  167. // CHECK:STDOUT: %T.patt: %pattern_type.001 = symbolic_binding_pattern T, 0 [concrete]
  168. // CHECK:STDOUT: %t.patt: @G.%pattern_type (%pattern_type.e02) = binding_pattern t [concrete]
  169. // CHECK:STDOUT: %t.param_patt: @G.%pattern_type (%pattern_type.e02) = value_param_pattern %t.patt, call_param0 [concrete]
  170. // CHECK:STDOUT: } {
  171. // CHECK:STDOUT: %.loc33_20.1: type = splice_block %.loc33_20.3 [concrete = constants.%facet_type.b5f] {
  172. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  173. // CHECK:STDOUT: %A.ref.loc33: type = name_ref A, file.%A.decl [concrete = constants.%A.type]
  174. // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, file.%Empty.decl [concrete = constants.%Empty.type]
  175. // CHECK:STDOUT: %impl.elem0.loc33_12: %.fa7 = impl_witness_access constants.%BitAndWith.impl_witness, element0 [concrete = constants.%type.as.BitAndWith.impl.Op]
  176. // CHECK:STDOUT: %bound_method.loc33_12: <bound method> = bound_method %A.ref.loc33, %impl.elem0.loc33_12 [concrete = constants.%type.as.BitAndWith.impl.Op.bound.152]
  177. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.call.loc33_12: init type = call %bound_method.loc33_12(%A.ref.loc33, %Empty.ref) [concrete = constants.%facet_type.c95]
  178. // CHECK:STDOUT: %B.ref.loc33: type = name_ref B, file.%B.decl [concrete = constants.%B.type]
  179. // CHECK:STDOUT: %impl.elem0.loc33_20: %.fa7 = impl_witness_access constants.%BitAndWith.impl_witness, element0 [concrete = constants.%type.as.BitAndWith.impl.Op]
  180. // CHECK:STDOUT: %bound_method.loc33_20: <bound method> = bound_method %type.as.BitAndWith.impl.Op.call.loc33_12, %impl.elem0.loc33_20 [concrete = constants.%type.as.BitAndWith.impl.Op.bound.49f]
  181. // CHECK:STDOUT: %.loc33_12.1: type = value_of_initializer %type.as.BitAndWith.impl.Op.call.loc33_12 [concrete = constants.%facet_type.c95]
  182. // CHECK:STDOUT: %.loc33_12.2: type = converted %type.as.BitAndWith.impl.Op.call.loc33_12, %.loc33_12.1 [concrete = constants.%facet_type.c95]
  183. // CHECK:STDOUT: %type.as.BitAndWith.impl.Op.call.loc33_20: init type = call %bound_method.loc33_20(%.loc33_12.2, %B.ref.loc33) [concrete = constants.%facet_type.b5f]
  184. // CHECK:STDOUT: %.loc33_20.2: type = value_of_initializer %type.as.BitAndWith.impl.Op.call.loc33_20 [concrete = constants.%facet_type.b5f]
  185. // CHECK:STDOUT: %.loc33_20.3: type = converted %type.as.BitAndWith.impl.Op.call.loc33_20, %.loc33_20.2 [concrete = constants.%facet_type.b5f]
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: %T.loc33_6.2: %facet_type.b5f = bind_symbolic_name T, 0 [symbolic = %T.loc33_6.1 (constants.%T)]
  188. // CHECK:STDOUT: %t.param: @G.%T.as_type.loc33_28.1 (%T.as_type) = value_param call_param0
  189. // CHECK:STDOUT: %.loc33_28.1: type = splice_block %.loc33_28.2 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)] {
  190. // CHECK:STDOUT: %T.ref.loc33: %facet_type.b5f = name_ref T, %T.loc33_6.2 [symbolic = %T.loc33_6.1 (constants.%T)]
  191. // CHECK:STDOUT: %T.as_type.loc33_28.2: type = facet_access_type %T.ref.loc33 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  192. // CHECK:STDOUT: %.loc33_28.2: type = converted %T.ref.loc33, %T.as_type.loc33_28.2 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT: %t: @G.%T.as_type.loc33_28.1 (%T.as_type) = bind_name t, %t.param
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: interface @Empty {
  200. // CHECK:STDOUT: %Self: %Empty.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.e3a]
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: !members:
  203. // CHECK:STDOUT: .Self = %Self
  204. // CHECK:STDOUT: .AA = <poisoned>
  205. // CHECK:STDOUT: .BB = <poisoned>
  206. // CHECK:STDOUT: witness = ()
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: interface @A {
  210. // CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.0dd]
  211. // CHECK:STDOUT: %A.AA.decl: %A.AA.type = fn_decl @A.AA [concrete = constants.%A.AA] {} {}
  212. // CHECK:STDOUT: %assoc0: %A.assoc_type = assoc_entity element0, %A.AA.decl [concrete = constants.%assoc0.6e7]
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: !members:
  215. // CHECK:STDOUT: .Self = %Self
  216. // CHECK:STDOUT: .AA = %assoc0
  217. // CHECK:STDOUT: .BB = <poisoned>
  218. // CHECK:STDOUT: witness = (%A.AA.decl)
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: interface @B {
  222. // CHECK:STDOUT: %Self: %B.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.975]
  223. // CHECK:STDOUT: %B.BB.decl: %B.BB.type = fn_decl @B.BB [concrete = constants.%B.BB] {} {}
  224. // CHECK:STDOUT: %assoc0: %B.assoc_type = assoc_entity element0, %B.BB.decl [concrete = constants.%assoc0.a29]
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: !members:
  227. // CHECK:STDOUT: .Self = %Self
  228. // CHECK:STDOUT: .BB = %assoc0
  229. // CHECK:STDOUT: .AA = <poisoned>
  230. // CHECK:STDOUT: witness = (%B.BB.decl)
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: impl @C.as.Destroy.impl: @C.%Self.ref as constants.%Destroy.type {
  234. // CHECK:STDOUT: %C.as.Destroy.impl.Op.decl: %C.as.Destroy.impl.Op.type = fn_decl @C.as.Destroy.impl.Op [concrete = constants.%C.as.Destroy.impl.Op] {
  235. // CHECK:STDOUT: %self.patt: %pattern_type.44a = binding_pattern self [concrete]
  236. // CHECK:STDOUT: %self.param_patt: %pattern_type.44a = value_param_pattern %self.patt, call_param0 [concrete]
  237. // CHECK:STDOUT: %.loc24: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  238. // CHECK:STDOUT: } {
  239. // CHECK:STDOUT: %self.param: %ptr.019 = value_param call_param0
  240. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  241. // CHECK:STDOUT: %self: %ptr.019 = bind_name self, %self.param
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: !members:
  245. // CHECK:STDOUT: .Op = %C.as.Destroy.impl.Op.decl
  246. // CHECK:STDOUT: witness = @C.%Destroy.impl_witness
  247. // CHECK:STDOUT: }
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: impl @C.as.Empty.impl: %C.ref as %Empty.ref {
  250. // CHECK:STDOUT: !members:
  251. // CHECK:STDOUT: witness = file.%Empty.impl_witness
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: impl @C.as.A.impl: %C.ref as %A.ref {
  255. // CHECK:STDOUT: %C.as.A.impl.AA.decl: %C.as.A.impl.AA.type = fn_decl @C.as.A.impl.AA [concrete = constants.%C.as.A.impl.AA] {} {}
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: !members:
  258. // CHECK:STDOUT: .AA = %C.as.A.impl.AA.decl
  259. // CHECK:STDOUT: witness = file.%A.impl_witness
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: impl @C.as.B.impl: %C.ref as %B.ref {
  263. // CHECK:STDOUT: %C.as.B.impl.BB.decl: %C.as.B.impl.BB.type = fn_decl @C.as.B.impl.BB [concrete = constants.%C.as.B.impl.BB] {} {}
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: !members:
  266. // CHECK:STDOUT: .BB = %C.as.B.impl.BB.decl
  267. // CHECK:STDOUT: witness = file.%B.impl_witness
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: class @C {
  271. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  272. // CHECK:STDOUT: impl_decl @C.as.Destroy.impl [concrete] {} {}
  273. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@C.as.Destroy.impl.%C.as.Destroy.impl.Op.decl), @C.as.Destroy.impl [concrete]
  274. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.071]
  275. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  276. // CHECK:STDOUT: complete_type_witness = %complete_type
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: !members:
  279. // CHECK:STDOUT: .Self = constants.%C
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: generic fn @A.AA(@A.%Self: %A.type) {
  283. // CHECK:STDOUT: fn();
  284. // CHECK:STDOUT: }
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: generic fn @B.BB(@B.%Self: %B.type) {
  287. // CHECK:STDOUT: fn();
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: fn @C.as.Destroy.impl.Op(%self.param: %ptr.019) = "no_op";
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: fn @C.as.A.impl.AA() {
  293. // CHECK:STDOUT: !entry:
  294. // CHECK:STDOUT: return
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: fn @C.as.B.impl.BB() {
  298. // CHECK:STDOUT: !entry:
  299. // CHECK:STDOUT: return
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: generic fn @G(%T.loc33_6.2: %facet_type.b5f) {
  303. // CHECK:STDOUT: %T.loc33_6.1: %facet_type.b5f = bind_symbolic_name T, 0 [symbolic = %T.loc33_6.1 (constants.%T)]
  304. // CHECK:STDOUT: %T.as_type.loc33_28.1: type = facet_access_type %T.loc33_6.1 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  305. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.as_type.loc33_28.1 [symbolic = %pattern_type (constants.%pattern_type.e02)]
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: !definition:
  308. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.as_type.loc33_28.1 [symbolic = %require_complete (constants.%require_complete.359)]
  309. // CHECK:STDOUT: %A.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc33_6.1, @A [symbolic = %A.lookup_impl_witness (constants.%A.lookup_impl_witness)]
  310. // CHECK:STDOUT: %A.facet.loc34: %A.type = facet_value %T.as_type.loc33_28.1, (%A.lookup_impl_witness) [symbolic = %A.facet.loc34 (constants.%A.facet.d1f)]
  311. // CHECK:STDOUT: %.loc34_4.2: type = fn_type_with_self_type constants.%A.AA.type, %A.facet.loc34 [symbolic = %.loc34_4.2 (constants.%.b2b)]
  312. // CHECK:STDOUT: %impl.elem0.loc34_4.2: @G.%.loc34_4.2 (%.b2b) = impl_witness_access %A.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0.d41)]
  313. // CHECK:STDOUT: %specific_impl_fn.loc34_4.2: <specific function> = specific_impl_function %impl.elem0.loc34_4.2, @A.AA(%A.facet.loc34) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn.e57)]
  314. // CHECK:STDOUT: %B.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc33_6.1, @B [symbolic = %B.lookup_impl_witness (constants.%B.lookup_impl_witness)]
  315. // CHECK:STDOUT: %B.facet.loc35: %B.type = facet_value %T.as_type.loc33_28.1, (%B.lookup_impl_witness) [symbolic = %B.facet.loc35 (constants.%B.facet.434)]
  316. // CHECK:STDOUT: %.loc35_4.2: type = fn_type_with_self_type constants.%B.BB.type, %B.facet.loc35 [symbolic = %.loc35_4.2 (constants.%.1ce)]
  317. // CHECK:STDOUT: %impl.elem0.loc35_4.2: @G.%.loc35_4.2 (%.1ce) = impl_witness_access %B.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc35_4.2 (constants.%impl.elem0.629)]
  318. // CHECK:STDOUT: %specific_impl_fn.loc35_4.2: <specific function> = specific_impl_function %impl.elem0.loc35_4.2, @B.BB(%B.facet.loc35) [symbolic = %specific_impl_fn.loc35_4.2 (constants.%specific_impl_fn.c90)]
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: fn(%t.param: @G.%T.as_type.loc33_28.1 (%T.as_type)) {
  321. // CHECK:STDOUT: !entry:
  322. // CHECK:STDOUT: %t.ref.loc34: @G.%T.as_type.loc33_28.1 (%T.as_type) = name_ref t, %t
  323. // CHECK:STDOUT: %AA.ref.loc34: %A.assoc_type = name_ref AA, @A.%assoc0 [concrete = constants.%assoc0.6e7]
  324. // CHECK:STDOUT: %T.as_type.loc34: type = facet_access_type constants.%T [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  325. // CHECK:STDOUT: %.loc34_4.1: type = converted constants.%T, %T.as_type.loc34 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  326. // CHECK:STDOUT: %impl.elem0.loc34_4.1: @G.%.loc34_4.2 (%.b2b) = impl_witness_access constants.%A.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0.d41)]
  327. // CHECK:STDOUT: %specific_impl_fn.loc34_4.1: <specific function> = specific_impl_function %impl.elem0.loc34_4.1, @A.AA(constants.%A.facet.d1f) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn.e57)]
  328. // CHECK:STDOUT: %.loc34_8: init %empty_tuple.type = call %specific_impl_fn.loc34_4.1()
  329. // CHECK:STDOUT: %t.ref.loc35: @G.%T.as_type.loc33_28.1 (%T.as_type) = name_ref t, %t
  330. // CHECK:STDOUT: %BB.ref.loc35: %B.assoc_type = name_ref BB, @B.%assoc0 [concrete = constants.%assoc0.a29]
  331. // CHECK:STDOUT: %T.as_type.loc35: type = facet_access_type constants.%T [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  332. // CHECK:STDOUT: %.loc35_4.1: type = converted constants.%T, %T.as_type.loc35 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  333. // CHECK:STDOUT: %impl.elem0.loc35_4.1: @G.%.loc35_4.2 (%.1ce) = impl_witness_access constants.%B.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc35_4.2 (constants.%impl.elem0.629)]
  334. // CHECK:STDOUT: %specific_impl_fn.loc35_4.1: <specific function> = specific_impl_function %impl.elem0.loc35_4.1, @B.BB(constants.%B.facet.434) [symbolic = %specific_impl_fn.loc35_4.2 (constants.%specific_impl_fn.c90)]
  335. // CHECK:STDOUT: %.loc35_8: init %empty_tuple.type = call %specific_impl_fn.loc35_4.1()
  336. // CHECK:STDOUT: %T.ref.loc37: %facet_type.b5f = name_ref T, %T.loc33_6.2 [symbolic = %T.loc33_6.1 (constants.%T)]
  337. // CHECK:STDOUT: %AA.ref.loc37: %A.assoc_type = name_ref AA, @A.%assoc0 [concrete = constants.%assoc0.6e7]
  338. // CHECK:STDOUT: %T.as_type.loc37: type = facet_access_type %T.ref.loc37 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  339. // CHECK:STDOUT: %.loc37_4: type = converted %T.ref.loc37, %T.as_type.loc37 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  340. // CHECK:STDOUT: %impl.elem0.loc37: @G.%.loc34_4.2 (%.b2b) = impl_witness_access constants.%A.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0.d41)]
  341. // CHECK:STDOUT: %specific_impl_fn.loc37: <specific function> = specific_impl_function %impl.elem0.loc37, @A.AA(constants.%A.facet.d1f) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn.e57)]
  342. // CHECK:STDOUT: %.loc37_8: init %empty_tuple.type = call %specific_impl_fn.loc37()
  343. // CHECK:STDOUT: %T.ref.loc38: %facet_type.b5f = name_ref T, %T.loc33_6.2 [symbolic = %T.loc33_6.1 (constants.%T)]
  344. // CHECK:STDOUT: %BB.ref.loc38: %B.assoc_type = name_ref BB, @B.%assoc0 [concrete = constants.%assoc0.a29]
  345. // CHECK:STDOUT: %T.as_type.loc38: type = facet_access_type %T.ref.loc38 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  346. // CHECK:STDOUT: %.loc38_4: type = converted %T.ref.loc38, %T.as_type.loc38 [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  347. // CHECK:STDOUT: %impl.elem0.loc38: @G.%.loc35_4.2 (%.1ce) = impl_witness_access constants.%B.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc35_4.2 (constants.%impl.elem0.629)]
  348. // CHECK:STDOUT: %specific_impl_fn.loc38: <specific function> = specific_impl_function %impl.elem0.loc38, @B.BB(constants.%B.facet.434) [symbolic = %specific_impl_fn.loc35_4.2 (constants.%specific_impl_fn.c90)]
  349. // CHECK:STDOUT: %.loc38_8: init %empty_tuple.type = call %specific_impl_fn.loc38()
  350. // CHECK:STDOUT: %T.ref.loc40: %facet_type.b5f = name_ref T, %T.loc33_6.2 [symbolic = %T.loc33_6.1 (constants.%T)]
  351. // CHECK:STDOUT: %A.ref.loc40: type = name_ref A, file.%A.decl [concrete = constants.%A.type]
  352. // CHECK:STDOUT: %AA.ref.loc40: %A.assoc_type = name_ref AA, @A.%assoc0 [concrete = constants.%assoc0.6e7]
  353. // CHECK:STDOUT: %T.as_type.loc40: type = facet_access_type constants.%T [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  354. // CHECK:STDOUT: %A.facet.loc40: %A.type = facet_value %T.as_type.loc40, (constants.%A.lookup_impl_witness) [symbolic = %A.facet.loc34 (constants.%A.facet.d1f)]
  355. // CHECK:STDOUT: %.loc40_4: %A.type = converted %T.ref.loc40, %A.facet.loc40 [symbolic = %A.facet.loc34 (constants.%A.facet.d1f)]
  356. // CHECK:STDOUT: %impl.elem0.loc40: @G.%.loc34_4.2 (%.b2b) = impl_witness_access constants.%A.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc34_4.2 (constants.%impl.elem0.d41)]
  357. // CHECK:STDOUT: %specific_impl_fn.loc40: <specific function> = specific_impl_function %impl.elem0.loc40, @A.AA(constants.%A.facet.d1f) [symbolic = %specific_impl_fn.loc34_4.2 (constants.%specific_impl_fn.e57)]
  358. // CHECK:STDOUT: %.loc40_12: init %empty_tuple.type = call %specific_impl_fn.loc40()
  359. // CHECK:STDOUT: %T.ref.loc41: %facet_type.b5f = name_ref T, %T.loc33_6.2 [symbolic = %T.loc33_6.1 (constants.%T)]
  360. // CHECK:STDOUT: %B.ref.loc41: type = name_ref B, file.%B.decl [concrete = constants.%B.type]
  361. // CHECK:STDOUT: %BB.ref.loc41: %B.assoc_type = name_ref BB, @B.%assoc0 [concrete = constants.%assoc0.a29]
  362. // CHECK:STDOUT: %T.as_type.loc41: type = facet_access_type constants.%T [symbolic = %T.as_type.loc33_28.1 (constants.%T.as_type)]
  363. // CHECK:STDOUT: %B.facet.loc41: %B.type = facet_value %T.as_type.loc41, (constants.%B.lookup_impl_witness) [symbolic = %B.facet.loc35 (constants.%B.facet.434)]
  364. // CHECK:STDOUT: %.loc41_4: %B.type = converted %T.ref.loc41, %B.facet.loc41 [symbolic = %B.facet.loc35 (constants.%B.facet.434)]
  365. // CHECK:STDOUT: %impl.elem0.loc41: @G.%.loc35_4.2 (%.1ce) = impl_witness_access constants.%B.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc35_4.2 (constants.%impl.elem0.629)]
  366. // CHECK:STDOUT: %specific_impl_fn.loc41: <specific function> = specific_impl_function %impl.elem0.loc41, @B.BB(constants.%B.facet.434) [symbolic = %specific_impl_fn.loc35_4.2 (constants.%specific_impl_fn.c90)]
  367. // CHECK:STDOUT: %.loc41_12: init %empty_tuple.type = call %specific_impl_fn.loc41()
  368. // CHECK:STDOUT: return
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: fn @F() {
  373. // CHECK:STDOUT: !entry:
  374. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
  375. // CHECK:STDOUT: %.loc45_6.1: %empty_struct_type = struct_literal ()
  376. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  377. // CHECK:STDOUT: %.loc45_6.2: ref %C = temporary_storage
  378. // CHECK:STDOUT: %.loc45_6.3: init %C = class_init (), %.loc45_6.2 [concrete = constants.%C.val]
  379. // CHECK:STDOUT: %.loc45_6.4: ref %C = temporary %.loc45_6.2, %.loc45_6.3
  380. // CHECK:STDOUT: %.loc45_8.1: ref %C = converted %.loc45_6.1, %.loc45_6.4
  381. // CHECK:STDOUT: %facet_value.loc45_12.1: %facet_type.b5f = facet_value constants.%C, (constants.%Empty.impl_witness, constants.%A.impl_witness, constants.%B.impl_witness) [concrete = constants.%facet_value]
  382. // CHECK:STDOUT: %.loc45_12.1: %facet_type.b5f = converted constants.%C, %facet_value.loc45_12.1 [concrete = constants.%facet_value]
  383. // CHECK:STDOUT: %facet_value.loc45_12.2: %facet_type.b5f = facet_value constants.%C, (constants.%Empty.impl_witness, constants.%A.impl_witness, constants.%B.impl_witness) [concrete = constants.%facet_value]
  384. // CHECK:STDOUT: %.loc45_12.2: %facet_type.b5f = converted constants.%C, %facet_value.loc45_12.2 [concrete = constants.%facet_value]
  385. // CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G.ref, @G(constants.%facet_value) [concrete = constants.%G.specific_fn]
  386. // CHECK:STDOUT: %.loc45_8.2: %C = bind_value %.loc45_8.1
  387. // CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.specific_fn(%.loc45_8.2)
  388. // CHECK:STDOUT: %C.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc45_6.4, constants.%C.as.Destroy.impl.Op
  389. // CHECK:STDOUT: %addr: %ptr.019 = addr_of %.loc45_6.4
  390. // CHECK:STDOUT: %C.as.Destroy.impl.Op.call: init %empty_tuple.type = call %C.as.Destroy.impl.Op.bound(%addr)
  391. // CHECK:STDOUT: return
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: specific @A.AA(constants.%Self.0dd) {}
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: specific @B.BB(constants.%Self.975) {}
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: specific @A.AA(constants.%A.facet.d7e) {}
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: specific @B.BB(constants.%B.facet.c0b) {}
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: specific @G(constants.%T) {
  403. // CHECK:STDOUT: %T.loc33_6.1 => constants.%T
  404. // CHECK:STDOUT: %T.as_type.loc33_28.1 => constants.%T.as_type
  405. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.e02
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: specific @A.AA(constants.%A.facet.d1f) {}
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: specific @B.BB(constants.%B.facet.434) {}
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: specific @G(constants.%facet_value) {
  413. // CHECK:STDOUT: %T.loc33_6.1 => constants.%facet_value
  414. // CHECK:STDOUT: %T.as_type.loc33_28.1 => constants.%C
  415. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.c48
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: !definition:
  418. // CHECK:STDOUT: %require_complete => constants.%complete_type
  419. // CHECK:STDOUT: %A.lookup_impl_witness => constants.%A.impl_witness
  420. // CHECK:STDOUT: %A.facet.loc34 => constants.%A.facet.d7e
  421. // CHECK:STDOUT: %.loc34_4.2 => constants.%.1ee
  422. // CHECK:STDOUT: %impl.elem0.loc34_4.2 => constants.%C.as.A.impl.AA
  423. // CHECK:STDOUT: %specific_impl_fn.loc34_4.2 => constants.%C.as.A.impl.AA
  424. // CHECK:STDOUT: %B.lookup_impl_witness => constants.%B.impl_witness
  425. // CHECK:STDOUT: %B.facet.loc35 => constants.%B.facet.c0b
  426. // CHECK:STDOUT: %.loc35_4.2 => constants.%.d72
  427. // CHECK:STDOUT: %impl.elem0.loc35_4.2 => constants.%C.as.B.impl.BB
  428. // CHECK:STDOUT: %specific_impl_fn.loc35_4.2 => constants.%C.as.B.impl.BB
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT: